Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/lukebennett88/luke-ui. luke-ui.pages.dev
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738import { themeContractTree, themeVarName } from './contract.js';
/** * Recursively walks the contract tree and builds a same-shape object where each leaf holds its * stable `var(--luke-*)` reference. This keeps the public `vars` shape fully source-owned and free * of styling-engine types: no `@vanilla-extract/css` import contributes to its declarations. */function buildVars( node: Record<string, unknown>, segments: Array<string> = [],): Record<string, unknown> { const result: Record<string, unknown> = {}; for (const [key, value] of Object.entries(node)) { const path = [...segments, key]; result[key] = value === null ? `var(${themeVarName(path)})` : buildVars(value as Record<string, unknown>, path); } return result;}
type ContractVars<T> = { [K in keyof T]: T[K] extends null ? string : T[K] extends Record<string, unknown> ? ContractVars<T[K]> : never;};
/** * Typed access to the semantic theme custom properties. Each path resolves to a stable global * `--luke-*` variable reference, for example `vars.color.background.danger.solid.hover` is * `var(--luke-color-background-danger-solid-hover)`. Emits no CSS; values are supplied by a * theme stylesheet built with `buildTheme`. */export const vars = buildVars(themeContractTree) as ContractVars<typeof themeContractTree>;