UNPKG

verstak

Version:
41 lines (40 loc) 1.34 kB
import { ReactiveTreeNode, setBasis } from "reactronic"; import { Block, OnClick } from "verstak"; import { rxModel } from "./common/Utils.js"; import { Theme } from "./Theme.js"; import { Icon } from "./Icon.v.js"; export function Button(declaration) { return (Block(setBasis(declaration, { preparation() { var _a; (_a = this.model) !== null && _a !== void 0 ? _a : (this.model = rxModel({ icon: "fa-solid fa-square", label: ReactiveTreeNode.current.key, })); }, body() { const m = this.model; const theme = Theme.current.button; this.useStylingPreset(theme.main); if (m.icon) { Icon(m.icon, { body(el, base) { base(); this.useStylingPreset(theme.icon); }, }); } if (m.label) { Block({ body(el, base) { base(); this.textIsFormatted = false; this.text = m.label; this.useStylingPreset(theme.label); }, }); } OnClick(this.native, m.action); }, }))); }