refactor(line): share flex footer helper

This commit is contained in:
Peter Steinberger
2026-02-14 14:03:59 +00:00
parent a1fc6a6ea6
commit 9f84afc992
3 changed files with 25 additions and 48 deletions

View File

@@ -10,6 +10,7 @@ import type {
FlexText,
ListItem,
} from "./types.js";
import { attachFooterText } from "./common.js";
/**
* 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) {
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",
};
attachFooterText(bubble, footer);
}
return bubble;

View 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;
}

View File

@@ -1,4 +1,5 @@
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)
@@ -135,22 +136,7 @@ export function createReceiptCard(params: {
};
if (footer) {
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",
};
attachFooterText(bubble, footer);
}
return bubble;
@@ -499,22 +485,7 @@ export function createAgendaCard(params: {
};
if (footer) {
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",
};
attachFooterText(bubble, footer);
}
return bubble;