@adea-ai/ui 0.128.2 → 0.128.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/theme/appearance-panel.js +1 -1
- package/dist/components/theme/index.js +1 -1
- package/dist/components/theme/lazy.d.ts +15 -0
- package/dist/components/theme/lazy.d.ts.map +1 -0
- package/dist/components/theme/lazy.js +9 -0
- package/dist/components/theme/theme-catalogue-source.d.ts +15 -0
- package/dist/components/theme/theme-catalogue-source.d.ts.map +1 -0
- package/dist/components/theme/theme-catalogue-source.js +51 -0
- package/dist/components/theme/theme-catalogue-source.js.map +1 -0
- package/dist/components/theme/theme-document-core.d.ts +123 -0
- package/dist/components/theme/theme-document-core.d.ts.map +1 -0
- package/dist/components/theme/{theme-document.js → theme-document-core.js} +12 -12
- package/dist/components/theme/theme-document-core.js.map +1 -0
- package/dist/components/theme/theme-document.d.ts +8 -107
- package/dist/components/theme/theme-document.d.ts.map +1 -1
- package/dist/components/theme/theme-persistence.d.ts +1 -1
- package/dist/components/theme/theme-persistence.d.ts.map +1 -1
- package/dist/components/theme/theme-persistence.js +9 -6
- package/dist/components/theme/theme-persistence.js.map +1 -1
- package/dist/components/theme/theme-provider-core.d.ts +19 -0
- package/dist/components/theme/theme-provider-core.d.ts.map +1 -0
- package/dist/components/theme/theme-provider-core.js +28 -0
- package/dist/components/theme/theme-provider-core.js.map +1 -0
- package/dist/components/theme/theme-provider-lazy.d.ts +28 -0
- package/dist/components/theme/theme-provider-lazy.d.ts.map +1 -0
- package/dist/components/theme/theme-provider-lazy.js +36 -0
- package/dist/components/theme/theme-provider-lazy.js.map +1 -0
- package/dist/components/theme/theme-provider-value.d.ts +175 -0
- package/dist/components/theme/theme-provider-value.d.ts.map +1 -0
- package/dist/components/theme/theme-provider-value.js +200 -0
- package/dist/components/theme/theme-provider-value.js.map +1 -0
- package/dist/components/theme/theme-provider.d.ts +11 -136
- package/dist/components/theme/theme-provider.d.ts.map +1 -1
- package/dist/components/theme/theme-provider.js +27 -149
- package/dist/components/theme/theme-provider.js.map +1 -1
- package/dist/components/theme/theme-script.js +4 -3
- package/dist/components/theme/theme-script.js.map +1 -1
- package/dist/components/theme/theme-state-core.d.ts +248 -0
- package/dist/components/theme/theme-state-core.d.ts.map +1 -0
- package/dist/components/theme/{theme-state.js → theme-state-core.js} +8 -7
- package/dist/components/theme/theme-state-core.js.map +1 -0
- package/dist/components/theme/theme-state.d.ts +8 -214
- package/dist/components/theme/theme-state.d.ts.map +1 -1
- package/dist/components/theme/theme-toggle.js.map +1 -1
- package/dist/index.js +7 -4
- package/dist/lib/accent-presets.d.ts +26 -0
- package/dist/lib/accent-presets.d.ts.map +1 -0
- package/dist/lib/accent-presets.js +11 -0
- package/dist/lib/accent-presets.js.map +1 -0
- package/dist/lib/theme-catalogue.d.ts +3 -0
- package/dist/lib/theme-catalogue.d.ts.map +1 -0
- package/dist/lib/theme-catalogue.js +22 -0
- package/dist/lib/theme-catalogue.js.map +1 -0
- package/dist/lib/theme-css.d.ts +43 -0
- package/dist/lib/theme-css.d.ts.map +1 -0
- package/dist/lib/theme-css.js +167 -0
- package/dist/lib/theme-css.js.map +1 -0
- package/dist/lib/theme-defaults.d.ts +46 -0
- package/dist/lib/theme-defaults.d.ts.map +1 -0
- package/dist/lib/theme-defaults.generated.d.ts +13 -0
- package/dist/lib/theme-defaults.generated.d.ts.map +1 -0
- package/dist/lib/theme-defaults.generated.js +318 -0
- package/dist/lib/theme-defaults.generated.js.map +1 -0
- package/dist/lib/theme-defaults.js +47 -0
- package/dist/lib/theme-defaults.js.map +1 -0
- package/dist/lib/theme-engine-light.d.ts +3 -0
- package/dist/lib/theme-engine-light.d.ts.map +1 -0
- package/dist/lib/theme-engine-light.js +75 -0
- package/dist/lib/theme-engine-light.js.map +1 -0
- package/dist/lib/theme-engine.d.ts +69 -0
- package/dist/lib/theme-engine.d.ts.map +1 -0
- package/dist/lib/theme-engine.js +33 -0
- package/dist/lib/theme-engine.js.map +1 -0
- package/dist/lib/themes.d.ts +14 -48
- package/dist/lib/themes.d.ts.map +1 -1
- package/dist/lib/themes.js +21 -163
- package/dist/lib/themes.js.map +1 -1
- package/dist/lib/tokens.d.ts +1 -25
- package/dist/lib/tokens.d.ts.map +1 -1
- package/dist/lib/tokens.js +1 -24
- package/dist/lib/tokens.js.map +1 -1
- package/dist/r/lib.json +35 -0
- package/dist/r/registry.json +70 -0
- package/dist/r/src/components/theme/lazy.ts +35 -0
- package/dist/r/src/components/theme/theme-catalogue-source.ts +59 -0
- package/dist/r/src/components/theme/theme-document-core.ts +262 -0
- package/dist/r/src/components/theme/theme-document.ts +23 -240
- package/dist/r/src/components/theme/theme-persistence.ts +14 -6
- package/dist/r/src/components/theme/theme-provider-core.tsx +40 -0
- package/dist/r/src/components/theme/theme-provider-lazy.tsx +34 -0
- package/dist/r/src/components/theme/theme-provider-value.ts +445 -0
- package/dist/r/src/components/theme/theme-provider.tsx +23 -346
- package/dist/r/src/components/theme/theme-script.ts +3 -3
- package/dist/r/src/components/theme/theme-state-core.ts +364 -0
- package/dist/r/src/components/theme/theme-state.ts +10 -329
- package/dist/r/src/components/theme/theme-toggle.tsx +1 -1
- package/dist/r/src/lib/accent-presets.ts +43 -0
- package/dist/r/src/lib/theme-catalogue.ts +26 -0
- package/dist/r/src/lib/theme-css.ts +201 -0
- package/dist/r/src/lib/theme-defaults.generated.ts +319 -0
- package/dist/r/src/lib/theme-defaults.ts +79 -0
- package/dist/r/src/lib/theme-engine-light.ts +117 -0
- package/dist/r/src/lib/theme-engine.ts +111 -0
- package/dist/r/src/lib/themes.ts +27 -191
- package/dist/r/src/lib/tokens.ts +1 -35
- package/dist/r/theming.json +35 -0
- package/package.json +10 -2
- package/registry.json +70 -0
- package/src/components/theme/lazy.ts +35 -0
- package/src/components/theme/theme-catalogue-source.ts +59 -0
- package/src/components/theme/theme-document-core.ts +262 -0
- package/src/components/theme/theme-document.ts +23 -240
- package/src/components/theme/theme-persistence.ts +14 -6
- package/src/components/theme/theme-provider-core.tsx +40 -0
- package/src/components/theme/theme-provider-lazy.tsx +34 -0
- package/src/components/theme/theme-provider-value.ts +445 -0
- package/src/components/theme/theme-provider.tsx +23 -346
- package/src/components/theme/theme-script.ts +3 -3
- package/src/components/theme/theme-state-core.ts +364 -0
- package/src/components/theme/theme-state.ts +10 -329
- package/src/components/theme/theme-toggle.tsx +1 -1
- package/src/lib/accent-presets.ts +43 -0
- package/src/lib/theme-catalogue.ts +26 -0
- package/src/lib/theme-css.ts +201 -0
- package/src/lib/theme-defaults.generated.ts +319 -0
- package/src/lib/theme-defaults.ts +79 -0
- package/src/lib/theme-engine-light.ts +117 -0
- package/src/lib/theme-engine.ts +111 -0
- package/src/lib/themes.ts +27 -191
- package/src/lib/tokens.ts +1 -35
- package/dist/components/theme/theme-document.js.map +0 -1
- package/dist/components/theme/theme-state.js.map +0 -1
package/dist/lib/themes.d.ts
CHANGED
|
@@ -35,6 +35,8 @@
|
|
|
35
35
|
import { type AccentPreset, type AdeaTheme, type AdeaThemeRecord } from '@adea-ai/themes';
|
|
36
36
|
import { type AccentRoles } from './accent-roles';
|
|
37
37
|
export { isThemeAccentId } from './theme-accents';
|
|
38
|
+
export { terminalCssVariables, tokensAsHex } from './theme-css';
|
|
39
|
+
export { defaultDarkThemeId, defaultLightThemeId, resolveVariant } from './theme-defaults';
|
|
38
40
|
export type ThemeAppearance = 'light' | 'dark';
|
|
39
41
|
/**
|
|
40
42
|
* The surface and text roles, in shadcn's vocabulary.
|
|
@@ -174,27 +176,15 @@ export declare function variantFromRecord(theme: AdeaThemeRecord): ThemeVariant;
|
|
|
174
176
|
* catalogue has nothing to measure, and gets its appearance's ceiling.
|
|
175
177
|
*/
|
|
176
178
|
export declare function primarySubtleFor(theme: Pick<ThemeVariant, 'id' | 'appearance'>): string;
|
|
177
|
-
/** The catalogue, in catalogue order. */
|
|
178
|
-
export declare const builtinThemes: readonly ThemeVariant[];
|
|
179
|
-
export declare function themeById(id: string): ThemeVariant | undefined;
|
|
180
179
|
/**
|
|
181
|
-
* The
|
|
182
|
-
*
|
|
183
|
-
* An id the registry does not hold — an imported theme that was deleted, a
|
|
184
|
-
* catalogue entry that was renamed — must still paint *something of the appearance
|
|
185
|
-
* being shown*. Falling back to whichever variant happens to be first in the
|
|
186
|
-
* registry painted a dark palette under a light `color-scheme` for a light id, so
|
|
187
|
-
* the fallback is the appearance's own default, then any variant of that
|
|
188
|
-
* appearance, then the registry's first entry only when it holds nothing else.
|
|
189
|
-
*
|
|
190
|
-
* `registry` is the builtin catalogue plus whatever extras the host supplies; the
|
|
191
|
-
* stored id is never rewritten, only resolved, so a host that keeps an unknown id
|
|
192
|
-
* keeps resolving it if the theme comes back.
|
|
180
|
+
* The catalogue, in catalogue order.
|
|
193
181
|
*
|
|
194
|
-
* The
|
|
195
|
-
*
|
|
182
|
+
* The `@__PURE__` marks let a bundler drop the whole table, and with it the catalogue,
|
|
183
|
+
* from a consumer that imports only this module's catalogue-free helpers
|
|
184
|
+
* (`tokensAsHex`, `isThemeAccentId`, `resolveVariant`…) and never reads it.
|
|
196
185
|
*/
|
|
197
|
-
export declare
|
|
186
|
+
export declare const builtinThemes: readonly ThemeVariant[];
|
|
187
|
+
export declare function themeById(id: string): ThemeVariant | undefined;
|
|
198
188
|
/** The variants of one appearance, which is what a picker for that mode shows. */
|
|
199
189
|
export declare function themesForAppearance(appearance: ThemeAppearance): readonly ThemeVariant[];
|
|
200
190
|
/** The families in the catalogue, in catalogue order. */
|
|
@@ -358,36 +348,14 @@ export declare function editorPaletteFor(theme: ThemeVariant, mode?: EditorRoles
|
|
|
358
348
|
/**
|
|
359
349
|
* The roles a variant sets, as CSS custom properties.
|
|
360
350
|
*
|
|
361
|
-
* The
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
*
|
|
367
|
-
* Absent it, the result is what it has always been; the generated `theme-variants.css`
|
|
368
|
-
* and the design-system artifact are built without it.
|
|
351
|
+
* The mapping itself is `themeCssVariablesWith` in `theme-css.ts`; this binds it to
|
|
352
|
+
* the catalogue, which measures a theme's `--primary-subtle` strength
|
|
353
|
+
* ({@link primarySubtleFor}) and projects its floor editor ramp
|
|
354
|
+
* ({@link editorPaletteFor}). Absent `options`, the result is what it has always
|
|
355
|
+
* been; the generated `theme-variants.css` and the design-system artifact are built
|
|
356
|
+
* without it.
|
|
369
357
|
*/
|
|
370
358
|
export declare function themeCssVariables(theme: ThemeVariant, options?: ThemeCssVariableOptions): Record<string, string>;
|
|
371
|
-
/**
|
|
372
|
-
* The `--terminal-*` properties of a variant: the palette a terminal paints.
|
|
373
|
-
*
|
|
374
|
-
* What a pinned terminal theme writes over the interface variant's own. Taken from
|
|
375
|
-
* {@link themeCssVariables} rather than rebuilt, so the names, and a custom
|
|
376
|
-
* variant's verbatim `tokens`, can never drift from what the interface variant
|
|
377
|
-
* would have written for the same palette.
|
|
378
|
-
*/
|
|
379
|
-
export declare function terminalCssVariables(theme: ThemeVariant): Record<string, string>;
|
|
380
|
-
/**
|
|
381
|
-
* Token values with every `oklch()` colour written as `#rrggbb`.
|
|
382
|
-
*
|
|
383
|
-
* For a host whose stylesheet, tests or native shell speak hex: the catalogue's
|
|
384
|
-
* roles are `oklch()` strings, and this is the one conversion, gamut-mapped by the
|
|
385
|
-
* catalogue's own `oklchToHex`. A value that is already hex, carries alpha
|
|
386
|
-
* (`rgba()`), or is not a plain colour (`color-mix()`, `var()`) is left byte for
|
|
387
|
-
* byte, because converting would either lose the alpha or be a guess. Suitable as
|
|
388
|
-
* `ThemeProvider`'s `transformTokens`.
|
|
389
|
-
*/
|
|
390
|
-
export declare function tokensAsHex(tokens: Readonly<Record<string, string>>): Record<string, string>;
|
|
391
359
|
export type ThemeFinding = {
|
|
392
360
|
themeId: string;
|
|
393
361
|
role: string;
|
|
@@ -397,8 +365,6 @@ export type ThemeFinding = {
|
|
|
397
365
|
export declare function validateTheme(theme: ThemeVariant): ThemeFinding[];
|
|
398
366
|
/** Validates the whole registry, including the catalogue-level invariants. */
|
|
399
367
|
export declare function validateThemeRegistry(themes?: readonly ThemeVariant[]): ThemeFinding[];
|
|
400
|
-
export declare const defaultLightThemeId = "adea-light";
|
|
401
|
-
export declare const defaultDarkThemeId = "adea-dark";
|
|
402
368
|
/** Re-exported so a consumer measuring a colour does not need a second import. */
|
|
403
369
|
export { contrastRatio } from '@adea-ai/themes';
|
|
404
370
|
//# sourceMappingURL=themes.d.ts.map
|
package/dist/lib/themes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../../src/lib/themes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../../src/lib/themes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAiBL,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,eAAe,EAErB,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAA+C,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAK9F,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC/D,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAE1F,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,CAAA;AAE9C;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,EAAE,MAAM,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,iBAAiB,EAAE,M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ib/themes.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { accentOverrideVariables, resolveAccentRoles } from "./accent-roles.js";
|
|
2
2
|
import { isThemeAccentId } from "./theme-accents.js";
|
|
3
|
-
import {
|
|
3
|
+
import { terminalCssVariables, themeCssVariablesWith, tokensAsHex } from "./theme-css.js";
|
|
4
|
+
import { defaultDarkThemeId, defaultLightThemeId, resolveVariant } from "./theme-defaults.js";
|
|
5
|
+
import { ACCENTS, accentForeground, chartSeries, contrastRatio, editorRolesHex, getAccent, getTheme, hasTheme, primarySubtleCss, shadcnDestructiveProjection, statusForeground, syntaxRoles, themeAccentPresets, themes, themesByAppearance, tint, validateCatalogue } from "@adea-ai/themes";
|
|
4
6
|
import { shadcnVariables } from "@adea-ai/themes/adapters/shadcn";
|
|
5
|
-
import { oklchToHex, parseColor } from "@adea-ai/themes/oklch";
|
|
6
7
|
//#region src/lib/themes.ts
|
|
7
8
|
/**
|
|
8
9
|
* The theme registry, now a bridge.
|
|
@@ -203,34 +204,17 @@ function primarySubtleFor(theme) {
|
|
|
203
204
|
const record = getTheme(theme.id);
|
|
204
205
|
return record ? primarySubtleCss(record) : primarySubtleCss(theme.appearance);
|
|
205
206
|
}
|
|
206
|
-
/** The catalogue, in catalogue order. */
|
|
207
|
-
var builtinThemes = Object.freeze(themes.map(lazyVariant));
|
|
208
|
-
function themeById(id) {
|
|
209
|
-
if (!hasTheme(id)) return void 0;
|
|
210
|
-
return builtinThemes.find((theme) => theme.id === id);
|
|
211
|
-
}
|
|
212
207
|
/**
|
|
213
|
-
* The
|
|
214
|
-
*
|
|
215
|
-
* An id the registry does not hold — an imported theme that was deleted, a
|
|
216
|
-
* catalogue entry that was renamed — must still paint *something of the appearance
|
|
217
|
-
* being shown*. Falling back to whichever variant happens to be first in the
|
|
218
|
-
* registry painted a dark palette under a light `color-scheme` for a light id, so
|
|
219
|
-
* the fallback is the appearance's own default, then any variant of that
|
|
220
|
-
* appearance, then the registry's first entry only when it holds nothing else.
|
|
208
|
+
* The catalogue, in catalogue order.
|
|
221
209
|
*
|
|
222
|
-
* `
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
* The fallback order is translated from Zeron's `ThemeRegistry::resolve` (MIT,
|
|
227
|
-
* Copyright (c) 2026 Wing); see NOTICE.
|
|
210
|
+
* The `@__PURE__` marks let a bundler drop the whole table, and with it the catalogue,
|
|
211
|
+
* from a consumer that imports only this module's catalogue-free helpers
|
|
212
|
+
* (`tokensAsHex`, `isThemeAccentId`, `resolveVariant`…) and never reads it.
|
|
228
213
|
*/
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
if (
|
|
232
|
-
|
|
233
|
-
return registry.find((variant) => variant.id === defaultId) ?? registry.find((variant) => variant.appearance === appearance) ?? registry[0];
|
|
214
|
+
var builtinThemes = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ themes.map(lazyVariant));
|
|
215
|
+
function themeById(id) {
|
|
216
|
+
if (!hasTheme(id)) return void 0;
|
|
217
|
+
return builtinThemes.find((theme) => theme.id === id);
|
|
234
218
|
}
|
|
235
219
|
/** The variants of one appearance, which is what a picker for that mode shows. */
|
|
236
220
|
function themesForAppearance(appearance) {
|
|
@@ -454,142 +438,18 @@ function editorPaletteFor(theme, mode = "syntax") {
|
|
|
454
438
|
/**
|
|
455
439
|
* The roles a variant sets, as CSS custom properties.
|
|
456
440
|
*
|
|
457
|
-
* The
|
|
458
|
-
*
|
|
459
|
-
*
|
|
460
|
-
*
|
|
461
|
-
*
|
|
462
|
-
*
|
|
463
|
-
* Absent it, the result is what it has always been; the generated `theme-variants.css`
|
|
464
|
-
* and the design-system artifact are built without it.
|
|
441
|
+
* The mapping itself is `themeCssVariablesWith` in `theme-css.ts`; this binds it to
|
|
442
|
+
* the catalogue, which measures a theme's `--primary-subtle` strength
|
|
443
|
+
* ({@link primarySubtleFor}) and projects its floor editor ramp
|
|
444
|
+
* ({@link editorPaletteFor}). Absent `options`, the result is what it has always
|
|
445
|
+
* been; the generated `theme-variants.css` and the design-system artifact are built
|
|
446
|
+
* without it.
|
|
465
447
|
*/
|
|
466
448
|
function themeCssVariables(theme, options = {}) {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
"--background": c.background,
|
|
472
|
-
"--foreground": c.foreground,
|
|
473
|
-
"--card": c.card,
|
|
474
|
-
"--card-foreground": c.cardForeground,
|
|
475
|
-
"--popover": c.popover,
|
|
476
|
-
"--popover-foreground": c.popoverForeground,
|
|
477
|
-
"--primary": c.primary,
|
|
478
|
-
"--primary-foreground": c.primaryForeground,
|
|
479
|
-
"--primary-hover": primaryHover(c.primary, theme.appearance),
|
|
480
|
-
"--primary-subtle": primarySubtleFor(theme),
|
|
481
|
-
"--secondary": c.secondary,
|
|
482
|
-
"--secondary-foreground": c.secondaryForeground,
|
|
483
|
-
"--muted": c.muted,
|
|
484
|
-
"--muted-foreground": c.mutedForeground,
|
|
485
|
-
"--accent": c.accent,
|
|
486
|
-
"--accent-foreground": c.accentForeground,
|
|
487
|
-
"--destructive": c.destructive,
|
|
488
|
-
"--destructive-foreground": c.destructiveForeground,
|
|
489
|
-
"--destructive-subtle": c.destructiveSubtle,
|
|
490
|
-
"--destructive-action": c.destructiveAction,
|
|
491
|
-
"--destructive-action-foreground": c.destructiveActionForeground,
|
|
492
|
-
"--success": c.success,
|
|
493
|
-
"--success-foreground": c.successForeground,
|
|
494
|
-
"--success-subtle": c.successSubtle,
|
|
495
|
-
"--warning": c.warning,
|
|
496
|
-
"--warning-foreground": c.warningForeground,
|
|
497
|
-
"--warning-subtle": c.warningSubtle,
|
|
498
|
-
"--info": c.info,
|
|
499
|
-
"--info-foreground": c.infoForeground,
|
|
500
|
-
"--info-subtle": c.infoSubtle,
|
|
501
|
-
"--border": c.border,
|
|
502
|
-
"--input": c.input,
|
|
503
|
-
"--ring": c.ring,
|
|
504
|
-
"--sidebar": c.sidebar,
|
|
505
|
-
"--sidebar-foreground": c.sidebarForeground,
|
|
506
|
-
"--sidebar-accent": c.sidebarAccent,
|
|
507
|
-
"--sidebar-border": c.sidebarBorder,
|
|
508
|
-
"--sidebar-primary": c.primary,
|
|
509
|
-
"--sidebar-primary-foreground": c.primaryForeground,
|
|
510
|
-
"--sidebar-ring": c.ring,
|
|
511
|
-
"--sidebar-muted-foreground": c.sidebarMutedForeground,
|
|
512
|
-
"--surface-sunken": c.muted,
|
|
513
|
-
"--surface-hover": c.accent,
|
|
514
|
-
"--surface-active": c.border,
|
|
515
|
-
"--chrome": c.background,
|
|
516
|
-
"--terminal-background": t.background,
|
|
517
|
-
"--terminal-foreground": t.foreground,
|
|
518
|
-
"--terminal-cursor": t.cursor,
|
|
519
|
-
"--terminal-selection": t.selection,
|
|
520
|
-
"--terminal-ansi-black": t.black,
|
|
521
|
-
"--terminal-ansi-red": t.red,
|
|
522
|
-
"--terminal-ansi-green": t.green,
|
|
523
|
-
"--terminal-ansi-yellow": t.yellow,
|
|
524
|
-
"--terminal-ansi-blue": t.blue,
|
|
525
|
-
"--terminal-ansi-magenta": t.magenta,
|
|
526
|
-
"--terminal-ansi-cyan": t.cyan,
|
|
527
|
-
"--terminal-ansi-white": t.white,
|
|
528
|
-
"--terminal-ansi-bright-black": t.brightBlack,
|
|
529
|
-
"--terminal-ansi-bright-red": t.brightRed,
|
|
530
|
-
"--terminal-ansi-bright-green": t.brightGreen,
|
|
531
|
-
"--terminal-ansi-bright-yellow": t.brightYellow,
|
|
532
|
-
"--terminal-ansi-bright-blue": t.brightBlue,
|
|
533
|
-
"--terminal-ansi-bright-magenta": t.brightMagenta,
|
|
534
|
-
"--terminal-ansi-bright-cyan": t.brightCyan,
|
|
535
|
-
"--terminal-ansi-bright-white": t.brightWhite,
|
|
536
|
-
"--editor-keyword": e.keyword,
|
|
537
|
-
"--editor-string": e.string,
|
|
538
|
-
"--editor-number": e.number,
|
|
539
|
-
"--editor-comment": e.comment,
|
|
540
|
-
"--editor-function": e.function,
|
|
541
|
-
"--editor-variable": e.variable,
|
|
542
|
-
"--editor-type": e.type,
|
|
543
|
-
"--editor-tag": e.tag,
|
|
544
|
-
"--editor-attribute": e.attribute,
|
|
545
|
-
"--editor-operator": e.operator,
|
|
546
|
-
"--editor-heading": e.heading,
|
|
547
|
-
"--editor-link": e.link,
|
|
548
|
-
"--editor-diff-add": e.diffAdd,
|
|
549
|
-
"--editor-diff-delete": e.diffDelete,
|
|
550
|
-
"--editor-diff-hunk": e.diffHunk,
|
|
551
|
-
"--editor-search-match": e.searchMatch,
|
|
552
|
-
"--chart-1": theme.chart[0] ?? c.primary,
|
|
553
|
-
"--chart-2": theme.chart[1] ?? c.info,
|
|
554
|
-
"--chart-3": theme.chart[2] ?? c.success,
|
|
555
|
-
"--chart-4": theme.chart[3] ?? c.warning,
|
|
556
|
-
"--chart-5": theme.chart[4] ?? c.destructive,
|
|
557
|
-
"--chart-6": theme.chart[5] ?? c.mutedForeground
|
|
558
|
-
};
|
|
559
|
-
return theme.tokens ? {
|
|
560
|
-
...derived,
|
|
561
|
-
...theme.tokens
|
|
562
|
-
} : derived;
|
|
563
|
-
}
|
|
564
|
-
/**
|
|
565
|
-
* The `--terminal-*` properties of a variant: the palette a terminal paints.
|
|
566
|
-
*
|
|
567
|
-
* What a pinned terminal theme writes over the interface variant's own. Taken from
|
|
568
|
-
* {@link themeCssVariables} rather than rebuilt, so the names, and a custom
|
|
569
|
-
* variant's verbatim `tokens`, can never drift from what the interface variant
|
|
570
|
-
* would have written for the same palette.
|
|
571
|
-
*/
|
|
572
|
-
function terminalCssVariables(theme) {
|
|
573
|
-
return Object.fromEntries(Object.entries(themeCssVariables(theme)).filter(([name]) => name.startsWith("--terminal-")));
|
|
574
|
-
}
|
|
575
|
-
/**
|
|
576
|
-
* Token values with every `oklch()` colour written as `#rrggbb`.
|
|
577
|
-
*
|
|
578
|
-
* For a host whose stylesheet, tests or native shell speak hex: the catalogue's
|
|
579
|
-
* roles are `oklch()` strings, and this is the one conversion, gamut-mapped by the
|
|
580
|
-
* catalogue's own `oklchToHex`. A value that is already hex, carries alpha
|
|
581
|
-
* (`rgba()`), or is not a plain colour (`color-mix()`, `var()`) is left byte for
|
|
582
|
-
* byte, because converting would either lose the alpha or be a guess. Suitable as
|
|
583
|
-
* `ThemeProvider`'s `transformTokens`.
|
|
584
|
-
*/
|
|
585
|
-
function tokensAsHex(tokens) {
|
|
586
|
-
const converted = {};
|
|
587
|
-
for (const [name, value] of Object.entries(tokens)) {
|
|
588
|
-
const trimmed = value.trim();
|
|
589
|
-
const parsed = trimmed.startsWith("oklch(") && !trimmed.includes("/") ? parseColor(trimmed) : void 0;
|
|
590
|
-
converted[name] = parsed ? oklchToHex(parsed) : value;
|
|
591
|
-
}
|
|
592
|
-
return converted;
|
|
449
|
+
return themeCssVariablesWith({
|
|
450
|
+
primarySubtle: primarySubtleFor,
|
|
451
|
+
editor: (variant, mode) => editorPaletteFor(variant, mode)
|
|
452
|
+
}, theme, options);
|
|
593
453
|
}
|
|
594
454
|
function toFinding(finding) {
|
|
595
455
|
return {
|
|
@@ -617,8 +477,6 @@ function validateThemeRegistry(themes$1 = builtinThemes) {
|
|
|
617
477
|
message: `${theme.id} is in the registry but not in the catalogue`
|
|
618
478
|
})), ...validateCatalogue(records).map(toFinding)];
|
|
619
479
|
}
|
|
620
|
-
var defaultLightThemeId = "adea-light";
|
|
621
|
-
var defaultDarkThemeId = "adea-dark";
|
|
622
480
|
//#endregion
|
|
623
481
|
export { accentRolesForSelection, accentVariables, accents, appearancePreviewThemes, builtinThemes, contrastRatio, defaultDarkThemeId, defaultLightThemeId, editorPaletteFor, floorEditorPalette, isCatalogueVariant, isThemeAccentId, primarySubtleFor, resolveAccentPreset, resolveVariant, terminalCssVariables, themeAccentsFor, themeById, themeCssVariables, themeFamilies, themeRecordById, themeRecords, themesForAppearance, tokensAsHex, validateTheme, validateThemeRegistry, variantFromRecord, withAccent };
|
|
624
482
|
|
package/dist/lib/themes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"themes.js","names":["catalogue","themes"],"sources":["../../src/lib/themes.ts"],"sourcesContent":["/**\n * The theme registry, now a bridge.\n *\n * The catalogue itself lives in `@adea-ai/themes`. This module is what is left in\n * the design system: the translation between the catalogue's **canonical** role\n * names and the **shadcn** vocabulary every component here is written against, plus\n * the handful of custom properties this system declares that are presentations of\n * data the catalogue already holds — the `--terminal-*` ramp, the `--editor-*` ramp,\n * and `--chrome`.\n *\n * ## Why it is a bridge and not a copy\n *\n * This file used to hold thirteen themes as hand-written hex literal tables, with its\n * own contrast validator, its own terminal and editor palettes, and its own\n * provenance records. That is a lot of surface to maintain for one consumer of a\n * palette, and it meant every product that wanted the same themes — Adea, Cortana —\n * either imported this package or wrote its own. The catalogue moved out so that\n * there is one answer to \"what is Catppuccin Mocha\", and this file is the part that\n * genuinely belongs to the design system.\n *\n * It is deliberately thin. If you are looking for a colour, it is not here: see\n * `@adea-ai/themes`, whose README explains how the values are produced and whose\n * `NOTICE` records where every palette came from.\n *\n * ## The mapping, and the entry that is not a rename\n *\n * The package-owned `shadcnVariables` adapter maps canonical roles onto this\n * system's vocabulary. One entry will trip a reader: the catalogue's `accent`\n * becomes this system's `primary`, because in the shadcn vocabulary `--primary` is\n * the action colour — the fill of a primary button, the thing a focus ring is drawn\n * in — while `--accent` is a low-contrast hover wash. The catalogue's `accent` is\n * the former, so it goes to `--primary`, and `--accent` is filled from\n * `surfaceHover`, which is what shadcn components actually use it for.\n */\n\nimport {\n ACCENTS,\n accentForeground,\n chartSeries,\n editorRolesHex,\n getAccent,\n getTheme,\n hasTheme,\n shadcnDestructiveProjection,\n statusForeground,\n tint,\n primaryHover,\n primarySubtleCss,\n syntaxRoles,\n themes as catalogue,\n themesByAppearance,\n themeAccentPresets,\n validateCatalogue,\n type AccentPreset,\n type AdeaTheme,\n type AdeaThemeRecord,\n type ContrastFinding,\n} from '@adea-ai/themes'\nimport { shadcnVariables } from '@adea-ai/themes/adapters/shadcn'\nimport { oklchToHex, parseColor } from '@adea-ai/themes/oklch'\nimport { accentOverrideVariables, resolveAccentRoles, type AccentRoles } from './accent-roles'\nimport { isThemeAccentId } from './theme-accents'\n\nexport { isThemeAccentId } from './theme-accents'\n\nexport type ThemeAppearance = 'light' | 'dark'\n\n/**\n * The surface and text roles, in shadcn's vocabulary.\n *\n * Named to match the components below, which is why they differ from the\n * catalogue's: these are this system's variable names, and renaming them would mean\n * touching every component in the library for no gain.\n */\nexport type ThemeColors = {\n background: string\n foreground: string\n card: string\n cardForeground: string\n popover: string\n popoverForeground: string\n primary: string\n primaryForeground: string\n secondary: string\n secondaryForeground: string\n muted: string\n mutedForeground: string\n accent: string\n accentForeground: string\n destructive: string\n destructiveForeground: string\n destructiveSubtle: string\n /** Contrast-safe solid-action presentation, derived from the canonical error role. */\n destructiveAction: string\n destructiveActionForeground: string\n success: string\n successForeground: string\n successSubtle: string\n warning: string\n warningForeground: string\n warningSubtle: string\n info: string\n infoForeground: string\n infoSubtle: string\n border: string\n input: string\n ring: string\n sidebar: string\n sidebarForeground: string\n sidebarAccent: string\n sidebarBorder: string\n sidebarMutedForeground: string\n}\n\n/** The sixteen ANSI colours a terminal needs, plus its cursor and selection. */\nexport type ThemeTerminalPalette = {\n background: string\n foreground: string\n cursor: string\n selection: string\n black: string\n red: string\n green: string\n yellow: string\n blue: string\n magenta: string\n cyan: string\n white: string\n brightBlack: string\n brightRed: string\n brightGreen: string\n brightYellow: string\n brightBlue: string\n brightMagenta: string\n brightCyan: string\n brightWhite: string\n}\n\n/** The syntax roles a code view needs. */\nexport type ThemeEditorPalette = {\n keyword: string\n string: string\n number: string\n comment: string\n function: string\n variable: string\n type: string\n tag: string\n attribute: string\n operator: string\n heading: string\n link: string\n diffAdd: string\n diffDelete: string\n diffHunk: string\n searchMatch: string\n}\n\n/** Where a palette came from, and the terms it is used under. */\nexport type ThemeProvenance = {\n /** The project or person the palette belongs to. */\n source: string\n url: string\n /** An SPDX identifier. Every palette in this catalogue is permissive. */\n license: string\n}\n\nexport type ThemeVariant = {\n /** The `data-theme` value and the id a preference stores. */\n id: string\n /** Groups the variants that came from one project. */\n family: string\n familyLabel: string\n label: string\n appearance: ThemeAppearance\n /** One line, shown in a picker. */\n description: string\n colors: ThemeColors\n terminal: ThemeTerminalPalette\n editor: ThemeEditorPalette\n /** The categorical series, in order. */\n chart: readonly string[]\n provenance: ThemeProvenance\n /**\n * Custom properties written verbatim over {@link themeCssVariables}, last.\n *\n * For a variant a host built from data it does not control the derivation of —\n * an imported theme whose painted colours must stay exactly what the user\n * imported. The catalogue's own variants never carry it, so the derived roles\n * stay the only source of truth for them.\n */\n tokens?: Readonly<Record<string, string>>\n}\n\n/**\n * The shadcn-vocabulary roles of one catalogue entry.\n *\n * The expensive half of a variant: `shadcnVariables` projects the whole palette\n * (about 4 ms a theme), which is why {@link lazyVariant} defers it.\n */\nfunction colorsOf(theme: AdeaThemeRecord): ThemeColors {\n const projected = shadcnVariables(theme)\n const token = (name: string): string => {\n const value = projected[`--${name}`]\n if (!value) throw new Error(`${theme.id} has no shared shadcn projection for --${name}`)\n return value\n }\n const destructiveAction = shadcnDestructiveProjection(theme)\n return {\n background: token('background'),\n foreground: token('foreground'),\n card: token('card'),\n cardForeground: token('card-foreground'),\n popover: token('popover'),\n popoverForeground: token('popover-foreground'),\n primary: token('primary'),\n primaryForeground: token('primary-foreground'),\n secondary: token('secondary'),\n secondaryForeground: token('secondary-foreground'),\n muted: token('muted'),\n mutedForeground: token('muted-foreground'),\n accent: token('accent'),\n accentForeground: token('accent-foreground'),\n // Preserve the UI's semantic error token. The Themes projection uses its\n // contrast-safe solid-action fill for --destructive; UI keeps that fill in\n // the separate destructiveAction pair below.\n destructive: theme.colors.error,\n destructiveForeground: statusForeground(theme, 'error'),\n destructiveSubtle: tint(theme.colors.error, theme.colors.background),\n destructiveAction: destructiveAction.fill,\n destructiveActionForeground: destructiveAction.foreground,\n success: token('success'),\n successForeground: statusForeground(theme, 'success'),\n successSubtle: tint(theme.colors.success, theme.colors.background),\n warning: token('warning'),\n warningForeground: statusForeground(theme, 'warning'),\n warningSubtle: tint(theme.colors.warning, theme.colors.background),\n info: token('info'),\n infoForeground: statusForeground(theme, 'info'),\n infoSubtle: tint(theme.colors.info, theme.colors.background),\n border: token('border'),\n input: token('input'),\n ring: token('ring'),\n sidebar: token('sidebar'),\n sidebarForeground: token('sidebar-foreground'),\n sidebarAccent: token('sidebar-accent'),\n sidebarBorder: token('sidebar-border'),\n sidebarMutedForeground: token('sidebar-muted-foreground'),\n }\n}\n\n// The embedded terminal uses the theme's own canvas rather than a palette of its\n// own. The ANSI colours came from the palette that produced the canvas, so they\n// were chosen against it; a terminal on a different background would be the one\n// surface in the application not lit by the active theme.\nfunction terminalOf(theme: AdeaThemeRecord): ThemeTerminalPalette {\n return {\n background: theme.colors.background,\n foreground: theme.colors.foreground,\n cursor: theme.cursor,\n selection: theme.selection,\n ...theme.ansi,\n }\n}\n\nfunction editorOf(theme: AdeaThemeRecord): ThemeEditorPalette {\n const syntax = syntaxRoles(theme)\n return {\n keyword: syntax.keyword,\n string: syntax.string,\n number: syntax.number,\n comment: syntax.comment,\n function: syntax.function,\n variable: syntax.variable,\n type: syntax.type,\n tag: syntax.tag,\n attribute: syntax.attribute,\n operator: syntax.operator,\n heading: syntax.heading,\n link: syntax.link,\n diffAdd: syntax.diffAdd,\n diffDelete: syntax.diffDelete,\n diffHunk: syntax.diffHunk,\n searchMatch: syntax.searchMatch,\n }\n}\n\nfunction provenanceOf(theme: AdeaThemeRecord): ThemeProvenance {\n return {\n source: theme.provenance.project,\n url: theme.provenance.url,\n license: theme.provenance.license,\n }\n}\n\n/**\n * The design system's view of one catalogue record, built in full and at once.\n *\n * For a host that holds a record the catalogue does not — an imported theme, a\n * reconstruction from stored data — and wants a variant it can hand to\n * `ThemeProvider`'s `themes`. It throws for a record the shadcn projection cannot\n * map, here and now, rather than on first paint. The catalogue itself goes through\n * {@link lazyVariant} instead.\n */\nexport function variantFromRecord(theme: AdeaThemeRecord): ThemeVariant {\n return {\n id: theme.id,\n family: theme.family,\n familyLabel: theme.familyLabel,\n label: theme.label,\n appearance: theme.appearance,\n description: theme.description,\n colors: colorsOf(theme),\n terminal: terminalOf(theme),\n editor: editorOf(theme),\n chart: chartSeries(theme),\n provenance: provenanceOf(theme),\n }\n}\n\n/** Runs `build` on first call and returns that value from then on. A throw is not cached. */\nfunction once<T>(build: () => T): () => T {\n let built = false\n let value: T\n return () => {\n if (!built) {\n value = build()\n built = true\n }\n return value\n }\n}\n\nconst lazy = <T>(build: () => T): PropertyDescriptor => ({\n get: once(build),\n enumerable: true,\n})\n\n/**\n * {@link variantFromRecord} with the four derived palettes built on first read.\n *\n * Evaluating this module used to project all 34 catalogue themes up front, about\n * 155 ms before a single one was needed, on the hydration path of every consumer.\n * A page paints one variant, and a picker's labels and appearance are plain\n * fields, so only a variant whose `colors`, `terminal`, `editor` or `chart` is read\n * pays for them, once. The properties stay enumerable data-shaped accessors, so\n * spreading, `Object.entries` and JSON see the same object they always did.\n */\nfunction lazyVariant(theme: AdeaThemeRecord): ThemeVariant {\n return Object.defineProperties(\n {\n id: theme.id,\n family: theme.family,\n familyLabel: theme.familyLabel,\n label: theme.label,\n appearance: theme.appearance,\n description: theme.description,\n provenance: provenanceOf(theme),\n },\n {\n colors: lazy(() => colorsOf(theme)),\n terminal: lazy(() => terminalOf(theme)),\n editor: lazy(() => editorOf(theme)),\n chart: lazy(() => chartSeries(theme)),\n }\n ) as ThemeVariant\n}\n\n/**\n * A variant's `--primary-subtle`: the tint over `var(--primary)` at the strength its\n * catalogue record measures (`primarySubtleAlpha`). A variant that is not in the\n * catalogue has nothing to measure, and gets its appearance's ceiling.\n */\nexport function primarySubtleFor(theme: Pick<ThemeVariant, 'id' | 'appearance'>): string {\n const record = getTheme(theme.id)\n return record ? primarySubtleCss(record) : primarySubtleCss(theme.appearance)\n}\n\n/** The catalogue, in catalogue order. */\nexport const builtinThemes: readonly ThemeVariant[] = Object.freeze(catalogue.map(lazyVariant))\n\nexport function themeById(id: string): ThemeVariant | undefined {\n if (!hasTheme(id)) return undefined\n return builtinThemes.find((theme) => theme.id === id)\n}\n\n/**\n * The variant a stored id means, or the default of the same appearance.\n *\n * An id the registry does not hold — an imported theme that was deleted, a\n * catalogue entry that was renamed — must still paint *something of the appearance\n * being shown*. Falling back to whichever variant happens to be first in the\n * registry painted a dark palette under a light `color-scheme` for a light id, so\n * the fallback is the appearance's own default, then any variant of that\n * appearance, then the registry's first entry only when it holds nothing else.\n *\n * `registry` is the builtin catalogue plus whatever extras the host supplies; the\n * stored id is never rewritten, only resolved, so a host that keeps an unknown id\n * keeps resolving it if the theme comes back.\n *\n * The fallback order is translated from Zeron's `ThemeRegistry::resolve` (MIT,\n * Copyright (c) 2026 Wing); see NOTICE.\n */\nexport function resolveVariant(\n registry: readonly ThemeVariant[],\n id: string,\n appearance: ThemeAppearance\n): ThemeVariant {\n const found = registry.find((variant) => variant.id === id)\n if (found) return found\n const defaultId = appearance === 'dark' ? defaultDarkThemeId : defaultLightThemeId\n return (\n registry.find((variant) => variant.id === defaultId) ??\n registry.find((variant) => variant.appearance === appearance) ??\n registry[0]!\n )\n}\n\n/** The variants of one appearance, which is what a picker for that mode shows. */\nexport function themesForAppearance(appearance: ThemeAppearance): readonly ThemeVariant[] {\n const ids = new Set(themesByAppearance(appearance).map((theme) => theme.id))\n return builtinThemes.filter((theme) => ids.has(theme.id))\n}\n\n/** The families in the catalogue, in catalogue order. */\nexport function themeFamilies(): { family: string; label: string; themes: ThemeVariant[] }[] {\n const families = new Map<string, { family: string; label: string; themes: ThemeVariant[] }>()\n for (const theme of builtinThemes) {\n const entry = families.get(theme.family) ?? {\n family: theme.family,\n label: theme.familyLabel,\n themes: [],\n }\n entry.themes.push(theme)\n families.set(theme.family, entry)\n }\n return [...families.values()]\n}\n\n/** The accent presets, in the order a picker should show them. */\nexport const accents = ACCENTS\n\n/**\n * The canonical catalogue records, in catalogue order.\n *\n * {@link builtinThemes} is this system's projection of the catalogue onto the\n * shadcn vocabulary, which is what a document is painted with. A *preview* of a\n * theme — the miniatures `AppearanceEditor` and `ThemeMiniature` draw — reads the\n * catalogue's own roles instead (`surfaceActive`, `borderMuted`, `textSubtle`…),\n * several of which the projection folds together. These are those records, so a\n * consumer hands the editor exactly what it takes rather than reconstructing it\n * from the projection.\n */\nexport const themeRecords: readonly AdeaThemeRecord[] = catalogue\n\nexport function themeRecordById(id: string): AdeaThemeRecord | undefined {\n return getTheme(id)\n}\n\n/** A light/dark theme pair by id, with the defaults standing in for an unknown id. */\nfunction recordPair(lightThemeId: string, darkThemeId: string) {\n const light = getTheme(lightThemeId) ?? getTheme(defaultLightThemeId)!\n const dark = getTheme(darkThemeId) ?? getTheme(defaultDarkThemeId)!\n return { light, dark }\n}\n\n/**\n * The accents the selected light/dark pair carries — offered beside the presets.\n *\n * Computed per pair rather than per theme because a theme accent is a *pair* of\n * values, like a preset: a slot is offered only when both themes can offer it.\n */\nexport function themeAccentsFor(\n lightThemeId: string,\n darkThemeId: string\n): readonly AccentPreset[] {\n const { light, dark } = recordPair(lightThemeId, darkThemeId)\n return themeAccentPresets(light, dark)\n}\n\n/**\n * An accent id resolved against a theme pair: a preset, a theme accent the pair\n * offers, or `undefined` for `theme`, an unknown id, or a slot this pair cannot\n * offer — each of which means \"use the theme's own primary\".\n *\n * Theme accent ids are role-shaped (`ansi-blue`), so a stored one survives a theme\n * switch and resolves to the new theme's blue; when the new pair cannot offer the\n * slot it resolves to nothing, the same fallback a stale preset id gets.\n */\nexport function resolveAccentPreset(\n accentId: string,\n light: AdeaTheme,\n dark: AdeaTheme\n): AccentPreset | undefined {\n if (accentId === 'theme') return undefined\n const preset = getAccent(accentId)\n if (preset) return preset\n if (!isThemeAccentId(accentId)) return undefined\n return themeAccentPresets(light, dark).find((option) => option.id === accentId)\n}\n\n/**\n * A theme with an accent laid over it, in the catalogue's own shape.\n *\n * The accent replaces `accent` and its measured label, which is all an accent\n * changes about a theme; `undefined` returns the theme untouched. This is the\n * overlay a host needs for `AppearanceEditor`'s `lightTheme`/`darkTheme`.\n */\nexport function withAccent<T extends AdeaTheme>(theme: T, accent: AccentPreset | undefined): T {\n if (!accent) return theme\n const value = theme.appearance === 'dark' ? accent.dark : accent.light\n return {\n ...theme,\n colors: { ...theme.colors, accent: value, accentForeground: accentForeground(value) },\n }\n}\n\n/**\n * The two preview themes an appearance selection resolves to, accent applied.\n *\n * The adapter between a stored selection and `AppearanceEditor`: it takes ids —\n * what a preference holds — and returns the canonical records the editor's\n * `lightTheme` and `darkTheme` props take, so a host does not map roles by hand.\n * Unknown ids fall back to the defaults and an accent the pair cannot offer falls\n * back to the theme's own, exactly as `ThemeProvider` resolves them.\n */\nexport function appearancePreviewThemes(selection: {\n lightThemeId: string\n darkThemeId: string\n accent: string\n}): { lightTheme: AdeaThemeRecord; darkTheme: AdeaThemeRecord } {\n const { light, dark } = recordPair(selection.lightThemeId, selection.darkThemeId)\n const accent = resolveAccentPreset(selection.accent, light, dark)\n return { lightTheme: withAccent(light, accent), darkTheme: withAccent(dark, accent) }\n}\n\n/**\n * The properties an accent selection overrides, as CSS custom properties.\n *\n * ## Why this exists rather than relying on the `[data-accent]` blocks\n *\n * `theme.css` carries a `[data-accent='…']` block per preset, and those blocks are\n * correct — but they are unreachable at runtime. `ThemeProvider` writes a theme's\n * whole role set onto `<html>` as *inline* custom properties, and an inline\n * declaration outranks any stylesheet selector regardless of specificity. The\n * attribute was set, the rules existed, the values were right, and every one of the\n * seven accents rendered as the same blue.\n *\n * The blocks are kept, because they are what styles the window between the document\n * arriving and the provider mounting — which is the whole reason `themeScript`\n * exists. But the authoritative value has to be applied by the same code that\n * applies the theme, from the same source, or the two can drift again. So both the\n * provider and the CSS generator call `accentRoles` out of `@adea-ai/themes`, and\n * `tests/appearance-axes.test.ts` asserts the two agree value for value.\n *\n * A theme accent (`ansi-blue`) has no block: its value depends on the theme pair,\n * so it is resolved against `pair` — the selection's light and dark theme ids —\n * and only ever applied here. Without a pair it resolves against the defaults.\n *\n * Returns `undefined` for `theme` — the variant's own primary — for an id the\n * catalogue does not have, and for a theme accent the pair does not offer, so a\n * stale stored preference falls back to the theme rather than blanking the primary.\n */\nexport function accentVariables(\n accentId: string,\n appearance: ThemeAppearance,\n pair: { lightThemeId: string; darkThemeId: string } = {\n lightThemeId: defaultLightThemeId,\n darkThemeId: defaultDarkThemeId,\n },\n options: AccentVariableOptions = {}\n): Record<string, string> | undefined {\n const roles = accentRolesForSelection(accentId, appearance, pair, options)\n return roles ? accentOverrideVariables(roles) : undefined\n}\n\n/** What an accent is held to when it is resolved against a surface. */\nexport type AccentVariableOptions = {\n /** The surface the accent must read on: the variant's `colors.background`. */\n background?: string\n /**\n * The contrast floor against `background`. Absent, a preset is painted verbatim\n * and only a custom `#rrggbb` is held to the default floor.\n */\n floor?: number\n /** The variant the accent is applied to, so the tint takes its measured strength. */\n variantId?: string\n}\n\n/**\n * An accent selection resolved to the full {@link AccentRoles}, against a theme\n * pair. {@link accentVariables} is the document half of this; an element-scoped\n * paint (`paintAccentRoles`) wants all of it, including the tint.\n */\nexport function accentRolesForSelection(\n accentId: string,\n appearance: ThemeAppearance,\n pair: { lightThemeId: string; darkThemeId: string } = {\n lightThemeId: defaultLightThemeId,\n darkThemeId: defaultDarkThemeId,\n },\n options: AccentVariableOptions = {}\n): AccentRoles | undefined {\n if (accentId === 'theme') return undefined\n const record = options.variantId ? getTheme(options.variantId) : undefined\n return resolveAccentRoles(accentId, {\n target: record ?? appearance,\n background: options.background,\n floor: options.floor,\n // Only an `ansi-*` id needs the pair's offering, and measuring it is not free.\n themeAccents: isThemeAccentId(accentId)\n ? themeAccentsFor(pair.lightThemeId, pair.darkThemeId)\n : undefined,\n })\n}\n\n/**\n * Which projection fills the `--editor-*` ramp.\n *\n * - `syntax` (the default) is the catalogue's quiet syntax roles, as `ThemeVariant.editor`\n * holds them: a comment may sit below body-text contrast, because in a code view\n * it is meant to recede.\n * - `floor` holds every editor role to 4.5:1 on the canvas (`editorRolesHex`), for a\n * host that renders code as content rather than as decoration. It is hex, where\n * `syntax` is `oklch()`.\n */\nexport type EditorRolesMode = 'syntax' | 'floor'\n\n/** Options for {@link themeCssVariables}. */\nexport type ThemeCssVariableOptions = {\n /** The `--editor-*` projection. Default `syntax`: absent, the output is unchanged. */\n editor?: EditorRolesMode\n}\n\n/**\n * True for the catalogue's own variant, not a host's copy that merely shares its id.\n *\n * Identity rather than id, because a host's imported theme may reuse a catalogue id\n * with different colours, and projecting the catalogue's record for it would paint\n * the wrong palette.\n */\nexport function isCatalogueVariant(variant: ThemeVariant): boolean {\n return themeById(variant.id) === variant\n}\n\n/**\n * The editor palette held to 4.5:1, or `fallback` for a record that cannot reach it.\n *\n * Some palettes (an imported one, most often) cannot be repaired to the floor from\n * their own ramp within the catalogue's lightness budget, and `editorRolesHex` says\n * so by throwing. A palette that paints nothing is worse than one that paints its\n * quiet roles, so the throw is the cue to fall back rather than to fail. `project` is\n * a parameter so that path can be exercised: no catalogue theme takes it.\n */\nexport function floorEditorPalette(\n record: AdeaTheme,\n fallback: ThemeEditorPalette,\n project: (theme: AdeaTheme) => Record<keyof ThemeEditorPalette, string> = editorRolesHex\n): ThemeEditorPalette {\n try {\n const roles = project(record)\n return {\n keyword: roles.keyword,\n string: roles.string,\n number: roles.number,\n comment: roles.comment,\n function: roles.function,\n variable: roles.variable,\n type: roles.type,\n tag: roles.tag,\n attribute: roles.attribute,\n operator: roles.operator,\n heading: roles.heading,\n link: roles.link,\n diffAdd: roles.diffAdd,\n diffDelete: roles.diffDelete,\n diffHunk: roles.diffHunk,\n searchMatch: roles.searchMatch,\n }\n } catch {\n return fallback\n }\n}\n\nconst floorEditorCache = new Map<string, ThemeEditorPalette>()\n\n/**\n * The editor palette a variant paints under a projection.\n *\n * `floor` applies to the catalogue's own variants, whose record the catalogue holds.\n * A variant it does not hold (a host's imported theme) has no record to project and\n * keeps its own `editor`; such a theme normally carries its roles in `tokens`, which\n * win over either projection anyway. Computed once per theme: the repair is a search.\n */\nexport function editorPaletteFor(\n theme: ThemeVariant,\n mode: EditorRolesMode = 'syntax'\n): ThemeEditorPalette {\n if (mode !== 'floor' || !isCatalogueVariant(theme)) return theme.editor\n const cached = floorEditorCache.get(theme.id)\n if (cached) return cached\n const record = getTheme(theme.id)\n const palette = record ? floorEditorPalette(record, theme.editor) : theme.editor\n floorEditorCache.set(theme.id, palette)\n return palette\n}\n\n/**\n * The roles a variant sets, as CSS custom properties.\n *\n * The one place that knows the mapping from a theme's roles to this system's variable\n * names. A provider applies this; nothing else repeats it. The `--terminal-*` and\n * `--editor-*` ramps are presentations of the catalogue's ANSI and syntax data rather\n * than separate roles, which is why they are built here and not in the catalogue.\n *\n * `options.editor` picks the `--editor-*` projection ({@link EditorRolesMode}).\n * Absent it, the result is what it has always been; the generated `theme-variants.css`\n * and the design-system artifact are built without it.\n */\nexport function themeCssVariables(\n theme: ThemeVariant,\n options: ThemeCssVariableOptions = {}\n): Record<string, string> {\n const c = theme.colors\n const t = theme.terminal\n const e = editorPaletteFor(theme, options.editor)\n const derived = {\n '--background': c.background,\n '--foreground': c.foreground,\n '--card': c.card,\n '--card-foreground': c.cardForeground,\n '--popover': c.popover,\n '--popover-foreground': c.popoverForeground,\n '--primary': c.primary,\n '--primary-foreground': c.primaryForeground,\n /*\n * The two tokens derived from the primary, and they are here rather than left to\n * `theme.css` because they must follow `--primary` — which this function writes\n * for *any* theme in the catalogue, not just the two defaults `theme.css` carries.\n *\n * `--primary-hover` is a resolved colour, not a `color-mix()`: a uniform hover\n * step cannot be expressed as a mix (see `primaryHover`). Left out, a theme switch\n * would keep the previous theme's hover on the new theme's primary.\n *\n * `--primary-subtle` is a mix over `--primary`, so it follows an accent on its\n * own, but its *strength* is per theme: `primarySubtleCss(record)` lowers the\n * appearance ceiling only as far as this theme needs for body text to clear 4.5:1\n * on the tint, over every surface, for every accent it offers. It has to be\n * written per theme for that reason — the appearance-wide value is not legible on\n * every palette.\n */\n '--primary-hover': primaryHover(c.primary, theme.appearance),\n '--primary-subtle': primarySubtleFor(theme),\n '--secondary': c.secondary,\n '--secondary-foreground': c.secondaryForeground,\n '--muted': c.muted,\n '--muted-foreground': c.mutedForeground,\n '--accent': c.accent,\n '--accent-foreground': c.accentForeground,\n '--destructive': c.destructive,\n '--destructive-foreground': c.destructiveForeground,\n '--destructive-subtle': c.destructiveSubtle,\n '--destructive-action': c.destructiveAction,\n '--destructive-action-foreground': c.destructiveActionForeground,\n '--success': c.success,\n '--success-foreground': c.successForeground,\n '--success-subtle': c.successSubtle,\n '--warning': c.warning,\n '--warning-foreground': c.warningForeground,\n '--warning-subtle': c.warningSubtle,\n '--info': c.info,\n '--info-foreground': c.infoForeground,\n '--info-subtle': c.infoSubtle,\n '--border': c.border,\n '--input': c.input,\n '--ring': c.ring,\n '--sidebar': c.sidebar,\n '--sidebar-foreground': c.sidebarForeground,\n '--sidebar-accent': c.sidebarAccent,\n '--sidebar-border': c.sidebarBorder,\n '--sidebar-primary': c.primary,\n '--sidebar-primary-foreground': c.primaryForeground,\n '--sidebar-ring': c.ring,\n '--sidebar-muted-foreground': c.sidebarMutedForeground,\n '--surface-sunken': c.muted,\n '--surface-hover': c.accent,\n '--surface-active': c.border,\n '--chrome': c.background,\n '--terminal-background': t.background,\n '--terminal-foreground': t.foreground,\n '--terminal-cursor': t.cursor,\n '--terminal-selection': t.selection,\n '--terminal-ansi-black': t.black,\n '--terminal-ansi-red': t.red,\n '--terminal-ansi-green': t.green,\n '--terminal-ansi-yellow': t.yellow,\n '--terminal-ansi-blue': t.blue,\n '--terminal-ansi-magenta': t.magenta,\n '--terminal-ansi-cyan': t.cyan,\n '--terminal-ansi-white': t.white,\n '--terminal-ansi-bright-black': t.brightBlack,\n '--terminal-ansi-bright-red': t.brightRed,\n '--terminal-ansi-bright-green': t.brightGreen,\n '--terminal-ansi-bright-yellow': t.brightYellow,\n '--terminal-ansi-bright-blue': t.brightBlue,\n '--terminal-ansi-bright-magenta': t.brightMagenta,\n '--terminal-ansi-bright-cyan': t.brightCyan,\n '--terminal-ansi-bright-white': t.brightWhite,\n '--editor-keyword': e.keyword,\n '--editor-string': e.string,\n '--editor-number': e.number,\n '--editor-comment': e.comment,\n '--editor-function': e.function,\n '--editor-variable': e.variable,\n '--editor-type': e.type,\n '--editor-tag': e.tag,\n '--editor-attribute': e.attribute,\n '--editor-operator': e.operator,\n '--editor-heading': e.heading,\n '--editor-link': e.link,\n '--editor-diff-add': e.diffAdd,\n '--editor-diff-delete': e.diffDelete,\n '--editor-diff-hunk': e.diffHunk,\n '--editor-search-match': e.searchMatch,\n '--chart-1': theme.chart[0] ?? c.primary,\n '--chart-2': theme.chart[1] ?? c.info,\n '--chart-3': theme.chart[2] ?? c.success,\n '--chart-4': theme.chart[3] ?? c.warning,\n '--chart-5': theme.chart[4] ?? c.destructive,\n '--chart-6': theme.chart[5] ?? c.mutedForeground,\n }\n return theme.tokens ? { ...derived, ...theme.tokens } : derived\n}\n\n/**\n * The `--terminal-*` properties of a variant: the palette a terminal paints.\n *\n * What a pinned terminal theme writes over the interface variant's own. Taken from\n * {@link themeCssVariables} rather than rebuilt, so the names, and a custom\n * variant's verbatim `tokens`, can never drift from what the interface variant\n * would have written for the same palette.\n */\nexport function terminalCssVariables(theme: ThemeVariant): Record<string, string> {\n return Object.fromEntries(\n Object.entries(themeCssVariables(theme)).filter(([name]) => name.startsWith('--terminal-'))\n )\n}\n\n/**\n * Token values with every `oklch()` colour written as `#rrggbb`.\n *\n * For a host whose stylesheet, tests or native shell speak hex: the catalogue's\n * roles are `oklch()` strings, and this is the one conversion, gamut-mapped by the\n * catalogue's own `oklchToHex`. A value that is already hex, carries alpha\n * (`rgba()`), or is not a plain colour (`color-mix()`, `var()`) is left byte for\n * byte, because converting would either lose the alpha or be a guess. Suitable as\n * `ThemeProvider`'s `transformTokens`.\n */\nexport function tokensAsHex(tokens: Readonly<Record<string, string>>): Record<string, string> {\n const converted: Record<string, string> = {}\n for (const [name, value] of Object.entries(tokens)) {\n const trimmed = value.trim()\n // `parseOklch` discards alpha, so a translucent oklch() stays as written.\n const opaque = trimmed.startsWith('oklch(') && !trimmed.includes('/')\n const parsed = opaque ? parseColor(trimmed) : undefined\n converted[name] = parsed ? oklchToHex(parsed) : value\n }\n return converted\n}\n\n/* ---------------------------------------------------------------------------\n * Validation\n *\n * Delegated. The floors are the catalogue's, because they are what makes the\n * catalogue able to hold other people's palettes at all, and a second set of floors\n * here would be a second answer to the same question — and the one that drifts.\n * ------------------------------------------------------------------------- */\n\nexport type ThemeFinding = {\n themeId: string\n role: string\n message: string\n}\n\nfunction toFinding(finding: ContrastFinding): ThemeFinding {\n return { themeId: finding.themeId, role: finding.role, message: finding.message }\n}\n\n/** Validates one variant. The floors, and the reasoning behind them, live in the catalogue. */\nexport function validateTheme(theme: ThemeVariant): ThemeFinding[] {\n const record = catalogue.find((entry) => entry.id === theme.id)\n if (!record) {\n return [{ themeId: theme.id, role: 'id', message: `${theme.id} is not in the catalogue` }]\n }\n return validateCatalogue([record]).map(toFinding)\n}\n\n/** Validates the whole registry, including the catalogue-level invariants. */\nexport function validateThemeRegistry(\n themes: readonly ThemeVariant[] = builtinThemes\n): ThemeFinding[] {\n const records = themes\n .map((theme) => catalogue.find((entry) => entry.id === theme.id))\n .filter((record): record is AdeaThemeRecord => !!record)\n\n const orphaned = themes\n .filter((theme) => !hasTheme(theme.id))\n .map((theme) => ({\n themeId: theme.id,\n role: 'id',\n message: `${theme.id} is in the registry but not in the catalogue`,\n }))\n\n return [...orphaned, ...validateCatalogue(records).map(toFinding)]\n}\n\nexport const defaultLightThemeId = 'adea-light'\nexport const defaultDarkThemeId = 'adea-dark'\n\n/** Re-exported so a consumer measuring a colour does not need a second import. */\nexport { contrastRatio } from '@adea-ai/themes'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwMA,SAAS,SAAS,OAAqC;CACrD,MAAM,YAAY,gBAAgB,KAAK;CACvC,MAAM,SAAS,SAAyB;EACtC,MAAM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AAC,CAAC,IAAI,SAAS,CAAC;AACnE;AAEA,IAAa,sBAAsB;AACnC,IAAa,qBAAqB"}
|
|
1
|
+
{"version":3,"file":"themes.js","names":["catalogue","themes"],"sources":["../../src/lib/themes.ts"],"sourcesContent":["/**\n * The theme registry, now a bridge.\n *\n * The catalogue itself lives in `@adea-ai/themes`. This module is what is left in\n * the design system: the translation between the catalogue's **canonical** role\n * names and the **shadcn** vocabulary every component here is written against, plus\n * the handful of custom properties this system declares that are presentations of\n * data the catalogue already holds — the `--terminal-*` ramp, the `--editor-*` ramp,\n * and `--chrome`.\n *\n * ## Why it is a bridge and not a copy\n *\n * This file used to hold thirteen themes as hand-written hex literal tables, with its\n * own contrast validator, its own terminal and editor palettes, and its own\n * provenance records. That is a lot of surface to maintain for one consumer of a\n * palette, and it meant every product that wanted the same themes — Adea, Cortana —\n * either imported this package or wrote its own. The catalogue moved out so that\n * there is one answer to \"what is Catppuccin Mocha\", and this file is the part that\n * genuinely belongs to the design system.\n *\n * It is deliberately thin. If you are looking for a colour, it is not here: see\n * `@adea-ai/themes`, whose README explains how the values are produced and whose\n * `NOTICE` records where every palette came from.\n *\n * ## The mapping, and the entry that is not a rename\n *\n * The package-owned `shadcnVariables` adapter maps canonical roles onto this\n * system's vocabulary. One entry will trip a reader: the catalogue's `accent`\n * becomes this system's `primary`, because in the shadcn vocabulary `--primary` is\n * the action colour — the fill of a primary button, the thing a focus ring is drawn\n * in — while `--accent` is a low-contrast hover wash. The catalogue's `accent` is\n * the former, so it goes to `--primary`, and `--accent` is filled from\n * `surfaceHover`, which is what shadcn components actually use it for.\n */\n\nimport {\n ACCENTS,\n accentForeground,\n chartSeries,\n editorRolesHex,\n getAccent,\n getTheme,\n hasTheme,\n shadcnDestructiveProjection,\n statusForeground,\n tint,\n primarySubtleCss,\n syntaxRoles,\n themes as catalogue,\n themesByAppearance,\n themeAccentPresets,\n validateCatalogue,\n type AccentPreset,\n type AdeaTheme,\n type AdeaThemeRecord,\n type ContrastFinding,\n} from '@adea-ai/themes'\nimport { shadcnVariables } from '@adea-ai/themes/adapters/shadcn'\nimport { accentOverrideVariables, resolveAccentRoles, type AccentRoles } from './accent-roles'\nimport { isThemeAccentId } from './theme-accents'\nimport { themeCssVariablesWith } from './theme-css'\nimport { defaultDarkThemeId, defaultLightThemeId } from './theme-defaults'\n\nexport { isThemeAccentId } from './theme-accents'\nexport { terminalCssVariables, tokensAsHex } from './theme-css'\nexport { defaultDarkThemeId, defaultLightThemeId, resolveVariant } from './theme-defaults'\n\nexport type ThemeAppearance = 'light' | 'dark'\n\n/**\n * The surface and text roles, in shadcn's vocabulary.\n *\n * Named to match the components below, which is why they differ from the\n * catalogue's: these are this system's variable names, and renaming them would mean\n * touching every component in the library for no gain.\n */\nexport type ThemeColors = {\n background: string\n foreground: string\n card: string\n cardForeground: string\n popover: string\n popoverForeground: string\n primary: string\n primaryForeground: string\n secondary: string\n secondaryForeground: string\n muted: string\n mutedForeground: string\n accent: string\n accentForeground: string\n destructive: string\n destructiveForeground: string\n destructiveSubtle: string\n /** Contrast-safe solid-action presentation, derived from the canonical error role. */\n destructiveAction: string\n destructiveActionForeground: string\n success: string\n successForeground: string\n successSubtle: string\n warning: string\n warningForeground: string\n warningSubtle: string\n info: string\n infoForeground: string\n infoSubtle: string\n border: string\n input: string\n ring: string\n sidebar: string\n sidebarForeground: string\n sidebarAccent: string\n sidebarBorder: string\n sidebarMutedForeground: string\n}\n\n/** The sixteen ANSI colours a terminal needs, plus its cursor and selection. */\nexport type ThemeTerminalPalette = {\n background: string\n foreground: string\n cursor: string\n selection: string\n black: string\n red: string\n green: string\n yellow: string\n blue: string\n magenta: string\n cyan: string\n white: string\n brightBlack: string\n brightRed: string\n brightGreen: string\n brightYellow: string\n brightBlue: string\n brightMagenta: string\n brightCyan: string\n brightWhite: string\n}\n\n/** The syntax roles a code view needs. */\nexport type ThemeEditorPalette = {\n keyword: string\n string: string\n number: string\n comment: string\n function: string\n variable: string\n type: string\n tag: string\n attribute: string\n operator: string\n heading: string\n link: string\n diffAdd: string\n diffDelete: string\n diffHunk: string\n searchMatch: string\n}\n\n/** Where a palette came from, and the terms it is used under. */\nexport type ThemeProvenance = {\n /** The project or person the palette belongs to. */\n source: string\n url: string\n /** An SPDX identifier. Every palette in this catalogue is permissive. */\n license: string\n}\n\nexport type ThemeVariant = {\n /** The `data-theme` value and the id a preference stores. */\n id: string\n /** Groups the variants that came from one project. */\n family: string\n familyLabel: string\n label: string\n appearance: ThemeAppearance\n /** One line, shown in a picker. */\n description: string\n colors: ThemeColors\n terminal: ThemeTerminalPalette\n editor: ThemeEditorPalette\n /** The categorical series, in order. */\n chart: readonly string[]\n provenance: ThemeProvenance\n /**\n * Custom properties written verbatim over {@link themeCssVariables}, last.\n *\n * For a variant a host built from data it does not control the derivation of —\n * an imported theme whose painted colours must stay exactly what the user\n * imported. The catalogue's own variants never carry it, so the derived roles\n * stay the only source of truth for them.\n */\n tokens?: Readonly<Record<string, string>>\n}\n\n/**\n * The shadcn-vocabulary roles of one catalogue entry.\n *\n * The expensive half of a variant: `shadcnVariables` projects the whole palette\n * (about 4 ms a theme), which is why {@link lazyVariant} defers it.\n */\nfunction colorsOf(theme: AdeaThemeRecord): ThemeColors {\n const projected = shadcnVariables(theme)\n const token = (name: string): string => {\n const value = projected[`--${name}`]\n if (!value) throw new Error(`${theme.id} has no shared shadcn projection for --${name}`)\n return value\n }\n const destructiveAction = shadcnDestructiveProjection(theme)\n return {\n background: token('background'),\n foreground: token('foreground'),\n card: token('card'),\n cardForeground: token('card-foreground'),\n popover: token('popover'),\n popoverForeground: token('popover-foreground'),\n primary: token('primary'),\n primaryForeground: token('primary-foreground'),\n secondary: token('secondary'),\n secondaryForeground: token('secondary-foreground'),\n muted: token('muted'),\n mutedForeground: token('muted-foreground'),\n accent: token('accent'),\n accentForeground: token('accent-foreground'),\n // Preserve the UI's semantic error token. The Themes projection uses its\n // contrast-safe solid-action fill for --destructive; UI keeps that fill in\n // the separate destructiveAction pair below.\n destructive: theme.colors.error,\n destructiveForeground: statusForeground(theme, 'error'),\n destructiveSubtle: tint(theme.colors.error, theme.colors.background),\n destructiveAction: destructiveAction.fill,\n destructiveActionForeground: destructiveAction.foreground,\n success: token('success'),\n successForeground: statusForeground(theme, 'success'),\n successSubtle: tint(theme.colors.success, theme.colors.background),\n warning: token('warning'),\n warningForeground: statusForeground(theme, 'warning'),\n warningSubtle: tint(theme.colors.warning, theme.colors.background),\n info: token('info'),\n infoForeground: statusForeground(theme, 'info'),\n infoSubtle: tint(theme.colors.info, theme.colors.background),\n border: token('border'),\n input: token('input'),\n ring: token('ring'),\n sidebar: token('sidebar'),\n sidebarForeground: token('sidebar-foreground'),\n sidebarAccent: token('sidebar-accent'),\n sidebarBorder: token('sidebar-border'),\n sidebarMutedForeground: token('sidebar-muted-foreground'),\n }\n}\n\n// The embedded terminal uses the theme's own canvas rather than a palette of its\n// own. The ANSI colours came from the palette that produced the canvas, so they\n// were chosen against it; a terminal on a different background would be the one\n// surface in the application not lit by the active theme.\nfunction terminalOf(theme: AdeaThemeRecord): ThemeTerminalPalette {\n return {\n background: theme.colors.background,\n foreground: theme.colors.foreground,\n cursor: theme.cursor,\n selection: theme.selection,\n ...theme.ansi,\n }\n}\n\nfunction editorOf(theme: AdeaThemeRecord): ThemeEditorPalette {\n const syntax = syntaxRoles(theme)\n return {\n keyword: syntax.keyword,\n string: syntax.string,\n number: syntax.number,\n comment: syntax.comment,\n function: syntax.function,\n variable: syntax.variable,\n type: syntax.type,\n tag: syntax.tag,\n attribute: syntax.attribute,\n operator: syntax.operator,\n heading: syntax.heading,\n link: syntax.link,\n diffAdd: syntax.diffAdd,\n diffDelete: syntax.diffDelete,\n diffHunk: syntax.diffHunk,\n searchMatch: syntax.searchMatch,\n }\n}\n\nfunction provenanceOf(theme: AdeaThemeRecord): ThemeProvenance {\n return {\n source: theme.provenance.project,\n url: theme.provenance.url,\n license: theme.provenance.license,\n }\n}\n\n/**\n * The design system's view of one catalogue record, built in full and at once.\n *\n * For a host that holds a record the catalogue does not — an imported theme, a\n * reconstruction from stored data — and wants a variant it can hand to\n * `ThemeProvider`'s `themes`. It throws for a record the shadcn projection cannot\n * map, here and now, rather than on first paint. The catalogue itself goes through\n * {@link lazyVariant} instead.\n */\nexport function variantFromRecord(theme: AdeaThemeRecord): ThemeVariant {\n return {\n id: theme.id,\n family: theme.family,\n familyLabel: theme.familyLabel,\n label: theme.label,\n appearance: theme.appearance,\n description: theme.description,\n colors: colorsOf(theme),\n terminal: terminalOf(theme),\n editor: editorOf(theme),\n chart: chartSeries(theme),\n provenance: provenanceOf(theme),\n }\n}\n\n/** Runs `build` on first call and returns that value from then on. A throw is not cached. */\nfunction once<T>(build: () => T): () => T {\n let built = false\n let value: T\n return () => {\n if (!built) {\n value = build()\n built = true\n }\n return value\n }\n}\n\nconst lazy = <T>(build: () => T): PropertyDescriptor => ({\n get: once(build),\n enumerable: true,\n})\n\n/**\n * {@link variantFromRecord} with the four derived palettes built on first read.\n *\n * Evaluating this module used to project all 34 catalogue themes up front, about\n * 155 ms before a single one was needed, on the hydration path of every consumer.\n * A page paints one variant, and a picker's labels and appearance are plain\n * fields, so only a variant whose `colors`, `terminal`, `editor` or `chart` is read\n * pays for them, once. The properties stay enumerable data-shaped accessors, so\n * spreading, `Object.entries` and JSON see the same object they always did.\n */\nfunction lazyVariant(theme: AdeaThemeRecord): ThemeVariant {\n return Object.defineProperties(\n {\n id: theme.id,\n family: theme.family,\n familyLabel: theme.familyLabel,\n label: theme.label,\n appearance: theme.appearance,\n description: theme.description,\n provenance: provenanceOf(theme),\n },\n {\n colors: lazy(() => colorsOf(theme)),\n terminal: lazy(() => terminalOf(theme)),\n editor: lazy(() => editorOf(theme)),\n chart: lazy(() => chartSeries(theme)),\n }\n ) as ThemeVariant\n}\n\n/**\n * A variant's `--primary-subtle`: the tint over `var(--primary)` at the strength its\n * catalogue record measures (`primarySubtleAlpha`). A variant that is not in the\n * catalogue has nothing to measure, and gets its appearance's ceiling.\n */\nexport function primarySubtleFor(theme: Pick<ThemeVariant, 'id' | 'appearance'>): string {\n const record = getTheme(theme.id)\n return record ? primarySubtleCss(record) : primarySubtleCss(theme.appearance)\n}\n\n/**\n * The catalogue, in catalogue order.\n *\n * The `@__PURE__` marks let a bundler drop the whole table, and with it the catalogue,\n * from a consumer that imports only this module's catalogue-free helpers\n * (`tokensAsHex`, `isThemeAccentId`, `resolveVariant`…) and never reads it.\n */\nexport const builtinThemes: readonly ThemeVariant[] = /* @__PURE__ */ Object.freeze(\n /* @__PURE__ */ catalogue.map(lazyVariant)\n)\n\nexport function themeById(id: string): ThemeVariant | undefined {\n if (!hasTheme(id)) return undefined\n return builtinThemes.find((theme) => theme.id === id)\n}\n\n/** The variants of one appearance, which is what a picker for that mode shows. */\nexport function themesForAppearance(appearance: ThemeAppearance): readonly ThemeVariant[] {\n const ids = new Set(themesByAppearance(appearance).map((theme) => theme.id))\n return builtinThemes.filter((theme) => ids.has(theme.id))\n}\n\n/** The families in the catalogue, in catalogue order. */\nexport function themeFamilies(): { family: string; label: string; themes: ThemeVariant[] }[] {\n const families = new Map<string, { family: string; label: string; themes: ThemeVariant[] }>()\n for (const theme of builtinThemes) {\n const entry = families.get(theme.family) ?? {\n family: theme.family,\n label: theme.familyLabel,\n themes: [],\n }\n entry.themes.push(theme)\n families.set(theme.family, entry)\n }\n return [...families.values()]\n}\n\n/** The accent presets, in the order a picker should show them. */\nexport const accents = ACCENTS\n\n/**\n * The canonical catalogue records, in catalogue order.\n *\n * {@link builtinThemes} is this system's projection of the catalogue onto the\n * shadcn vocabulary, which is what a document is painted with. A *preview* of a\n * theme — the miniatures `AppearanceEditor` and `ThemeMiniature` draw — reads the\n * catalogue's own roles instead (`surfaceActive`, `borderMuted`, `textSubtle`…),\n * several of which the projection folds together. These are those records, so a\n * consumer hands the editor exactly what it takes rather than reconstructing it\n * from the projection.\n */\nexport const themeRecords: readonly AdeaThemeRecord[] = catalogue\n\nexport function themeRecordById(id: string): AdeaThemeRecord | undefined {\n return getTheme(id)\n}\n\n/** A light/dark theme pair by id, with the defaults standing in for an unknown id. */\nfunction recordPair(lightThemeId: string, darkThemeId: string) {\n const light = getTheme(lightThemeId) ?? getTheme(defaultLightThemeId)!\n const dark = getTheme(darkThemeId) ?? getTheme(defaultDarkThemeId)!\n return { light, dark }\n}\n\n/**\n * The accents the selected light/dark pair carries — offered beside the presets.\n *\n * Computed per pair rather than per theme because a theme accent is a *pair* of\n * values, like a preset: a slot is offered only when both themes can offer it.\n */\nexport function themeAccentsFor(\n lightThemeId: string,\n darkThemeId: string\n): readonly AccentPreset[] {\n const { light, dark } = recordPair(lightThemeId, darkThemeId)\n return themeAccentPresets(light, dark)\n}\n\n/**\n * An accent id resolved against a theme pair: a preset, a theme accent the pair\n * offers, or `undefined` for `theme`, an unknown id, or a slot this pair cannot\n * offer — each of which means \"use the theme's own primary\".\n *\n * Theme accent ids are role-shaped (`ansi-blue`), so a stored one survives a theme\n * switch and resolves to the new theme's blue; when the new pair cannot offer the\n * slot it resolves to nothing, the same fallback a stale preset id gets.\n */\nexport function resolveAccentPreset(\n accentId: string,\n light: AdeaTheme,\n dark: AdeaTheme\n): AccentPreset | undefined {\n if (accentId === 'theme') return undefined\n const preset = getAccent(accentId)\n if (preset) return preset\n if (!isThemeAccentId(accentId)) return undefined\n return themeAccentPresets(light, dark).find((option) => option.id === accentId)\n}\n\n/**\n * A theme with an accent laid over it, in the catalogue's own shape.\n *\n * The accent replaces `accent` and its measured label, which is all an accent\n * changes about a theme; `undefined` returns the theme untouched. This is the\n * overlay a host needs for `AppearanceEditor`'s `lightTheme`/`darkTheme`.\n */\nexport function withAccent<T extends AdeaTheme>(theme: T, accent: AccentPreset | undefined): T {\n if (!accent) return theme\n const value = theme.appearance === 'dark' ? accent.dark : accent.light\n return {\n ...theme,\n colors: { ...theme.colors, accent: value, accentForeground: accentForeground(value) },\n }\n}\n\n/**\n * The two preview themes an appearance selection resolves to, accent applied.\n *\n * The adapter between a stored selection and `AppearanceEditor`: it takes ids —\n * what a preference holds — and returns the canonical records the editor's\n * `lightTheme` and `darkTheme` props take, so a host does not map roles by hand.\n * Unknown ids fall back to the defaults and an accent the pair cannot offer falls\n * back to the theme's own, exactly as `ThemeProvider` resolves them.\n */\nexport function appearancePreviewThemes(selection: {\n lightThemeId: string\n darkThemeId: string\n accent: string\n}): { lightTheme: AdeaThemeRecord; darkTheme: AdeaThemeRecord } {\n const { light, dark } = recordPair(selection.lightThemeId, selection.darkThemeId)\n const accent = resolveAccentPreset(selection.accent, light, dark)\n return { lightTheme: withAccent(light, accent), darkTheme: withAccent(dark, accent) }\n}\n\n/**\n * The properties an accent selection overrides, as CSS custom properties.\n *\n * ## Why this exists rather than relying on the `[data-accent]` blocks\n *\n * `theme.css` carries a `[data-accent='…']` block per preset, and those blocks are\n * correct — but they are unreachable at runtime. `ThemeProvider` writes a theme's\n * whole role set onto `<html>` as *inline* custom properties, and an inline\n * declaration outranks any stylesheet selector regardless of specificity. The\n * attribute was set, the rules existed, the values were right, and every one of the\n * seven accents rendered as the same blue.\n *\n * The blocks are kept, because they are what styles the window between the document\n * arriving and the provider mounting — which is the whole reason `themeScript`\n * exists. But the authoritative value has to be applied by the same code that\n * applies the theme, from the same source, or the two can drift again. So both the\n * provider and the CSS generator call `accentRoles` out of `@adea-ai/themes`, and\n * `tests/appearance-axes.test.ts` asserts the two agree value for value.\n *\n * A theme accent (`ansi-blue`) has no block: its value depends on the theme pair,\n * so it is resolved against `pair` — the selection's light and dark theme ids —\n * and only ever applied here. Without a pair it resolves against the defaults.\n *\n * Returns `undefined` for `theme` — the variant's own primary — for an id the\n * catalogue does not have, and for a theme accent the pair does not offer, so a\n * stale stored preference falls back to the theme rather than blanking the primary.\n */\nexport function accentVariables(\n accentId: string,\n appearance: ThemeAppearance,\n pair: { lightThemeId: string; darkThemeId: string } = {\n lightThemeId: defaultLightThemeId,\n darkThemeId: defaultDarkThemeId,\n },\n options: AccentVariableOptions = {}\n): Record<string, string> | undefined {\n const roles = accentRolesForSelection(accentId, appearance, pair, options)\n return roles ? accentOverrideVariables(roles) : undefined\n}\n\n/** What an accent is held to when it is resolved against a surface. */\nexport type AccentVariableOptions = {\n /** The surface the accent must read on: the variant's `colors.background`. */\n background?: string\n /**\n * The contrast floor against `background`. Absent, a preset is painted verbatim\n * and only a custom `#rrggbb` is held to the default floor.\n */\n floor?: number\n /** The variant the accent is applied to, so the tint takes its measured strength. */\n variantId?: string\n}\n\n/**\n * An accent selection resolved to the full {@link AccentRoles}, against a theme\n * pair. {@link accentVariables} is the document half of this; an element-scoped\n * paint (`paintAccentRoles`) wants all of it, including the tint.\n */\nexport function accentRolesForSelection(\n accentId: string,\n appearance: ThemeAppearance,\n pair: { lightThemeId: string; darkThemeId: string } = {\n lightThemeId: defaultLightThemeId,\n darkThemeId: defaultDarkThemeId,\n },\n options: AccentVariableOptions = {}\n): AccentRoles | undefined {\n if (accentId === 'theme') return undefined\n const record = options.variantId ? getTheme(options.variantId) : undefined\n return resolveAccentRoles(accentId, {\n target: record ?? appearance,\n background: options.background,\n floor: options.floor,\n // Only an `ansi-*` id needs the pair's offering, and measuring it is not free.\n themeAccents: isThemeAccentId(accentId)\n ? themeAccentsFor(pair.lightThemeId, pair.darkThemeId)\n : undefined,\n })\n}\n\n/**\n * Which projection fills the `--editor-*` ramp.\n *\n * - `syntax` (the default) is the catalogue's quiet syntax roles, as `ThemeVariant.editor`\n * holds them: a comment may sit below body-text contrast, because in a code view\n * it is meant to recede.\n * - `floor` holds every editor role to 4.5:1 on the canvas (`editorRolesHex`), for a\n * host that renders code as content rather than as decoration. It is hex, where\n * `syntax` is `oklch()`.\n */\nexport type EditorRolesMode = 'syntax' | 'floor'\n\n/** Options for {@link themeCssVariables}. */\nexport type ThemeCssVariableOptions = {\n /** The `--editor-*` projection. Default `syntax`: absent, the output is unchanged. */\n editor?: EditorRolesMode\n}\n\n/**\n * True for the catalogue's own variant, not a host's copy that merely shares its id.\n *\n * Identity rather than id, because a host's imported theme may reuse a catalogue id\n * with different colours, and projecting the catalogue's record for it would paint\n * the wrong palette.\n */\nexport function isCatalogueVariant(variant: ThemeVariant): boolean {\n return themeById(variant.id) === variant\n}\n\n/**\n * The editor palette held to 4.5:1, or `fallback` for a record that cannot reach it.\n *\n * Some palettes (an imported one, most often) cannot be repaired to the floor from\n * their own ramp within the catalogue's lightness budget, and `editorRolesHex` says\n * so by throwing. A palette that paints nothing is worse than one that paints its\n * quiet roles, so the throw is the cue to fall back rather than to fail. `project` is\n * a parameter so that path can be exercised: no catalogue theme takes it.\n */\nexport function floorEditorPalette(\n record: AdeaTheme,\n fallback: ThemeEditorPalette,\n project: (theme: AdeaTheme) => Record<keyof ThemeEditorPalette, string> = editorRolesHex\n): ThemeEditorPalette {\n try {\n const roles = project(record)\n return {\n keyword: roles.keyword,\n string: roles.string,\n number: roles.number,\n comment: roles.comment,\n function: roles.function,\n variable: roles.variable,\n type: roles.type,\n tag: roles.tag,\n attribute: roles.attribute,\n operator: roles.operator,\n heading: roles.heading,\n link: roles.link,\n diffAdd: roles.diffAdd,\n diffDelete: roles.diffDelete,\n diffHunk: roles.diffHunk,\n searchMatch: roles.searchMatch,\n }\n } catch {\n return fallback\n }\n}\n\nconst floorEditorCache = new Map<string, ThemeEditorPalette>()\n\n/**\n * The editor palette a variant paints under a projection.\n *\n * `floor` applies to the catalogue's own variants, whose record the catalogue holds.\n * A variant it does not hold (a host's imported theme) has no record to project and\n * keeps its own `editor`; such a theme normally carries its roles in `tokens`, which\n * win over either projection anyway. Computed once per theme: the repair is a search.\n */\nexport function editorPaletteFor(\n theme: ThemeVariant,\n mode: EditorRolesMode = 'syntax'\n): ThemeEditorPalette {\n if (mode !== 'floor' || !isCatalogueVariant(theme)) return theme.editor\n const cached = floorEditorCache.get(theme.id)\n if (cached) return cached\n const record = getTheme(theme.id)\n const palette = record ? floorEditorPalette(record, theme.editor) : theme.editor\n floorEditorCache.set(theme.id, palette)\n return palette\n}\n\n/**\n * The roles a variant sets, as CSS custom properties.\n *\n * The mapping itself is `themeCssVariablesWith` in `theme-css.ts`; this binds it to\n * the catalogue, which measures a theme's `--primary-subtle` strength\n * ({@link primarySubtleFor}) and projects its floor editor ramp\n * ({@link editorPaletteFor}). Absent `options`, the result is what it has always\n * been; the generated `theme-variants.css` and the design-system artifact are built\n * without it.\n */\nexport function themeCssVariables(\n theme: ThemeVariant,\n options: ThemeCssVariableOptions = {}\n): Record<string, string> {\n return themeCssVariablesWith(\n {\n primarySubtle: primarySubtleFor,\n editor: (variant, mode) => editorPaletteFor(variant, mode),\n },\n theme,\n options\n )\n}\n\n/* ---------------------------------------------------------------------------\n * Validation\n *\n * Delegated. The floors are the catalogue's, because they are what makes the\n * catalogue able to hold other people's palettes at all, and a second set of floors\n * here would be a second answer to the same question — and the one that drifts.\n * ------------------------------------------------------------------------- */\n\nexport type ThemeFinding = {\n themeId: string\n role: string\n message: string\n}\n\nfunction toFinding(finding: ContrastFinding): ThemeFinding {\n return { themeId: finding.themeId, role: finding.role, message: finding.message }\n}\n\n/** Validates one variant. The floors, and the reasoning behind them, live in the catalogue. */\nexport function validateTheme(theme: ThemeVariant): ThemeFinding[] {\n const record = catalogue.find((entry) => entry.id === theme.id)\n if (!record) {\n return [{ themeId: theme.id, role: 'id', message: `${theme.id} is not in the catalogue` }]\n }\n return validateCatalogue([record]).map(toFinding)\n}\n\n/** Validates the whole registry, including the catalogue-level invariants. */\nexport function validateThemeRegistry(\n themes: readonly ThemeVariant[] = builtinThemes\n): ThemeFinding[] {\n const records = themes\n .map((theme) => catalogue.find((entry) => entry.id === theme.id))\n .filter((record): record is AdeaThemeRecord => !!record)\n\n const orphaned = themes\n .filter((theme) => !hasTheme(theme.id))\n .map((theme) => ({\n themeId: theme.id,\n role: 'id',\n message: `${theme.id} is in the registry but not in the catalogue`,\n }))\n\n return [...orphaned, ...validateCatalogue(records).map(toFinding)]\n}\n\n/** Re-exported so a consumer measuring a colour does not need a second import. */\nexport { contrastRatio } from '@adea-ai/themes'\n"],"mappings":";;;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ationTokens: TokenDefinition[];
|
|
44
44
|
export declare const motionTokens: TokenDefinition[];
|
|
45
45
|
export declare const zIndexTokens: TokenDefinition[];
|
|
46
|
-
|
|
47
|
-
* The accent axis.
|
|
48
|
-
*
|
|
49
|
-
* adea's accent presets, as a selection rather than a constant. `theme` is the
|
|
50
|
-
* default and means "the variant's own primary" — monochrome in adea's palette —
|
|
51
|
-
* and each named preset overrides the interactive roles through the
|
|
52
|
-
* `[data-accent]` blocks in `theme.css`.
|
|
53
|
-
*
|
|
54
|
-
* These are the same six presets `accentPresets` exports in adea's own
|
|
55
|
-
* `appearance.ts`, and the values match. A consumer's appearance picker and the
|
|
56
|
-
* workshop's theme toolbar read this one list, so the two cannot disagree about
|
|
57
|
-
* what a preset is called or what colour it is.
|
|
58
|
-
*/
|
|
59
|
-
export type AccentPreset = {
|
|
60
|
-
/** The `data-accent` value. `theme` is the variant's own primary. */
|
|
61
|
-
id: string;
|
|
62
|
-
label: string;
|
|
63
|
-
/** What the preset is for, in the gallery and in a picker. */
|
|
64
|
-
description: string;
|
|
65
|
-
/** The accent as it appears in the light theme. Absent for `theme`. */
|
|
66
|
-
light?: string;
|
|
67
|
-
/** The accent as it appears in the dark theme. Absent for `theme`. */
|
|
68
|
-
dark?: string;
|
|
69
|
-
};
|
|
70
|
-
export declare const accentPresets: readonly AccentPreset[];
|
|
46
|
+
export { accentPresets, type AccentPreset } from './accent-presets';
|
|
71
47
|
/** Every token, in gallery order. */
|
|
72
48
|
export declare const designTokens: {
|
|
73
49
|
readonly color: TokenDefinition[];
|
package/dist/lib/tokens.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../src/lib/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../src/lib/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhD,MAAM,MAAM,SAAS,GACjB,OAAO,GACP,WAAW,GACX,aAAa,GACb,QAAQ,GACR,UAAU,GACV,QAAQ,GACR,QAAQ,GACR,MAAM,CAAA;AAEV,MAAM,MAAM,eAAe,GAAG;IAC5B,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,SAAS,CAAA;IACf,8DAA8D;IAC9D,WAAW,EAAE,MAAM,CAAA;IACnB,oEAAoE;IACpE,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,eAAe,EAqVxC,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,eAAe,EAezC,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,eAAe,EAgI7C,CAAA;AAED;;+EAE+E;AAC/E,eAAO,MAAM,aAAa,EAAE,eAAe,EAwF1C,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,eAAe,EA2B5C,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,eAAe,EAkBzC,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,eAAe,EAyBzC,CAAA;AAED,OAAO,EAAE,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAEnE,qCAAqC;AACrC,eAAO,MAAM,YAAY;;;;;;;;CAQf,CAAA;AAEV,yDAAyD;AACzD,eAAO,MAAM,SAAS,EAAE,eAAe,EAAuC,CAAA;AAE9E;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,EAAE,MAAM,EAAe,CAAA"}
|
package/dist/lib/tokens.js
CHANGED
|
@@ -1,25 +1,7 @@
|
|
|
1
1
|
import { fontOptions } from "./font-catalog.js";
|
|
2
|
-
import {
|
|
2
|
+
import { accentPresets } from "./accent-presets.js";
|
|
3
3
|
//#region src/lib/tokens.ts
|
|
4
4
|
/**
|
|
5
|
-
* The design system's token manifest.
|
|
6
|
-
*
|
|
7
|
-
* `theme.css` is the source of truth for token *values*. This file is the
|
|
8
|
-
* source of truth for token *names and meaning* — what each one is for, and
|
|
9
|
-
* which ones a theme may vary.
|
|
10
|
-
*
|
|
11
|
-
* It exists because a manifest that is only documentation rots. Two things read
|
|
12
|
-
* it instead:
|
|
13
|
-
*
|
|
14
|
-
* - the token galleries in Storybook, so the review surface shows every token
|
|
15
|
-
* rather than the ones an author remembered;
|
|
16
|
-
* - `tests/tokens.test.ts`, which parses `theme.css` and fails when a token
|
|
17
|
-
* is declared in one place and missing from the other.
|
|
18
|
-
*
|
|
19
|
-
* That pairing is what makes "every token is documented and every documented
|
|
20
|
-
* token exists" a property the build enforces rather than a promise.
|
|
21
|
-
*/
|
|
22
|
-
/**
|
|
23
5
|
* Colour roles, in the order they appear in a page: surfaces first, then text,
|
|
24
6
|
* then the lines between them, then the semantic fills. The order is the
|
|
25
7
|
* documentation — reading the gallery top to bottom walks the surface ladder.
|
|
@@ -850,11 +832,6 @@ var zIndexTokens = [
|
|
|
850
832
|
description: "Notifications. Above everything, so they are never hidden by a dialog."
|
|
851
833
|
}
|
|
852
834
|
];
|
|
853
|
-
var accentPresets = Object.freeze([{
|
|
854
|
-
id: "theme",
|
|
855
|
-
label: "Theme",
|
|
856
|
-
description: "The variant's own primary. Neutral in adea's palette, so the interface stays monochrome."
|
|
857
|
-
}, ...ACCENTS]);
|
|
858
835
|
/** Every token, in gallery order. */
|
|
859
836
|
var designTokens = {
|
|
860
837
|
color: colorTokens,
|