/** * The schemas for the theme data shapes: a style variable and the theme that * carries a set of them. * * These live together, and apart from `theme.ts`, so the renderer stays free * of the schema library - `theme.ts` imports the types type-only, which keeps * mounting a theme at roughly a kilobyte. * * @module */ import * as s from '@fuzdev/fuz_schema/schema.ts'; /** Matches a public style variable name, the names a theme may set. */ export declare const STYLE_VARIABLE_NAME_MATCHER: RegExp; /** * Matches an internal variable name: a leading underscore before a public * name, the private spelling of the ramp intermediates * (`_palette_lightness_30`, `_chroma_shape_50`, `_palette_chroma_50`). * `default_variables` declares them and the renderer emits them, but they're * plumbing rather than API, so `STYLE_VARIABLE_NAME_MATCHER` rejects the * spelling and a theme can't set one. */ export declare const INTERNAL_VARIABLE_NAME_MATCHER: RegExp; export declare const StyleVariableName: s.PipeSchema; export type StyleVariableName = s.Infer; /** * A style variable: a custom property name with a value per color scheme. * * The slots follow the renderer's cascade: `base` is the base position, * rendered on `:root`, and `dark` renders on `:root.dark` (and for a root * naming no scheme, under `prefers-color-scheme: dark`). A theme variable * with only `base` therefore applies in both color schemes (its `fuz.theme` * `:root` beats the `fuz.base` dark default by layer order), while `dark` * alone applies in dark only - which is why the shipped themes author a * scheme-agnostic knob as a single `base` value. The light scheme renders * `base`; there is no light-only slot. * * Strict: a misspelled slot is an error, not a silently dropped scheme. A * slot must also be a contained CSS value (see `css_containment.ts`), since it * renders verbatim. * * The name is a public one (`StyleVariableName`): an internal ramp variable * is rejected with an error saying so. The derived data that does carry * internal names - a stance's mirror and `compile_theme`'s caps - travels * beside a theme as `ThemeDerived`, never inside it. */ export declare const StyleVariable: s.PipeSchema<{ name: string; base?: string | undefined; dark?: string | undefined; summary?: string | undefined; }, s.ObjectSchema<{ name: s.PipeSchema; base: s.OptionalSchema>; dark: s.OptionalSchema>; summary: s.OptionalSchema>; }>>; export type StyleVariable = s.Infer; /** * A theme's scheme stance: which color schemes it supports. `'dual'` themes * render light and dark appearances from each variable's slots; `'light'` and * `'dark'` themes render that single appearance in both color schemes. */ export declare const ThemeScheme: s.OneOfSchema; export type ThemeScheme = s.Infer; export declare const Theme: s.ObjectSchema<{ name: s.PipeSchema; /** * A sentence or two on what the theme looks like, for a theme picker to * show beside the name. Never rendered into CSS. */ summary: s.OptionalSchema; variables: s.ArraySchema; base: s.OptionalSchema>; dark: s.OptionalSchema>; summary: s.OptionalSchema>; }>>>; /** * The scheme stance, defaulting to `'dual'`. A single-scheme stance pins * `color-scheme` on the scope so form controls and native scrollbars agree. * A stanced theme's own variables are best authored single-slot in the * `base` position. * * Rendering a stanced theme faithfully also needs the scheme-adaptive * defaults mirrored into the stanced scheme. That mirror is derived data, * not part of the theme: `resolve_theme_stance` in `theme_stance.ts` * computes it beside the theme, and `render_theme_style` takes it as an * option. The renderer alone only pins `color-scheme` - it holds no * variable data of its own, so the mirror stays off the theme path of * consumers who don't use a stanced theme. */ scheme: s.OptionalSchema>; }>; export type Theme = s.Infer; /** * Parses an unknown value as a `Theme`, returning `null` when it doesn't * match. For untrusted input - a theme restored from storage, a theme handed * across a boundary - where a malformed value should fall back to a default * rather than throw. Use `s.parse(Theme, value)` directly when the failure * detail matters, or `validate_theme` in `theme_validate.ts` for the full lint. * * @param value - the value to parse * @returns the theme, or `null` when the value isn't one */ export declare const parse_theme: (value: unknown) => Theme | null; //# sourceMappingURL=variable.d.ts.map