@weasel-js/theme 1.5.0 → 1.5.1
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/README.md +67 -14
- package/dist/chunk-LL2ERJPZ.js +175 -0
- package/dist/chunk-LL2ERJPZ.js.map +1 -0
- package/dist/chunk-PJMTWM34.js +6 -0
- package/dist/chunk-PJMTWM34.js.map +1 -0
- package/dist/chunk-YBHW5LZM.js +1582 -0
- package/dist/chunk-YBHW5LZM.js.map +1 -0
- package/dist/engine.d.ts +293 -0
- package/dist/engine.js +1761 -0
- package/dist/engine.js.map +1 -0
- package/dist/index.d.ts +49 -15
- package/dist/index.js +143 -116
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +7 -5
- package/dist/react.js +13 -18
- package/dist/react.js.map +1 -1
- package/dist/{resolveTheme-DiF2Ew25.d.ts → resolveTheme-CHnPdh8W.d.ts} +84 -114
- package/dist/theme-BtpBHcUg.d.ts +189 -0
- package/dist/tokens.css +33 -27
- package/package.json +8 -1
- package/dist/chunk-VKZ4JIVX.js +0 -912
- package/dist/chunk-VKZ4JIVX.js.map +0 -1
package/dist/react.d.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { T as Theme,
|
|
2
|
+
import { T as Theme, S as Selection } from './theme-BtpBHcUg.js';
|
|
3
|
+
import { R as ResolvedTheme } from './resolveTheme-CHnPdh8W.js';
|
|
3
4
|
|
|
4
|
-
/** What `<ThemeProvider>` publishes: the theme, the
|
|
5
|
+
/** What `<ThemeProvider>` publishes: the theme, the full selection in force, and the
|
|
5
6
|
* fully resolved token record for that pair. */
|
|
6
7
|
interface ThemeContextValue {
|
|
7
8
|
readonly theme: Theme;
|
|
8
|
-
readonly
|
|
9
|
+
readonly selection: Selection;
|
|
9
10
|
readonly resolved: ResolvedTheme;
|
|
10
11
|
}
|
|
11
12
|
/** Props for `<ThemeProvider>`. */
|
|
12
13
|
interface ThemeProviderProps {
|
|
13
14
|
readonly theme?: Theme;
|
|
14
|
-
|
|
15
|
+
/** Axis values, e.g. `{ mode: 'light' }`. A missing axis takes its default. */
|
|
16
|
+
readonly selection?: Selection;
|
|
15
17
|
/** Applied to the wrapper element, so it can be the layout element too. */
|
|
16
18
|
readonly className?: string;
|
|
17
19
|
readonly style?: React.CSSProperties;
|
|
@@ -27,7 +29,7 @@ interface ThemeProviderProps {
|
|
|
27
29
|
* nesting your own div inside — an anonymous div between a flex parent and
|
|
28
30
|
* its child breaks percentage heights.
|
|
29
31
|
*/
|
|
30
|
-
declare function ThemeProvider({ theme,
|
|
32
|
+
declare function ThemeProvider({ theme, selection, className, style, children, }: ThemeProviderProps): React.ReactElement;
|
|
31
33
|
/** The theme in force. Throws outside a `<ThemeProvider>`; use
|
|
32
34
|
* `useThemeOptional` where the provider is not guaranteed. */
|
|
33
35
|
declare function useTheme(): ThemeContextValue;
|
package/dist/react.js
CHANGED
|
@@ -1,35 +1,30 @@
|
|
|
1
|
-
import { weaselTheme,
|
|
1
|
+
import { weaselTheme, applyTheme } from './chunk-YBHW5LZM.js';
|
|
2
|
+
import { themeAxes, fullSelection, selectionKey, resolveTheme } from './chunk-LL2ERJPZ.js';
|
|
2
3
|
import { createContext, useRef, useMemo, useLayoutEffect, useContext } from 'react';
|
|
3
4
|
import { jsx } from 'react/jsx-runtime';
|
|
4
5
|
|
|
5
6
|
var ThemeContext = createContext(null);
|
|
6
7
|
function ThemeProvider({
|
|
7
8
|
theme = weaselTheme,
|
|
8
|
-
|
|
9
|
+
selection,
|
|
9
10
|
className,
|
|
10
11
|
style,
|
|
11
12
|
children
|
|
12
13
|
}) {
|
|
13
14
|
const ref = useRef(null);
|
|
14
|
-
const
|
|
15
|
+
const axes = themeAxes(theme);
|
|
16
|
+
const full = fullSelection(axes, selection);
|
|
17
|
+
const key = selectionKey(axes, full);
|
|
15
18
|
const value = useMemo(
|
|
16
|
-
() => ({ theme,
|
|
17
|
-
|
|
19
|
+
() => ({ theme, selection: full, resolved: resolveTheme(theme, full) }),
|
|
20
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
21
|
+
[theme, key]
|
|
18
22
|
);
|
|
19
23
|
useLayoutEffect(() => {
|
|
20
|
-
if (ref.current) applyTheme(ref.current, theme,
|
|
21
|
-
}, [theme,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
{
|
|
25
|
-
ref,
|
|
26
|
-
className,
|
|
27
|
-
style,
|
|
28
|
-
"data-wzl-theme": theme.name,
|
|
29
|
-
"data-wzl-mode": effectiveMode,
|
|
30
|
-
children
|
|
31
|
-
}
|
|
32
|
-
) });
|
|
24
|
+
if (ref.current) applyTheme(ref.current, theme, value.selection);
|
|
25
|
+
}, [theme, value]);
|
|
26
|
+
const attrs = Object.fromEntries(Object.keys(axes).map((a) => [`data-wzl-${a}`, full[a]]));
|
|
27
|
+
return /* @__PURE__ */ jsx(ThemeContext.Provider, { value, children: /* @__PURE__ */ jsx("div", { ref, className, style, "data-wzl-theme": theme.name, ...attrs, children }) });
|
|
33
28
|
}
|
|
34
29
|
function useTheme() {
|
|
35
30
|
const ctx = useContext(ThemeContext);
|
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/react.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/react.tsx"],"names":[],"mappings":";;;;;AAcA,IAAM,YAAA,GAAe,cAAwC,IAAI,CAAA;AAuB1D,SAAS,aAAA,CAAc;AAAA,EAC5B,KAAA,GAAQ,WAAA;AAAA,EACR,SAAA;AAAA,EACA,SAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CAAA,EAA2C;AACzC,EAAA,MAAM,GAAA,GAAM,OAAuB,IAAI,CAAA;AACvC,EAAA,MAAM,IAAA,GAAO,UAAU,KAAK,CAAA;AAC5B,EAAA,MAAM,IAAA,GAAO,aAAA,CAAc,IAAA,EAAM,SAAS,CAAA;AAE1C,EAAA,MAAM,GAAA,GAAM,YAAA,CAAa,IAAA,EAAM,IAAI,CAAA;AAEnC,EAAA,MAAM,KAAA,GAAQ,OAAA;AAAA,IACZ,OAAO,EAAE,KAAA,EAAO,SAAA,EAAW,MAAM,QAAA,EAAU,YAAA,CAAa,KAAA,EAAO,IAAI,CAAA,EAAE,CAAA;AAAA;AAAA,IAErE,CAAC,OAAO,GAAG;AAAA,GACb;AAEA,EAAA,eAAA,CAAgB,MAAM;AACpB,IAAA,IAAI,IAAI,OAAA,EAAS,UAAA,CAAW,IAAI,OAAA,EAAS,KAAA,EAAO,MAAM,SAAS,CAAA;AAAA,EACjE,CAAA,EAAG,CAAC,KAAA,EAAO,KAAK,CAAC,CAAA;AAEjB,EAAA,MAAM,QAAQ,MAAA,CAAO,WAAA,CAAY,OAAO,IAAA,CAAK,IAAI,EAAE,GAAA,CAAI,CAAC,CAAA,KAAM,CAAC,YAAY,CAAC,CAAA,CAAA,EAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;AACzF,EAAA,2BACG,YAAA,CAAa,QAAA,EAAb,EAAsB,KAAA,EACrB,8BAAC,KAAA,EAAA,EAAI,GAAA,EAAU,SAAA,EAAsB,KAAA,EAAc,kBAAgB,KAAA,CAAM,IAAA,EAAO,GAAG,KAAA,EAChF,UACH,CAAA,EACF,CAAA;AAEJ;AAIO,SAAS,QAAA,GAA8B;AAC5C,EAAA,MAAM,GAAA,GAAM,WAAW,YAAY,CAAA;AACnC,EAAA,IAAI,CAAC,GAAA,EAAK,MAAM,IAAI,MAAM,gDAAgD,CAAA;AAC1E,EAAA,OAAO,GAAA;AACT;AASO,SAAS,gBAAA,GAA6C;AAC3D,EAAA,OAAO,WAAW,YAAY,CAAA;AAChC","file":"react.js","sourcesContent":["import React, { createContext, useContext, useMemo, useRef, useLayoutEffect } from 'react';\nimport { applyTheme } from './applyTheme';\nimport { fullSelection, selectionKey, type Selection } from './axes';\nimport { resolveTheme, themeAxes, type ResolvedTheme } from './resolveTheme';\nimport { weaselTheme, type Theme } from './theme';\n\n/** What `<ThemeProvider>` publishes: the theme, the full selection in force, and the\n * fully resolved token record for that pair. */\nexport interface ThemeContextValue {\n readonly theme: Theme;\n readonly selection: Selection;\n readonly resolved: ResolvedTheme;\n}\n\nconst ThemeContext = createContext<ThemeContextValue | null>(null);\n\n/** Props for `<ThemeProvider>`. */\nexport interface ThemeProviderProps {\n readonly theme?: Theme;\n /** Axis values, e.g. `{ mode: 'light' }`. A missing axis takes its default. */\n readonly selection?: Selection;\n /** Applied to the wrapper element, so it can be the layout element too. */\n readonly className?: string;\n readonly style?: React.CSSProperties;\n readonly children: React.ReactNode;\n}\n\n/**\n * Applies a theme to a wrapper element and publishes the resolved record.\n *\n * Consumers that draw outside the DOM (the WebGL HUD) read `resolved` and\n * never touch `getComputedStyle`.\n *\n * The wrapper is a real element in the layout. Pass `className` rather than\n * nesting your own div inside — an anonymous div between a flex parent and\n * its child breaks percentage heights.\n */\nexport function ThemeProvider({\n theme = weaselTheme,\n selection,\n className,\n style,\n children,\n}: ThemeProviderProps): React.ReactElement {\n const ref = useRef<HTMLDivElement>(null);\n const axes = themeAxes(theme);\n const full = fullSelection(axes, selection);\n // Keyed on the selection's content: callers pass a fresh object every render.\n const key = selectionKey(axes, full);\n\n const value = useMemo<ThemeContextValue>(\n () => ({ theme, selection: full, resolved: resolveTheme(theme, full) }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [theme, key],\n );\n\n useLayoutEffect(() => {\n if (ref.current) applyTheme(ref.current, theme, value.selection);\n }, [theme, value]);\n\n const attrs = Object.fromEntries(Object.keys(axes).map((a) => [`data-wzl-${a}`, full[a]]));\n return (\n <ThemeContext.Provider value={value}>\n <div ref={ref} className={className} style={style} data-wzl-theme={theme.name} {...attrs}>\n {children}\n </div>\n </ThemeContext.Provider>\n );\n}\n\n/** The theme in force. Throws outside a `<ThemeProvider>`; use\n * `useThemeOptional` where the provider is not guaranteed. */\nexport function useTheme(): ThemeContextValue {\n const ctx = useContext(ThemeContext);\n if (!ctx) throw new Error('useTheme must be used inside a <ThemeProvider>');\n return ctx;\n}\n\n/**\n * The theme if one is provided, `null` otherwise.\n *\n * For kit internals that should follow a theme when the app supplies one but\n * must still work in an app that never mounted a provider — `useHud` is the\n * motivating case.\n */\nexport function useThemeOptional(): ThemeContextValue | null {\n return useContext(ThemeContext);\n}\n"]}
|
|
@@ -1,37 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* A single design token as authored, before aliases are resolved: a DTCG-shaped
|
|
4
|
-
* `{ type, value }` pair where `value` may still be a `{ref}` to another token.
|
|
5
|
-
*/
|
|
6
|
-
interface RawToken {
|
|
7
|
-
readonly type: string;
|
|
8
|
-
readonly value: TokenValue;
|
|
9
|
-
/** Render the referenced color at this alpha, 0–1. */
|
|
10
|
-
readonly alpha?: number | undefined;
|
|
11
|
-
readonly description?: string | undefined;
|
|
12
|
-
}
|
|
13
|
-
/** A token graph flattened to one level, keyed by token name (no `--wzl-`
|
|
14
|
-
* prefix). Still unresolved — see `ResolvedTokenMap` for the output side. */
|
|
15
|
-
type FlatTokens = Record<string, RawToken>;
|
|
1
|
+
import { B as BakedTheme, b as AxisDefs, f as ThemeDefinition, T as Theme, S as Selection } from './theme-BtpBHcUg.js';
|
|
16
2
|
|
|
17
3
|
/** Every design token the built-in themes declare, spelled as the CSS
|
|
18
4
|
* custom property it becomes. */
|
|
19
|
-
type TokenName = '--wzl-accent' | '--wzl-accent-base' | '--wzl-accent-fg' | '--wzl-accent-hover' | '--wzl-accent-soft' | '--wzl-accent-strong' | '--wzl-backdrop' | '--wzl-border' | '--wzl-border-strong' | '--wzl-border-w' | '--wzl-control-h' | '--wzl-curve-color' | '--wzl-curve-width' | '--wzl-danger' | '--wzl-danger-base' | '--wzl-ease-in-cubic' | '--wzl-ease-in-out-cubic' | '--wzl-ease-out-back' | '--wzl-ease-out-cubic' | '--wzl-fg' | '--wzl-fg-inverse' | '--wzl-fg-muted' | '--wzl-fg-on-accent' | '--wzl-fg-subtle' | '--wzl-field-pad-x' | '--wzl-focus-ring' | '--wzl-font-body' | '--wzl-font-display' | '--wzl-font-mono' | '--wzl-font-size' | '--wzl-font-size-2xs' | '--wzl-font-size-lg' | '--wzl-font-size-sm' | '--wzl-font-size-xl' | '--wzl-font-size-xs' | '--wzl-font-ui' | '--wzl-font-weight-bold' | '--wzl-font-weight-light' | '--wzl-font-weight-medium' | '--wzl-font-weight-normal' | '--wzl-glass-blur' | '--wzl-glass-tint' | '--wzl-gray-100' | '--wzl-gray-200' | '--wzl-gray-300' | '--wzl-gray-400' | '--wzl-gray-50' | '--wzl-gray-500' | '--wzl-gray-600' | '--wzl-gray-700' | '--wzl-gray-800' | '--wzl-gray-900' | '--wzl-leading' | '--wzl-leading-snug' | '--wzl-leading-tight' | '--wzl-line' | '--wzl-line-strong' | '--wzl-line-subtle' | '--wzl-line-width' | '--wzl-motion-fast' | '--wzl-motion-medium' | '--wzl-radius-lg' | '--wzl-radius-md' | '--wzl-radius-pill' | '--wzl-radius-sm' | '--wzl-shadow' | '--wzl-slider-thumb-mix' | '--wzl-slider-thumb-size' | '--wzl-slider-track-h' | '--wzl-slider-track-mix' | '--wzl-space-lg' | '--wzl-space-md' | '--wzl-space-sm' | '--wzl-space-xs' | '--wzl-success' | '--wzl-success-base' | '--wzl-surface' | '--wzl-surface-hover' | '--wzl-surface-pressed' | '--wzl-surface-raised' | '--wzl-surface-sunken' | '--wzl-swatch-amber' | '--wzl-swatch-blue' | '--wzl-swatch-citron' | '--wzl-swatch-fuchsia' | '--wzl-swatch-green' | '--wzl-swatch-red' | '--wzl-swatch-rose' | '--wzl-swatch-sky' | '--wzl-swatch-teal' | '--wzl-swatch-violet' | '--wzl-tb-height' | '--wzl-tracking-none' | '--wzl-tracking-wide' | '--wzl-tracking-wider' | '--wzl-warning' | '--wzl-warning-base' | '--wzl-z-modal' | '--wzl-z-overlay' | '--wzl-z-toolbar';
|
|
20
|
-
/** A built-in theme with its aliases already collapsed: every
|
|
21
|
-
*
|
|
5
|
+
type TokenName = '--wzl-accent' | '--wzl-accent-base' | '--wzl-accent-fg' | '--wzl-accent-hover' | '--wzl-accent-soft' | '--wzl-accent-strong' | '--wzl-backdrop' | '--wzl-border' | '--wzl-border-strong' | '--wzl-border-w' | '--wzl-control-h' | '--wzl-curve-color' | '--wzl-curve-width' | '--wzl-danger' | '--wzl-danger-base' | '--wzl-ease-in-cubic' | '--wzl-ease-in-out-cubic' | '--wzl-ease-out-back' | '--wzl-ease-out-cubic' | '--wzl-fg' | '--wzl-fg-inverse' | '--wzl-fg-muted' | '--wzl-fg-on-accent' | '--wzl-fg-subtle' | '--wzl-field-pad-x' | '--wzl-focus-ring' | '--wzl-font-body' | '--wzl-font-display' | '--wzl-font-mono' | '--wzl-font-size' | '--wzl-font-size-2xs' | '--wzl-font-size-lg' | '--wzl-font-size-sm' | '--wzl-font-size-xl' | '--wzl-font-size-xs' | '--wzl-font-ui' | '--wzl-font-weight-bold' | '--wzl-font-weight-light' | '--wzl-font-weight-medium' | '--wzl-font-weight-normal' | '--wzl-glass-blur' | '--wzl-glass-tint' | '--wzl-gray-100' | '--wzl-gray-200' | '--wzl-gray-300' | '--wzl-gray-400' | '--wzl-gray-50' | '--wzl-gray-500' | '--wzl-gray-600' | '--wzl-gray-700' | '--wzl-gray-800' | '--wzl-gray-900' | '--wzl-handle-size' | '--wzl-handle-size-lg' | '--wzl-handle-size-sm' | '--wzl-leading' | '--wzl-leading-snug' | '--wzl-leading-tight' | '--wzl-line' | '--wzl-line-strong' | '--wzl-line-subtle' | '--wzl-line-width' | '--wzl-motion-fast' | '--wzl-motion-medium' | '--wzl-radius-lg' | '--wzl-radius-md' | '--wzl-radius-pill' | '--wzl-radius-sm' | '--wzl-shadow' | '--wzl-slider-thumb-mix' | '--wzl-slider-thumb-size' | '--wzl-slider-track-h' | '--wzl-slider-track-mix' | '--wzl-space-lg' | '--wzl-space-md' | '--wzl-space-sm' | '--wzl-space-xs' | '--wzl-success' | '--wzl-success-base' | '--wzl-surface' | '--wzl-surface-hover' | '--wzl-surface-pressed' | '--wzl-surface-raised' | '--wzl-surface-sunken' | '--wzl-swatch-amber' | '--wzl-swatch-blue' | '--wzl-swatch-citron' | '--wzl-swatch-fuchsia' | '--wzl-swatch-green' | '--wzl-swatch-red' | '--wzl-swatch-rose' | '--wzl-swatch-sky' | '--wzl-swatch-teal' | '--wzl-swatch-violet' | '--wzl-tb-height' | '--wzl-tracking-none' | '--wzl-tracking-wide' | '--wzl-tracking-wider' | '--wzl-warning' | '--wzl-warning-base' | '--wzl-z-modal' | '--wzl-z-overlay' | '--wzl-z-toolbar';
|
|
6
|
+
/** A built-in theme with its aliases already collapsed: every selection
|
|
7
|
+
* (keyed `mode=dark`, axes in declaration order) maps every token name to
|
|
8
|
+
* a final CSS value. */
|
|
22
9
|
interface GeneratedTheme {
|
|
23
10
|
readonly name: string;
|
|
24
|
-
readonly
|
|
25
|
-
readonly
|
|
11
|
+
readonly axes: AxisDefs;
|
|
12
|
+
readonly selections: Readonly<Record<string, Readonly<Record<TokenName, string>>>>;
|
|
26
13
|
}
|
|
27
14
|
/** The built-in themes, resolved, keyed by theme name. Read this to list
|
|
28
15
|
* or preview themes without resolving a token graph yourself. */
|
|
29
16
|
declare const THEMES: {
|
|
30
17
|
readonly weasel: {
|
|
31
18
|
readonly name: "weasel";
|
|
32
|
-
readonly
|
|
33
|
-
|
|
34
|
-
|
|
19
|
+
readonly axes: {
|
|
20
|
+
readonly mode: {
|
|
21
|
+
readonly default: "dark";
|
|
22
|
+
readonly values: {
|
|
23
|
+
readonly dark: {
|
|
24
|
+
readonly scheme: "dark";
|
|
25
|
+
};
|
|
26
|
+
readonly light: {
|
|
27
|
+
readonly scheme: "light";
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
readonly selections: {
|
|
33
|
+
readonly 'mode=dark': {
|
|
35
34
|
readonly '--wzl-gray-50': "#f5f5f6";
|
|
36
35
|
readonly '--wzl-gray-100': "#e6e7e9";
|
|
37
36
|
readonly '--wzl-gray-200': "#c9cbcf";
|
|
@@ -45,11 +44,31 @@ declare const THEMES: {
|
|
|
45
44
|
readonly '--wzl-accent-soft': "#1d1454";
|
|
46
45
|
readonly '--wzl-accent-base': "#2e1f7a";
|
|
47
46
|
readonly '--wzl-accent-strong': "#5841b8";
|
|
47
|
+
readonly '--wzl-swatch-fuchsia': "#f641f7";
|
|
48
|
+
readonly '--wzl-swatch-green': "#48e628";
|
|
49
|
+
readonly '--wzl-swatch-sky': "#36bff2";
|
|
50
|
+
readonly '--wzl-swatch-amber': "#e69628";
|
|
51
|
+
readonly '--wzl-swatch-teal': "#3ee1cb";
|
|
52
|
+
readonly '--wzl-swatch-red': "#f75034";
|
|
53
|
+
readonly '--wzl-swatch-blue': "#407ef7";
|
|
54
|
+
readonly '--wzl-swatch-citron': "#d5d23a";
|
|
55
|
+
readonly '--wzl-swatch-rose': "#fa4590";
|
|
56
|
+
readonly '--wzl-swatch-violet': "#955cf9";
|
|
57
|
+
readonly '--wzl-surface': "#181a1e";
|
|
58
|
+
readonly '--wzl-surface-raised': "#25272c";
|
|
59
|
+
readonly '--wzl-surface-sunken': "#0e0f12";
|
|
60
|
+
readonly '--wzl-fg': "#e6e7e9";
|
|
61
|
+
readonly '--wzl-fg-muted': "#9ea1a8";
|
|
62
|
+
readonly '--wzl-fg-subtle': "#6f737b";
|
|
63
|
+
readonly '--wzl-border': "#25272c";
|
|
64
|
+
readonly '--wzl-border-strong': "#6f737b";
|
|
65
|
+
readonly '--wzl-accent-fg': "#5841b8";
|
|
66
|
+
readonly '--wzl-fg-inverse': "#0e0f12";
|
|
67
|
+
readonly '--wzl-shadow': "rgba(0, 0, 0, 0.6)";
|
|
48
68
|
readonly '--wzl-danger-base': "#d94a3f";
|
|
49
69
|
readonly '--wzl-warning-base': "#d99a3f";
|
|
50
70
|
readonly '--wzl-success-base': "#2ec27e";
|
|
51
71
|
readonly '--wzl-fg-on-accent': "#f5f5f6";
|
|
52
|
-
readonly '--wzl-fg': "#e6e7e9";
|
|
53
72
|
readonly '--wzl-line-subtle': "rgba(230, 231, 233, 0.1)";
|
|
54
73
|
readonly '--wzl-line': "rgba(230, 231, 233, 0.2)";
|
|
55
74
|
readonly '--wzl-line-strong': "rgba(230, 231, 233, 0.4)";
|
|
@@ -63,16 +82,6 @@ declare const THEMES: {
|
|
|
63
82
|
readonly '--wzl-glass-tint': "#2e1f7a";
|
|
64
83
|
readonly '--wzl-surface-hover': "rgba(230, 231, 233, 0.1)";
|
|
65
84
|
readonly '--wzl-surface-pressed': "rgba(230, 231, 233, 0.18)";
|
|
66
|
-
readonly '--wzl-swatch-fuchsia': "#f641f7";
|
|
67
|
-
readonly '--wzl-swatch-green': "#48e628";
|
|
68
|
-
readonly '--wzl-swatch-sky': "#36bff2";
|
|
69
|
-
readonly '--wzl-swatch-amber': "#e69628";
|
|
70
|
-
readonly '--wzl-swatch-teal': "#3ee1cb";
|
|
71
|
-
readonly '--wzl-swatch-red': "#f75034";
|
|
72
|
-
readonly '--wzl-swatch-blue': "#407ef7";
|
|
73
|
-
readonly '--wzl-swatch-citron': "#d5d23a";
|
|
74
|
-
readonly '--wzl-swatch-rose': "#fa4590";
|
|
75
|
-
readonly '--wzl-swatch-violet': "#955cf9";
|
|
76
85
|
readonly '--wzl-radius-sm': "3px";
|
|
77
86
|
readonly '--wzl-radius-md': "5px";
|
|
78
87
|
readonly '--wzl-radius-lg': "14px";
|
|
@@ -86,6 +95,9 @@ declare const THEMES: {
|
|
|
86
95
|
readonly '--wzl-slider-thumb-size': "8px";
|
|
87
96
|
readonly '--wzl-slider-track-mix': "18%";
|
|
88
97
|
readonly '--wzl-slider-thumb-mix': "70%";
|
|
98
|
+
readonly '--wzl-handle-size': "9px";
|
|
99
|
+
readonly '--wzl-handle-size-sm': "7px";
|
|
100
|
+
readonly '--wzl-handle-size-lg': "10px";
|
|
89
101
|
readonly '--wzl-field-pad-x': "8px";
|
|
90
102
|
readonly '--wzl-glass-blur': "3px";
|
|
91
103
|
readonly '--wzl-font-size-2xs': "9px";
|
|
@@ -122,18 +134,8 @@ declare const THEMES: {
|
|
|
122
134
|
readonly '--wzl-font-weight-normal': "300";
|
|
123
135
|
readonly '--wzl-font-weight-medium': "350";
|
|
124
136
|
readonly '--wzl-font-weight-bold': "400";
|
|
125
|
-
readonly '--wzl-surface': "#181a1e";
|
|
126
|
-
readonly '--wzl-surface-raised': "#25272c";
|
|
127
|
-
readonly '--wzl-surface-sunken': "#0e0f12";
|
|
128
|
-
readonly '--wzl-fg-muted': "#9ea1a8";
|
|
129
|
-
readonly '--wzl-fg-subtle': "#6f737b";
|
|
130
|
-
readonly '--wzl-border': "#25272c";
|
|
131
|
-
readonly '--wzl-border-strong': "#6f737b";
|
|
132
|
-
readonly '--wzl-accent-fg': "#5841b8";
|
|
133
|
-
readonly '--wzl-fg-inverse': "#0e0f12";
|
|
134
|
-
readonly '--wzl-shadow': "rgba(0, 0, 0, 0.6)";
|
|
135
137
|
};
|
|
136
|
-
readonly light: {
|
|
138
|
+
readonly 'mode=light': {
|
|
137
139
|
readonly '--wzl-gray-50': "#f5f5f6";
|
|
138
140
|
readonly '--wzl-gray-100': "#e6e7e9";
|
|
139
141
|
readonly '--wzl-gray-200': "#c9cbcf";
|
|
@@ -147,11 +149,31 @@ declare const THEMES: {
|
|
|
147
149
|
readonly '--wzl-accent-soft': "#1d1454";
|
|
148
150
|
readonly '--wzl-accent-base': "#2e1f7a";
|
|
149
151
|
readonly '--wzl-accent-strong': "#5841b8";
|
|
152
|
+
readonly '--wzl-swatch-fuchsia': "#f641f7";
|
|
153
|
+
readonly '--wzl-swatch-green': "#48e628";
|
|
154
|
+
readonly '--wzl-swatch-sky': "#36bff2";
|
|
155
|
+
readonly '--wzl-swatch-amber': "#e69628";
|
|
156
|
+
readonly '--wzl-swatch-teal': "#3ee1cb";
|
|
157
|
+
readonly '--wzl-swatch-red': "#f75034";
|
|
158
|
+
readonly '--wzl-swatch-blue': "#407ef7";
|
|
159
|
+
readonly '--wzl-swatch-citron': "#d5d23a";
|
|
160
|
+
readonly '--wzl-swatch-rose': "#fa4590";
|
|
161
|
+
readonly '--wzl-swatch-violet': "#955cf9";
|
|
162
|
+
readonly '--wzl-surface': "#f5f5f6";
|
|
163
|
+
readonly '--wzl-surface-raised': "#e6e7e9";
|
|
164
|
+
readonly '--wzl-surface-sunken': "#c9cbcf";
|
|
165
|
+
readonly '--wzl-fg': "#0e0f12";
|
|
166
|
+
readonly '--wzl-fg-muted': "#383b42";
|
|
167
|
+
readonly '--wzl-fg-subtle': "#4d5058";
|
|
168
|
+
readonly '--wzl-border': "#c9cbcf";
|
|
169
|
+
readonly '--wzl-border-strong': "#4d5058";
|
|
170
|
+
readonly '--wzl-accent-fg': "#2e1f7a";
|
|
171
|
+
readonly '--wzl-fg-inverse': "#f5f5f6";
|
|
172
|
+
readonly '--wzl-shadow': "rgba(0, 0, 0, 0.18)";
|
|
150
173
|
readonly '--wzl-danger-base': "#d94a3f";
|
|
151
174
|
readonly '--wzl-warning-base': "#d99a3f";
|
|
152
175
|
readonly '--wzl-success-base': "#2ec27e";
|
|
153
176
|
readonly '--wzl-fg-on-accent': "#f5f5f6";
|
|
154
|
-
readonly '--wzl-fg': "#0e0f12";
|
|
155
177
|
readonly '--wzl-line-subtle': "rgba(14, 15, 18, 0.1)";
|
|
156
178
|
readonly '--wzl-line': "rgba(14, 15, 18, 0.2)";
|
|
157
179
|
readonly '--wzl-line-strong': "rgba(14, 15, 18, 0.4)";
|
|
@@ -165,16 +187,6 @@ declare const THEMES: {
|
|
|
165
187
|
readonly '--wzl-glass-tint': "#2e1f7a";
|
|
166
188
|
readonly '--wzl-surface-hover': "rgba(14, 15, 18, 0.1)";
|
|
167
189
|
readonly '--wzl-surface-pressed': "rgba(14, 15, 18, 0.18)";
|
|
168
|
-
readonly '--wzl-swatch-fuchsia': "#f641f7";
|
|
169
|
-
readonly '--wzl-swatch-green': "#48e628";
|
|
170
|
-
readonly '--wzl-swatch-sky': "#36bff2";
|
|
171
|
-
readonly '--wzl-swatch-amber': "#e69628";
|
|
172
|
-
readonly '--wzl-swatch-teal': "#3ee1cb";
|
|
173
|
-
readonly '--wzl-swatch-red': "#f75034";
|
|
174
|
-
readonly '--wzl-swatch-blue': "#407ef7";
|
|
175
|
-
readonly '--wzl-swatch-citron': "#d5d23a";
|
|
176
|
-
readonly '--wzl-swatch-rose': "#fa4590";
|
|
177
|
-
readonly '--wzl-swatch-violet': "#955cf9";
|
|
178
190
|
readonly '--wzl-radius-sm': "3px";
|
|
179
191
|
readonly '--wzl-radius-md': "5px";
|
|
180
192
|
readonly '--wzl-radius-lg': "14px";
|
|
@@ -188,6 +200,9 @@ declare const THEMES: {
|
|
|
188
200
|
readonly '--wzl-slider-thumb-size': "8px";
|
|
189
201
|
readonly '--wzl-slider-track-mix': "18%";
|
|
190
202
|
readonly '--wzl-slider-thumb-mix': "70%";
|
|
203
|
+
readonly '--wzl-handle-size': "9px";
|
|
204
|
+
readonly '--wzl-handle-size-sm': "7px";
|
|
205
|
+
readonly '--wzl-handle-size-lg': "10px";
|
|
191
206
|
readonly '--wzl-field-pad-x': "8px";
|
|
192
207
|
readonly '--wzl-glass-blur': "3px";
|
|
193
208
|
readonly '--wzl-font-size-2xs': "9px";
|
|
@@ -224,73 +239,28 @@ declare const THEMES: {
|
|
|
224
239
|
readonly '--wzl-font-weight-normal': "300";
|
|
225
240
|
readonly '--wzl-font-weight-medium': "350";
|
|
226
241
|
readonly '--wzl-font-weight-bold': "400";
|
|
227
|
-
readonly '--wzl-surface': "#f5f5f6";
|
|
228
|
-
readonly '--wzl-surface-raised': "#e6e7e9";
|
|
229
|
-
readonly '--wzl-surface-sunken': "#c9cbcf";
|
|
230
|
-
readonly '--wzl-fg-muted': "#383b42";
|
|
231
|
-
readonly '--wzl-fg-subtle': "#4d5058";
|
|
232
|
-
readonly '--wzl-border': "#c9cbcf";
|
|
233
|
-
readonly '--wzl-border-strong': "#4d5058";
|
|
234
|
-
readonly '--wzl-accent-fg': "#2e1f7a";
|
|
235
|
-
readonly '--wzl-fg-inverse': "#f5f5f6";
|
|
236
|
-
readonly '--wzl-shadow': "rgba(0, 0, 0, 0.18)";
|
|
237
242
|
};
|
|
238
243
|
};
|
|
239
244
|
};
|
|
240
245
|
};
|
|
241
|
-
/**
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
247
|
-
/** The same built-in themes as `THEMES`, unresolved. This is what
|
|
248
|
-
* `defineTheme` layers onto. */
|
|
249
|
-
declare const THEME_SOURCES: Readonly<Record<string, ThemeSource>>;
|
|
250
|
-
|
|
251
|
-
/** Authoring shorthand: a bare string is a literal or a `{ref}`. */
|
|
252
|
-
type TokenInput = string | number | RawToken;
|
|
253
|
-
/** What `defineTheme` accepts: a name, the base theme to layer onto, and the
|
|
254
|
-
* token overrides, split into mode-invariant and per-mode. */
|
|
255
|
-
interface ThemeInput {
|
|
256
|
-
readonly name: string;
|
|
257
|
-
/** Base to layer onto. Defaults to `weaselTheme`; `null` opts out. */
|
|
258
|
-
readonly extends?: Theme | null;
|
|
259
|
-
readonly defaultMode?: string;
|
|
260
|
-
/** Mode-invariant overrides. */
|
|
261
|
-
readonly tokens?: Readonly<Record<string, TokenInput>>;
|
|
262
|
-
readonly modes: Readonly<Record<string, Readonly<Record<string, TokenInput>>>>;
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* A theme: a named set of design tokens, organized into a mode-invariant layer
|
|
266
|
-
* plus one layer per mode (light, dark, …), optionally extending another theme.
|
|
267
|
-
* Tokens are held unresolved — aliases between them are collapsed later by
|
|
268
|
-
* `resolveTheme`, so an override of a base primitive still reaches everything
|
|
269
|
-
* that references it.
|
|
270
|
-
*/
|
|
271
|
-
interface Theme {
|
|
272
|
-
readonly name: string;
|
|
273
|
-
readonly extends: Theme | null;
|
|
274
|
-
readonly defaultMode: string;
|
|
275
|
-
readonly tokens: FlatTokens;
|
|
276
|
-
readonly modes: Readonly<Record<string, FlatTokens>>;
|
|
277
|
-
}
|
|
278
|
-
/** The built-in theme, materialized from the generated source. */
|
|
279
|
-
declare const weaselTheme: Theme;
|
|
280
|
-
/** Build a theme from authoring shorthand. Unless `extends` says otherwise the
|
|
281
|
-
* result layers onto `weaselTheme`, so a theme only needs to name what it
|
|
282
|
-
* changes. */
|
|
283
|
-
declare function defineTheme(input: ThemeInput): Theme;
|
|
246
|
+
/** The built-in themes as authored: their unbaked definitions. */
|
|
247
|
+
declare const THEME_SOURCES: Readonly<Record<string, ThemeDefinition>>;
|
|
248
|
+
/** The built-in themes with every rule run and references intact. This is
|
|
249
|
+
* what `weaselTheme` is built from, so the runtime entry bundles no generator. */
|
|
250
|
+
declare const BAKED_THEMES: Readonly<Record<string, BakedTheme>>;
|
|
284
251
|
|
|
285
|
-
/** The output of `resolveTheme`: every token of a theme, for one
|
|
252
|
+
/** The output of `resolveTheme`: every token of a theme, for one selection, keyed
|
|
286
253
|
* by CSS custom-property name and flattened to a final CSS value. */
|
|
287
254
|
type ResolvedTheme = Readonly<Record<TokenName, string>>;
|
|
255
|
+
/** Every axis the chain declares. An axis declared more than once keeps every value; a descendant's value entries and default win. */
|
|
256
|
+
declare function themeAxes(theme: Theme): AxisDefs;
|
|
288
257
|
/**
|
|
289
|
-
* Merge the extends chain
|
|
290
|
-
*
|
|
258
|
+
* Merge the extends chain at a selection, resolve every alias, and key the
|
|
259
|
+
* result by CSS custom-property name. A missing or unknown axis value takes the
|
|
260
|
+
* axis default.
|
|
291
261
|
*
|
|
292
262
|
* Pure — no DOM. An unresolvable reference throws rather than falling back.
|
|
293
263
|
*/
|
|
294
|
-
declare function resolveTheme(theme: Theme,
|
|
264
|
+
declare function resolveTheme(theme: Theme, selection?: Selection): ResolvedTheme;
|
|
295
265
|
|
|
296
|
-
export {
|
|
266
|
+
export { BAKED_THEMES as B, type GeneratedTheme as G, type ResolvedTheme as R, type TokenName as T, THEMES as a, THEME_SOURCES as b, resolveTheme as r, themeAxes as t };
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/** One value of an axis. `scheme` becomes `color-scheme` in that value's CSS blocks. */
|
|
2
|
+
interface AxisValue {
|
|
3
|
+
readonly scheme?: 'dark' | 'light';
|
|
4
|
+
}
|
|
5
|
+
interface AxisDef {
|
|
6
|
+
readonly default: string;
|
|
7
|
+
readonly values: Readonly<Record<string, AxisValue>>;
|
|
8
|
+
}
|
|
9
|
+
/** Key order is declaration order, which selectors and selection keys follow. */
|
|
10
|
+
type AxisDefs = Readonly<Record<string, AxisDef>>;
|
|
11
|
+
/** A partial choice of axis values, e.g. `{ mode: 'light' }`. */
|
|
12
|
+
type Selection = Readonly<Record<string, string>>;
|
|
13
|
+
/** `{ by: 'mode', dark: …, light: … }`: a value that differs per axis value. */
|
|
14
|
+
interface ByAxis<T> {
|
|
15
|
+
readonly by: string;
|
|
16
|
+
readonly [axisValue: string]: Varying<T> | string;
|
|
17
|
+
}
|
|
18
|
+
type Varying<T> = T | ByAxis<T>;
|
|
19
|
+
declare function isByAxis(v: unknown): v is ByAxis<unknown>;
|
|
20
|
+
/** Every axis given a known value; anything missing or unknown takes its default. */
|
|
21
|
+
declare function fullSelection(axes: AxisDefs, selection?: Selection): Selection;
|
|
22
|
+
declare function enumerateSelections(axes: AxisDefs): Selection[];
|
|
23
|
+
/** `mode=dark,density=compact`, axes in declaration order. */
|
|
24
|
+
declare function selectionKey(axes: AxisDefs, selection: Selection): string;
|
|
25
|
+
|
|
26
|
+
type TokenValue = string | number | readonly (string | number)[];
|
|
27
|
+
/**
|
|
28
|
+
* A single design token as authored, before aliases are resolved: a DTCG-shaped
|
|
29
|
+
* `{ type, value }` pair where `value` may still be a `{ref}` to another token.
|
|
30
|
+
*/
|
|
31
|
+
interface RawToken {
|
|
32
|
+
readonly type: string;
|
|
33
|
+
readonly value: TokenValue;
|
|
34
|
+
/** Render the referenced color at this alpha, 0–1. */
|
|
35
|
+
readonly alpha?: number | undefined;
|
|
36
|
+
readonly description?: string | undefined;
|
|
37
|
+
}
|
|
38
|
+
/** A token graph flattened to one level, keyed by token name (no `--wzl-`
|
|
39
|
+
* prefix). Still unresolved — see `ResolvedTokenMap` for the output side. */
|
|
40
|
+
type FlatTokens = Record<string, RawToken>;
|
|
41
|
+
|
|
42
|
+
/** A number, or `{seeds.name}`. */
|
|
43
|
+
type NumberParam = Varying<number | string>;
|
|
44
|
+
interface PinObject {
|
|
45
|
+
readonly value: TokenValue;
|
|
46
|
+
readonly type?: string;
|
|
47
|
+
readonly description?: string;
|
|
48
|
+
readonly alpha?: number;
|
|
49
|
+
}
|
|
50
|
+
/** A bare value or `{ value, type?, description?, alpha? }`. The value may be a `{token}` reference. */
|
|
51
|
+
type PinValue = TokenValue | PinObject;
|
|
52
|
+
interface LightnessRampDef {
|
|
53
|
+
readonly kind: 'lightness';
|
|
54
|
+
readonly steps: Varying<readonly string[]>;
|
|
55
|
+
/** First and last step's OKLCH lightness. */
|
|
56
|
+
readonly lightness: Varying<readonly [NumberParam, NumberParam]>;
|
|
57
|
+
/** 0 walks evenly; 1 follows a smoothstep S. */
|
|
58
|
+
readonly curve?: NumberParam;
|
|
59
|
+
/** Degrees. Ignored when an anchor is given. */
|
|
60
|
+
readonly hue?: NumberParam;
|
|
61
|
+
readonly chroma?: Varying<{
|
|
62
|
+
readonly peak: NumberParam;
|
|
63
|
+
readonly lightBias?: NumberParam;
|
|
64
|
+
readonly darkBias?: NumberParam;
|
|
65
|
+
}>;
|
|
66
|
+
/** Step name → exact hex (or `{seeds.name}`). The first anchor supplies hue and chroma. */
|
|
67
|
+
readonly anchor?: Varying<Readonly<Record<string, Varying<string>>>>;
|
|
68
|
+
readonly description?: string;
|
|
69
|
+
readonly describe?: Readonly<Record<string, string>>;
|
|
70
|
+
}
|
|
71
|
+
interface CategoricalRampDef {
|
|
72
|
+
readonly kind: 'categorical';
|
|
73
|
+
readonly steps: Varying<readonly string[]>;
|
|
74
|
+
/** Any of the palette generator's `Constraints` except `count` and `anchors`. */
|
|
75
|
+
readonly gates?: Varying<Readonly<Record<string, Varying<number | string>>>>;
|
|
76
|
+
readonly anchors?: readonly {
|
|
77
|
+
readonly name: string;
|
|
78
|
+
readonly hue: number;
|
|
79
|
+
readonly lightness: number;
|
|
80
|
+
readonly chroma?: number;
|
|
81
|
+
}[];
|
|
82
|
+
readonly description?: string;
|
|
83
|
+
readonly describe?: Readonly<Record<string, string>>;
|
|
84
|
+
}
|
|
85
|
+
type RampDef = LightnessRampDef | CategoricalRampDef;
|
|
86
|
+
interface ScaleDef {
|
|
87
|
+
readonly steps: Varying<readonly string[]>;
|
|
88
|
+
readonly base: NumberParam;
|
|
89
|
+
/** Linear: `base + step × i`. */
|
|
90
|
+
readonly step?: NumberParam;
|
|
91
|
+
/** Geometric: `base × ratio^i`. */
|
|
92
|
+
readonly ratio?: NumberParam;
|
|
93
|
+
readonly description?: string;
|
|
94
|
+
readonly describe?: Readonly<Record<string, string>>;
|
|
95
|
+
}
|
|
96
|
+
interface SemanticCommon {
|
|
97
|
+
readonly type?: string;
|
|
98
|
+
readonly description?: string;
|
|
99
|
+
/** Audited, never applied. */
|
|
100
|
+
readonly check?: {
|
|
101
|
+
readonly contrast: number;
|
|
102
|
+
readonly against: readonly string[];
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
type StepRule = SemanticCommon & {
|
|
106
|
+
readonly ramp: string;
|
|
107
|
+
readonly step: Varying<string>;
|
|
108
|
+
};
|
|
109
|
+
type OffsetRule = SemanticCommon & {
|
|
110
|
+
readonly from: string;
|
|
111
|
+
readonly offset: number;
|
|
112
|
+
readonly dir: 'lighter' | 'darker' | 'away';
|
|
113
|
+
};
|
|
114
|
+
type ContrastRule = SemanticCommon & {
|
|
115
|
+
readonly ramp: string;
|
|
116
|
+
readonly contrast: {
|
|
117
|
+
readonly min: number;
|
|
118
|
+
readonly against: readonly string[];
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
type RefRule = SemanticCommon & {
|
|
122
|
+
readonly ref: string;
|
|
123
|
+
readonly alpha?: number;
|
|
124
|
+
};
|
|
125
|
+
type LiteralRule = SemanticCommon & {
|
|
126
|
+
readonly value: TokenValue;
|
|
127
|
+
};
|
|
128
|
+
type SemanticRule = StepRule | OffsetRule | ContrastRule | RefRule | LiteralRule;
|
|
129
|
+
interface ThemeDefinition {
|
|
130
|
+
readonly name: string;
|
|
131
|
+
/** Another definition's name. Absent or null: extends nothing. */
|
|
132
|
+
readonly extends?: string | null;
|
|
133
|
+
readonly description?: string;
|
|
134
|
+
readonly axes?: AxisDefs;
|
|
135
|
+
readonly seeds?: Readonly<Record<string, Varying<number | string>>>;
|
|
136
|
+
readonly ramps?: Readonly<Record<string, RampDef>>;
|
|
137
|
+
readonly scales?: Readonly<Record<string, ScaleDef>>;
|
|
138
|
+
readonly semantics?: Readonly<Record<string, Varying<SemanticRule>>>;
|
|
139
|
+
readonly components?: Readonly<Record<string, Varying<PinValue>>>;
|
|
140
|
+
readonly pins?: Readonly<Record<string, Varying<PinValue>>>;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
type Lookup = (name: string) => ThemeDefinition | undefined;
|
|
144
|
+
/** The definition with its whole `extends` chain folded in, child entries winning. */
|
|
145
|
+
declare function mergeChain(def: ThemeDefinition, lookup?: Lookup, seen?: ReadonlySet<string>): ThemeDefinition;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* A definition with every rule run: plain or `by`-varying tokens, references intact.
|
|
149
|
+
* A branch `derive` could not produce is left out, so at runtime it falls through to the parent; definitions with
|
|
150
|
+
* issues still bake, because the editor bakes mid-edit and the build refuses them before baking. Cycles and dangling
|
|
151
|
+
* references still throw, as they do in `derive`.
|
|
152
|
+
*/
|
|
153
|
+
interface BakedTheme {
|
|
154
|
+
readonly name: string;
|
|
155
|
+
readonly extends: string | null;
|
|
156
|
+
readonly axes: AxisDefs;
|
|
157
|
+
/** In layer order, then definition order. */
|
|
158
|
+
readonly tokens: Readonly<Record<string, Varying<RawToken>>>;
|
|
159
|
+
}
|
|
160
|
+
/** Derive `definition` at every selection and fold the results into one record of tokens with no rules left. */
|
|
161
|
+
declare function bake(definition: ThemeDefinition, lookup?: Lookup): BakedTheme;
|
|
162
|
+
/** `definition` and every theme it extends, baked, root first. */
|
|
163
|
+
declare function bakeChain(definition: ThemeDefinition, lookup?: Lookup): BakedTheme[];
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* A theme ready to resolve: its axes and its tokens, each plain or varying by
|
|
167
|
+
* axis, references intact. A `by` that leaves a value out contributes nothing
|
|
168
|
+
* for that selection, so the theme it extends supplies it.
|
|
169
|
+
*/
|
|
170
|
+
interface Theme {
|
|
171
|
+
readonly name: string;
|
|
172
|
+
readonly extends: Theme | null;
|
|
173
|
+
readonly axes: AxisDefs;
|
|
174
|
+
readonly tokens: Readonly<Record<string, Varying<RawToken>>>;
|
|
175
|
+
}
|
|
176
|
+
/** What `defineTheme` accepts: a definition whose `extends` is a `Theme`, holding pins and components only. */
|
|
177
|
+
type ThemeInput = Omit<ThemeDefinition, 'extends'> & {
|
|
178
|
+
readonly extends?: Theme | null;
|
|
179
|
+
};
|
|
180
|
+
/** The built-in theme, from the baked output of themes/weasel.json. */
|
|
181
|
+
declare const weaselTheme: Theme;
|
|
182
|
+
/**
|
|
183
|
+
* Build a theme from pins. Unless `extends` says otherwise the result layers
|
|
184
|
+
* onto `weaselTheme`, so a theme only names what it changes. A definition with
|
|
185
|
+
* seeds, ramps, scales or semantics needs deriving first.
|
|
186
|
+
*/
|
|
187
|
+
declare function defineTheme(input: ThemeInput): Theme;
|
|
188
|
+
|
|
189
|
+
export { type AxisDef as A, type BakedTheme as B, type CategoricalRampDef as C, type FlatTokens as F, type Lookup as L, type NumberParam as N, type OffsetRule as O, type PinObject as P, type RawToken as R, type Selection as S, type Theme as T, type Varying as V, type TokenValue as a, type AxisDefs as b, type AxisValue as c, type ByAxis as d, type PinValue as e, type ThemeDefinition as f, type ThemeInput as g, defineTheme as h, enumerateSelections as i, fullSelection as j, isByAxis as k, type ContrastRule as l, type LightnessRampDef as m, type LiteralRule as n, type RampDef as o, type RefRule as p, type ScaleDef as q, type SemanticRule as r, selectionKey as s, type StepRule as t, bake as u, bakeChain as v, weaselTheme as w, mergeChain as x };
|