/** * Render helpers for 2-column form layout with info text */ import clsx from "clsx"; import { html, nothing, type TemplateResult } from "lit"; import { tw } from "@/utils/tailwind"; export type Cols = [TemplateResult<1>, TemplateResult | string | undefined][]; // TODO Revisit, maybe configure with Cols? const singleLineFromControls = ["sl-checkbox", "sl-switch"]; export function inputCol(content: TemplateResult<1>) { return html`
${content}
`; } export function infoCol(content: TemplateResult | string, topPadding: string) { return html`
${content}
`; } export function columns(cols: Cols) { return html`
${cols.map(([main, info]) => { const singleLineFormControl = new RegExp( `<(${singleLineFromControls.join("|")})`, ).test(main.strings[0].trim()); return html`
${main}
${info ? infoCol(info, singleLineFormControl ? tw`md:pt-1` : tw`md:pt-8`) : nothing} `; })}
`; }