Skip to content

Commit 4fde330

Browse files
author
Hyunje Jun
committed
Add types for flex message
Resolve #74.
1 parent 772e9c6 commit 4fde330

File tree

1 file changed

+162
-1
lines changed

1 file changed

+162
-1
lines changed

lib/types.ts

Lines changed: 162 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ export type Message =
128128
| LocationMessage
129129
| StickerMessage
130130
| ImageMapMessage
131-
| TemplateMessage;
131+
| TemplateMessage
132+
| FlexMessage;
132133

133134
export type TextMessage = {
134135
type: "text";
@@ -181,6 +182,12 @@ export type TemplateMessage = {
181182
template: TemplateContent;
182183
};
183184

185+
export type FlexMessage = {
186+
type: "flex";
187+
altText: string;
188+
contents: FlexContainer;
189+
};
190+
184191
export type ImageMapAction = ImageMapURIAction | ImageMapMessageAction;
185192

186193
export type ImageMapActionBase = { area: Area };
@@ -202,6 +209,160 @@ export type Area = {
202209
height: number;
203210
};
204211

212+
export type FlexContainer = FlexBubble | FlexCarousel;
213+
214+
export type FlexBubble = {
215+
type: "bubble";
216+
direction?: "ltr" | "rtl";
217+
header?: FlexBox;
218+
hero?: FlexImage;
219+
body?: FlexBox;
220+
footer?: FlexBox;
221+
styles?: FlexBubbleStyle;
222+
};
223+
224+
export type FlexBubbleStyle = {
225+
header?: FlexBlockStyle;
226+
hero?: FlexBlockStyle;
227+
body?: FlexBlockStyle;
228+
footer?: FlexBlockStyle;
229+
};
230+
231+
export type FlexBlockStyle = {
232+
backgroundColor?: string;
233+
separator?: boolean;
234+
separatorColor?: string;
235+
};
236+
237+
export type FlexCarousel = {
238+
type: "carousel";
239+
contents: FlexBubble[];
240+
};
241+
242+
export type FlexComponent =
243+
| FlexBox
244+
| FlexButton
245+
| FlexFiller
246+
| FlexIcon
247+
| FlexImage
248+
| FlexSeparator
249+
| FlexSpacer
250+
| FlexText;
251+
252+
export type FlexBox = {
253+
type: "box";
254+
layout: "horizontal" | "vertical" | "baseline";
255+
contents: FlexComponent[];
256+
flex?: number;
257+
spacing?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
258+
margin?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
259+
};
260+
261+
export type FlexButton = {
262+
type: "button";
263+
action: Action<{ label: string }>;
264+
flex?: number;
265+
margin?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
266+
height?: "sm" | "md";
267+
style?: "link" | "secondary" | "primary";
268+
color?: string;
269+
gravity?: "top" | "bottom" | "center";
270+
};
271+
272+
export type FlexFiller = {
273+
type: "filler";
274+
};
275+
276+
export type FlexIcon = {
277+
type: "icon";
278+
url: string;
279+
margin?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
280+
size?:
281+
| "xxs"
282+
| "xs"
283+
| "sm"
284+
| "md"
285+
| "lg"
286+
| "xl"
287+
| "xxl"
288+
| "3xl"
289+
| "4xl"
290+
| "5xl";
291+
aspectRatio?: "1:1" | "2:1" | "3:1";
292+
};
293+
294+
export type FlexImage = {
295+
type: "image";
296+
url: string;
297+
flex?: number;
298+
margin?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
299+
align?: "start" | "end" | "center";
300+
gravity?: "top" | "bottom" | "center";
301+
size?:
302+
| "xxs"
303+
| "xs"
304+
| "sm"
305+
| "md"
306+
| "lg"
307+
| "xl"
308+
| "xxl"
309+
| "3xl"
310+
| "4xl"
311+
| "5xl"
312+
| "full";
313+
aspectRatio?:
314+
| "1:1"
315+
| "1.51:1"
316+
| "1.91:1"
317+
| "4:3"
318+
| "16:9"
319+
| "20:13"
320+
| "2:1"
321+
| "3:1"
322+
| "3:4"
323+
| "9:16"
324+
| "1:2"
325+
| "1:3";
326+
aspectMode?: "cover" | "fit";
327+
backgroundColor?: string;
328+
action?: Action<{ label: string }>;
329+
};
330+
331+
export type FlexSeparator = {
332+
type: "separator";
333+
margin?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
334+
color?: string;
335+
};
336+
337+
export type FlexSpacer = {
338+
type: "spacer";
339+
size?: "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
340+
};
341+
342+
export type FlexText = {
343+
type: "text";
344+
text: string;
345+
flex?: number;
346+
margin?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
347+
size?:
348+
| "xxs"
349+
| "xs"
350+
| "sm"
351+
| "md"
352+
| "lg"
353+
| "xl"
354+
| "xxl"
355+
| "3xl"
356+
| "4xl"
357+
| "5xl";
358+
align?: "start" | "end" | "center";
359+
gravity?: "top" | "bottom" | "center";
360+
wrap?: boolean;
361+
weight?: "regular" | "bold";
362+
color?: string;
363+
action?: Action<{ label: string }>;
364+
};
365+
205366
export type TemplateContent =
206367
| TemplateButtons
207368
| TemplateConfirm

0 commit comments

Comments
 (0)