/** * The Studio's chrome, generated from one colour. * * `s.settings()`'s `theme.accent` is a single hex, and what it has to replace is * a TEN-STEP RAMP: `index.css` declares `--colors-brand-green-100` through * `-1000` and every brand token points into it, picking different steps in light * and in dark (a tinted surface is step 200 in light and 800 in dark; the text * on it is 1000 and 100). So the accent is not a colour to place, it is a ramp * to build — which is also why one accent drives both modes with nothing to keep * in sync. * * ## Why an arbitrary hex is safe * * The obvious worry is `contrast.test.ts`, which holds every foreground / * background pair the chrome renders to WCAG AA. A hex typed by an editor never * goes near that test. * * It holds anyway, because of how the ramp is built: **green's lightness at each * step is reused unchanged, and only the hue moves.** WCAG relative luminance is * almost entirely a function of lightness, so a ramp that keeps green's L * profile keeps green's contrast relationships. Chroma is scaled to the accent's * own saturation and then reduced — never L — until each step fits sRGB. * * "Almost entirely" is doing real work in that sentence: at equal OKLCH * lightness a saturated yellow has a higher relative luminance than a blue, so * the ratios do move a little. {@link BRAND_CONTRAST_PAIRS} is the list of pairs * that have to survive it, and `accentRamp.test.ts` runs them over the hue * circle rather than trusting the argument. * * ## What is NOT generated * * With no accent set, the hand-tuned ramp in `index.css` is used as it is. This * module reproduces it to within a step or two, and re-deriving a value somebody * tuned by eye is a silent regression rather than a simplification. */ /** The steps `index.css` declares, smallest (lightest) first. */ export declare const RAMP_STEPS: readonly [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]; export type RampStep = (typeof RAMP_STEPS)[number]; export type AccentRamp = Record; /** * Val's own brand ramp, and the lightness profile every generated ramp borrows. * * A copy of what `index.css` declares, because this package cannot read the UI * package's stylesheet — so the two are held together by a test instead: * `contrast.test.ts` resolves the ramp out of the real CSS and asserts it equals * this. If that test fails, the stylesheet moved and this did not. */ export declare const VAL_GREEN_RAMP: AccentRamp; /** * The ten-step ramp for one accent, or `null` if it is not a six-digit hex. * * `null` rather than a fallback: the caller knows whether it is holding a value * an editor picked (in which case the schema already validated it) or one that * came out of a hand-edited settings file, and only the caller can decide * whether "ignore it" or "report it" is right. */ export declare function accentRamp(accent: string): AccentRamp | null; /** * The custom properties that restyle the chrome, ready to put on a `style` * attribute. * * Custom properties on the element rather than a generated stylesheet: nothing * has to be escaped, an inline custom property beats `@layer base` without a * specificity fight, and a subtree that should keep the untouched palette * simply is not given the object. See `useValThemeStyle` for where they go — * every place the Studio stamps `data-mode`, because the theme travels with it. * * Empty when nothing is set, which is what makes "no theme" cost nothing. */ export declare function themeCustomProperties(theme: { accent?: string | null; /** A `--radius` length. The caller maps the named step; see `THEME_RADIUS_LENGTHS`. */ radius?: string | null; /** The proposal colour, a hex. See {@link proposalCustomProperties}. */ proposal?: string | null; }): Record; /** * The proposal colour's tokens, for light and dark at once. * * The six `--*-proposal` tokens are declared per mode in `index.css`, each as * `var(--theme-proposal--, )`, so the ones written * here are picked up where the mode block is declared -- on every element the * Studio stamps `data-mode` on, which is where these go (see * `themeCustomProperties` on why a `var()` resolves where it is declared). * Both modes' values are written because an element does not know which mode * its subtree will be in by the time it is styled. * * From the same ramp as the accent: the hue is the project's, the lightness * of each step Val's, so the steps chosen here have the contrast Val's violet * had. Text on the filled colour is white unless white would not read, then * the ramp's darkest step. Empty for a value that is not a usable hex, so * Val's violet stays. */ export declare function proposalCustomProperties(hex: string): Record; /** * WCAG relative luminance of a six-digit hex. * * Exported so there is one implementation of the maths that decides whether a * theme is legible; `contrast.test.ts` had its own copy, and two copies of a * threshold is how a guarantee quietly stops being one. */ export declare function relativeLuminance(hex: string): number; /** WCAG contrast ratio between two six-digit hex colours, 1 to 21. */ export declare function contrastRatio(a: string, b: string): number; /** WCAG AA for body text. */ export declare const AA_TEXT = 4.5; /** WCAG AA for large text and for UI components such as a focus ring. */ export declare const AA_LARGE = 3; /** * Where a brand pair's background comes from. * * A `RampStep` is a step of the brand ramp, so it moves with the accent. A hex * is a neutral surface that does not — the canvas and the floating panels are * grey in every theme, and a ring has to be legible against them. */ export type PairGround = RampStep | string; /** * Every foreground / background pair the chrome renders with BRAND colours. * * The list is data rather than a test body because two different things have to * be held to it, and one table is the only way they can agree: * * - `accentRamp.test.ts` runs it over ramps generated across the hue circle, * which is what makes an arbitrary accent safe. * - `contrast.test.ts` runs it over the ramp resolved out of the real * `index.css`, which is what stops someone nudging Val's own green past AA. * * The neutral pairs — muted text on a panel, a hairline on the canvas — stay in * `contrast.test.ts`. They have nothing to do with the accent, and a theme * cannot move them. */ export declare const BRAND_CONTRAST_PAIRS: readonly { what: string; mode: "light" | "dark"; fg: PairGround; bg: PairGround; min: number; }[]; /** Resolve one side of a {@link BRAND_CONTRAST_PAIRS} entry against a ramp. */ export declare function resolvePairGround(ground: PairGround, ramp: AccentRamp): string;