/** * @file Example preview that highlights how design tokens respond to theme changes. */ import * as React from "react"; import { Button } from "../../../../components/elements/Button"; import { H2, H3, H4 } from "../../../../components/elements/Heading"; import { Label } from "../../../../components/elements/Label"; import { PropertySection } from "../../../../components/inspector/parts/PropertySection"; import { InspectorField } from "../../../../components/inspector/parts/InspectorField"; import { ReadOnlyField } from "../../../../components/inspector/parts/ReadOnlyField"; import classes from "./ThemeShowcaseExample.module.css"; type TokenGroup = { title: string; tokens: string[]; }; const TOKEN_GROUPS: TokenGroup[] = [ { title: "Surfaces", tokens: [ "--node-editor-surface-primary", "--node-editor-surface-secondary", "--node-editor-surface-tertiary", "--node-editor-window-background-color", ], }, { title: "Typography", tokens: [ "--node-editor-title-font", "--node-editor-control-text-font", "--node-editor-theme-default-font-family", "--node-editor-font-size-sm", ], }, { title: "Controls & Accents", tokens: [ "--node-editor-accent-color", "--node-editor-accent-color-hover", "--node-editor-selected-control-color", "--node-editor-keyboard-focus-indicator-color", ], }, ]; type TokenValues = Record; /** * Render a theme-aware showcase grid for verifying design token values. */ export function ThemeShowcaseExample(): React.ReactElement { const [tokenValues, setTokenValues] = React.useState({}); React.useEffect(() => { if (typeof window === "undefined") { return; } const readTokenValues = () => { const rootStyles = window.getComputedStyle(document.documentElement); const entries = TOKEN_GROUPS.flatMap((group) => group.tokens.map((token) => [token, rootStyles.getPropertyValue(token).trim()]), ); setTokenValues(Object.fromEntries(entries)); }; readTokenValues(); if (typeof MutationObserver !== "undefined") { const observer = new MutationObserver(readTokenValues); observer.observe(document.documentElement, { attributes: true, attributeFilter: ["data-node-editor-theme"], }); return () => observer.disconnect(); } return undefined; }, []); return (

Theme-driven Component Showcase

Switch themes to see how components, surfaces, and accents respond instantly.

Heading Level 2

Heading Level 3

Heading Level 4

{TOKEN_GROUPS.map((group) => (
{group.tokens.map((token) => ( {tokenValues[token] ?? "—"} ))}
))}
); }