mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 09:48:39 +00:00
refactor(line): share flex footer helper
This commit is contained in:
@@ -10,6 +10,7 @@ import type {
|
|||||||
FlexText,
|
FlexText,
|
||||||
ListItem,
|
ListItem,
|
||||||
} from "./types.js";
|
} from "./types.js";
|
||||||
|
import { attachFooterText } from "./common.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an info card with title, body, and optional footer
|
* Create an info card with title, body, and optional footer
|
||||||
@@ -76,22 +77,7 @@ export function createInfoCard(title: string, body: string, footer?: string): Fl
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (footer) {
|
if (footer) {
|
||||||
bubble.footer = {
|
attachFooterText(bubble, footer);
|
||||||
type: "box",
|
|
||||||
layout: "vertical",
|
|
||||||
contents: [
|
|
||||||
{
|
|
||||||
type: "text",
|
|
||||||
text: footer,
|
|
||||||
size: "xs",
|
|
||||||
color: "#AAAAAA",
|
|
||||||
wrap: true,
|
|
||||||
align: "center",
|
|
||||||
} as FlexText,
|
|
||||||
],
|
|
||||||
paddingAll: "lg",
|
|
||||||
backgroundColor: "#FAFAFA",
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return bubble;
|
return bubble;
|
||||||
|
|||||||
20
src/line/flex-templates/common.ts
Normal file
20
src/line/flex-templates/common.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import type { FlexBox, FlexBubble, FlexText } from "./types.js";
|
||||||
|
|
||||||
|
export function attachFooterText(bubble: FlexBubble, footer: string) {
|
||||||
|
bubble.footer = {
|
||||||
|
type: "box",
|
||||||
|
layout: "vertical",
|
||||||
|
contents: [
|
||||||
|
{
|
||||||
|
type: "text",
|
||||||
|
text: footer,
|
||||||
|
size: "xs",
|
||||||
|
color: "#AAAAAA",
|
||||||
|
wrap: true,
|
||||||
|
align: "center",
|
||||||
|
} as FlexText,
|
||||||
|
],
|
||||||
|
paddingAll: "lg",
|
||||||
|
backgroundColor: "#FAFAFA",
|
||||||
|
} as FlexBox;
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import type { Action, FlexBox, FlexBubble, FlexComponent, FlexText } from "./types.js";
|
import type { Action, FlexBox, FlexBubble, FlexComponent, FlexText } from "./types.js";
|
||||||
|
import { attachFooterText } from "./common.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a receipt/summary card (for orders, transactions, data tables)
|
* Create a receipt/summary card (for orders, transactions, data tables)
|
||||||
@@ -135,22 +136,7 @@ export function createReceiptCard(params: {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (footer) {
|
if (footer) {
|
||||||
bubble.footer = {
|
attachFooterText(bubble, footer);
|
||||||
type: "box",
|
|
||||||
layout: "vertical",
|
|
||||||
contents: [
|
|
||||||
{
|
|
||||||
type: "text",
|
|
||||||
text: footer,
|
|
||||||
size: "xs",
|
|
||||||
color: "#AAAAAA",
|
|
||||||
wrap: true,
|
|
||||||
align: "center",
|
|
||||||
} as FlexText,
|
|
||||||
],
|
|
||||||
paddingAll: "lg",
|
|
||||||
backgroundColor: "#FAFAFA",
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return bubble;
|
return bubble;
|
||||||
@@ -499,22 +485,7 @@ export function createAgendaCard(params: {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (footer) {
|
if (footer) {
|
||||||
bubble.footer = {
|
attachFooterText(bubble, footer);
|
||||||
type: "box",
|
|
||||||
layout: "vertical",
|
|
||||||
contents: [
|
|
||||||
{
|
|
||||||
type: "text",
|
|
||||||
text: footer,
|
|
||||||
size: "xs",
|
|
||||||
color: "#AAAAAA",
|
|
||||||
align: "center",
|
|
||||||
wrap: true,
|
|
||||||
} as FlexText,
|
|
||||||
],
|
|
||||||
paddingAll: "lg",
|
|
||||||
backgroundColor: "#FAFAFA",
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return bubble;
|
return bubble;
|
||||||
|
|||||||
Reference in New Issue
Block a user