UNPKG

verstak

Version:
40 lines (39 loc) 1.35 kB
import { ReactiveTreeNode, Mode } from "reactronic"; import { Division, JustText, OnClick } from "verstak"; import { triggeringModel } from "./common/Utils.js"; import { Theme } from "./Theme.js"; import { Icon } from "./Icon.v.js"; export function Button(declaration) { return (Division(ReactiveTreeNode.withBasis(declaration, { mode: Mode.autonomous, preparation: el => { var _a; (_a = el.model) !== null && _a !== void 0 ? _a : (el.model = triggeringModel({ icon: "fa-solid fa-square", label: ReactiveTreeNode.current.key, })); }, script: el => { const m = el.model; const theme = Theme.current.button; el.useStylingPreset(theme.main); if (m.icon) { Icon(m.icon, { script: (el, base) => { base(); el.useStylingPreset(theme.icon); }, }); } if (m.label) { JustText(m.label, false, { script: (el, base) => { base(); el.useStylingPreset(theme.label); }, }); } OnClick(el.native, m.action); }, }))); }