import { html } from "lit"; import { msg } from "@lit/localize"; import type { BuilderComponent } from "../../types/BuilderComponent"; import { FONT_OPTIONS } from "../../builder/data/data"; const DEFAULT_FONT = "system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif"; export const ParagraphComponent: BuilderComponent = { type: "p", label: () => msg("Paragraph"), group: "text", defaultData: { font: DEFAULT_FONT, }, render: (data) => { const font = data?.font ?? DEFAULT_FONT; const color = data?.color ?? "#000000"; const content = data?.content ?? msg("Paragraph"); const fontWeight = data?.["font-weight"] ?? "normal"; const width = data?.width ?? "auto"; const height = data?.height ?? "auto"; const fontSize = data?.["font-size"] ?? "1em"; return html`

${content}

`; }, bindings: () => [ { key: "content", label: msg("Paragraph text"), kind: "text", target: "p", placeholder: msg("Enter paragraph…"), }, { key: "width", label: msg("Width"), kind: "style", target: "p", name: "width", placeholder: `${msg("e.g.")} 300px`, }, { key: "height", label: msg("Height"), kind: "style", target: "p", name: "height", placeholder: `${msg("e.g.")} 100px`, }, { key: "color", label: msg("Text color"), kind: "style", target: "p", name: "color", placeholder: "#000000", }, { key: "font-weight", label: msg("Font weight"), kind: "style", target: "p", name: "font-weight", placeholder: `${msg("e.g.")} 400 ${msg("or")} bold`, }, { key: "font-size", label: msg("Font size"), kind: "style", target: "p", name: "font-size", placeholder: `${msg("e.g.")} 32px ${msg("or")} 2em`, } ], settings: ({ data, setData }) => { const current = (data?.font as string) ?? DEFAULT_FONT; const currentLabel = FONT_OPTIONS.find((f) => f.value === current)?.label ?? msg("Choose font"); return html`

${msg("Typography")}

${msg("Font")}
${currentLabel} { const item = e.detail.item as any; const next = String(item?.value ?? ""); if (next) setData({ font: next }); }} > ${FONT_OPTIONS.map( (f) => html` ${f.label} `, )}
setData({ font: DEFAULT_FONT })} > ${msg("Reset font")}
`; }, };