import { computed, NAME, pattern, UI, type VNode, Writable, } from "commonfabric"; import { Controls, SelectControl } from "../ui/controls/index.ts"; // deno-lint-ignore no-empty-interface interface ThemeSamplerStoryInput {} export interface ThemeSamplerStoryOutput { [NAME]: string; [UI]: VNode; controls: VNode; } const themes: Record> = { default: {}, neutral: { colorScheme: "light", colors: { primary: "#4979fa", primaryForeground: "#ffffff", secondary: "#eceef1", secondaryForeground: "#34373c", background: "#ffffff", surface: "#f2f3f6", surfaceHover: "#eceef1", text: "#34373c", textMuted: "#5b5f65", border: "rgba(79, 89, 103, 0.15)", borderMuted: "rgba(79, 89, 103, 0.08)", accent: "#fc856d", accentForeground: "#ffffff", success: "#21c17b", successForeground: "#ffffff", error: "#ff6057", errorForeground: "#ffffff", warning: "#e5a126", warningForeground: "#ffffff", }, }, warm: { fontFamily: "'Georgia', 'Times New Roman', serif", borderRadius: "12px", density: "spacious", colorScheme: "light", colors: { primary: "#8B4513", primaryForeground: "#FFF8F0", secondary: "#D2B48C", secondaryForeground: "#3E2723", background: "#FFF8F0", surface: "#FFF0E0", surfaceHover: "#FFE4CC", text: "#2C1810", textMuted: "#8B7355", border: "#E8D5C0", borderMuted: "#F0E6D8", accent: "#C84C09", accentForeground: "#FFF8F0", success: "#4A7C59", successForeground: "#ffffff", error: "#A03020", errorForeground: "#ffffff", warning: "#B8860B", warningForeground: "#ffffff", }, }, dark: { borderRadius: "16px", density: "comfortable", colorScheme: "dark", colors: { primary: "#7C6CF7", primaryForeground: "#FFFFFF", secondary: "#2D3436", secondaryForeground: "#DFE6E9", background: "#0C0C1E", surface: "#16163A", surfaceHover: "#1E1E50", text: "#F0F0FF", textMuted: "#636e88", border: "#2A2A5A", borderMuted: "#1E1E4A", accent: "#00CEC9", accentForeground: "#0C0C1E", success: "#00B894", successForeground: "#FFFFFF", error: "#FF6B6B", errorForeground: "#FFFFFF", warning: "#FDCB6E", warningForeground: "#0C0C1E", }, }, highContrast: { colorScheme: "light", colors: { primary: "#0000EE", primaryForeground: "#FFFFFF", secondary: "#E0E0E0", secondaryForeground: "#000000", background: "#FFFFFF", surface: "#F0F0F0", surfaceHover: "#E0E0E0", text: "#000000", textMuted: "#333333", border: "#000000", borderMuted: "#666666", accent: "#CC0000", accentForeground: "#FFFFFF", success: "#006600", successForeground: "#FFFFFF", error: "#CC0000", errorForeground: "#FFFFFF", warning: "#CC6600", warningForeground: "#FFFFFF", }, }, }; const themeItems = [ { label: "Default (system)", value: "default" }, { label: "Neutral Slate (Figma)", value: "neutral" }, { label: "Warm (serif)", value: "warm" }, { label: "Dark (finance)", value: "dark" }, { label: "High Contrast", value: "highContrast" }, ]; function SemanticTokenGrid() { const tokenGroups = [ { label: "Text", tokens: [ { name: "text", var: "--cf-theme-color-text" }, { name: "text-muted", var: "--cf-theme-color-text-muted" }, ], }, { label: "Surfaces", tokens: [ { name: "background", var: "--cf-theme-color-background" }, { name: "surface", var: "--cf-theme-color-surface" }, { name: "surface-hover", var: "--cf-theme-color-surface-hover" }, ], }, { label: "Borders", tokens: [ { name: "border", var: "--cf-theme-color-border" }, { name: "border-muted", var: "--cf-theme-color-border-muted" }, ], }, { label: "Accents", tokens: [ { name: "primary", var: "--cf-theme-color-primary" }, { name: "secondary", var: "--cf-theme-color-secondary" }, { name: "accent", var: "--cf-theme-color-accent" }, ], }, { label: "Status", tokens: [ { name: "success", var: "--cf-theme-color-success" }, { name: "warning", var: "--cf-theme-color-warning" }, { name: "error", var: "--cf-theme-color-error" }, ], }, { label: "Derived", tokens: [ { name: "primary-light", var: "--cf-theme-color-primary-light" }, { name: "success-light", var: "--cf-theme-color-success-light" }, { name: "error-surface", var: "--cf-theme-color-error-surface" }, { name: "error-light", var: "--cf-theme-color-error-light" }, ], }, ]; return (

Semantic Tokens

{tokenGroups.map((group) => (
{group.label}
{group.tokens.map((t) => (
{t.name}
))}
))}
); } function ComponentSampler() { return (

Component Sampler

{/* Buttons */}
Buttons
Primary Secondary Destructive Ghost Outline
{/* Chips & Badges */}
Chips & Badges
Default Primary Accent Default Secondary Destructive Outline
{/* Alerts */}
Alerts
Info Informational message using theme tokens. Success Operation completed using theme tokens. Error Something went wrong using theme tokens.
{/* Card */}
Card
Card Title
Card content rendered inside a themed surface. Border, radius, and background should all resolve from the active theme.
{/* List Items */}
List Items
{/* Input */}
Input
{/* Label */}
Text
Default text color Muted text color Text component
); } export default pattern( () => { const selectedTheme = new Writable("default"); const activeTheme = computed(() => themes[selectedTheme.get()] ?? {}); return { [NAME]: "Theme Sampler", [UI]: (

Theme Sampler

Switch themes using the control below to verify semantic token propagation across components.

), controls: ( ), }; }, );