import { NAME, pattern, UI, type VNode } from "commonfabric"; import UIVariantsDemo from "../../examples/ui-variants-demo.tsx"; // deno-lint-ignore no-empty-interface interface RenderStoryInput {} export interface RenderStoryOutput { [NAME]: string; [UI]: VNode; controls: VNode; } interface SingleUIInput { label: string; } export interface SingleUIOutput { [NAME]: string; [UI]: VNode; } /** * A piece that exports ONLY [UI] — no [CHIP_UI]/[TILE_UI]. Used to demonstrate * the cf-render platform defaults (chip → cf-cell-link by [NAME]; tile → the * full [UI] scaled to ~0.5). */ const SingleUIPiece = pattern(({ label }) => ({ [NAME]: label, [UI]: (
{label}
This piece exports only [UI].
), })); const cellStyle = { border: "1px dashed #cbd5e1", borderRadius: "8px", padding: "12px", background: "#fafafa", minHeight: "80px", }; const labelStyle = { fontSize: "12px", fontWeight: "700", color: "#64748b", textTransform: "uppercase", letterSpacing: "0.06em", marginBottom: "8px", }; const sectionTitleStyle = { fontSize: "15px", fontWeight: "700", color: "#0f172a", margin: "8px 0", }; const noteStyle = { fontSize: "13px", color: "#64748b", marginBottom: "12px", }; export default pattern(() => { // A piece exporting the full variant spectrum ([UI], [CHIP_UI], [TILE_UI]). const demo = UIVariantsDemo({ title: "UI Variants Demo" }); // A piece exporting only [UI], to exercise the platform-default failover. const single = SingleUIPiece({ label: "Single-UI Piece" }); return { [NAME]: "cf-render Story", [UI]: (
Exported variants (CT-1321)
{""}{" "} renders the piece's matching variant key when the piece exports it: [UI] for full, [CHIP_UI] for chip, [TILE_UI] for tile.
variant="full" (default)
variant="chip"
variant="tile"
Platform defaults (failover)
A piece that exports only [UI] still renders at every variant via the per-variant platform default: chip falls over to a cf-cell-link (by [NAME]); tile falls over to the full [UI] scaled to ~0.5.
variant="chip" → cf-cell-link default
variant="tile" → scaled [UI] default
), controls: (
No interactive controls. This story renders {""}{" "} at each UI variant for a full-spectrum piece and a single-[UI] piece.
), }; });