@skdx/tokens 0.27.0 → 0.29.0
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/LICENSE +21 -0
- package/README.md +92 -69
- package/dist/foundation.css +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/themes/AntDark.cjs +1 -1
- package/dist/themes/AntDark.d.cts +3 -12
- package/dist/themes/AntDark.d.ts +3 -12
- package/dist/themes/AntDark.js +1 -1
- package/dist/themes/{AntBrand.cjs → AntLight.cjs} +1 -1
- package/dist/themes/{AntBrand.d.cts → AntLight.d.cts} +1 -1
- package/dist/themes/{AntBrand.d.ts → AntLight.d.ts} +1 -1
- package/dist/themes/{AntBrand.js → AntLight.js} +1 -1
- package/dist/themes/CatppuccinLatte.cjs +1 -1
- package/dist/themes/CatppuccinLatte.d.cts +1 -7
- package/dist/themes/CatppuccinLatte.d.ts +1 -7
- package/dist/themes/CatppuccinLatte.js +1 -1
- package/dist/themes/CatppuccinMocha.cjs +1 -1
- package/dist/themes/CatppuccinMocha.d.cts +1 -7
- package/dist/themes/CatppuccinMocha.d.ts +1 -7
- package/dist/themes/CatppuccinMocha.js +1 -1
- package/dist/themes/ChakraDark.cjs +1 -1
- package/dist/themes/ChakraDark.d.cts +3 -12
- package/dist/themes/ChakraDark.d.ts +3 -12
- package/dist/themes/ChakraDark.js +1 -1
- package/dist/themes/{ChakraBrand.cjs → ChakraLight.cjs} +1 -1
- package/dist/themes/{ChakraBrand.d.cts → ChakraLight.d.cts} +1 -1
- package/dist/themes/{ChakraBrand.d.ts → ChakraLight.d.ts} +1 -1
- package/dist/themes/{ChakraBrand.js → ChakraLight.js} +1 -1
- package/dist/themes/CupcakeDark.cjs +1 -1
- package/dist/themes/CupcakeDark.d.cts +3 -5
- package/dist/themes/CupcakeDark.d.ts +3 -5
- package/dist/themes/CupcakeLight.cjs +1 -1
- package/dist/themes/CupcakeLight.d.cts +1 -8
- package/dist/themes/CupcakeLight.d.ts +1 -8
- package/dist/themes/CupcakeLight.js +1 -1
- package/dist/themes/DefaultTheme.cjs +1 -1
- package/dist/themes/DefaultTheme.d.cts +3 -15
- package/dist/themes/DefaultTheme.d.ts +3 -15
- package/dist/themes/DefaultTheme.js +1 -1
- package/dist/themes/DraculaLight.cjs +1 -1
- package/dist/themes/DraculaLight.d.cts +3 -10
- package/dist/themes/DraculaLight.d.ts +3 -10
- package/dist/themes/DraculaLight.js +1 -1
- package/dist/themes/EmeraldDark.cjs +1 -1
- package/dist/themes/EmeraldDark.d.cts +3 -8
- package/dist/themes/EmeraldDark.d.ts +3 -8
- package/dist/themes/EmeraldDark.js +1 -1
- package/dist/themes/{EmeraldBrand.cjs → EmeraldLight.cjs} +1 -1
- package/dist/themes/{EmeraldBrand.d.cts → EmeraldLight.d.cts} +1 -1
- package/dist/themes/{EmeraldBrand.d.ts → EmeraldLight.d.ts} +1 -1
- package/dist/themes/{EmeraldBrand.js → EmeraldLight.js} +1 -1
- package/dist/themes/EverforestDark.cjs +1 -1
- package/dist/themes/EverforestDark.d.cts +1 -2
- package/dist/themes/EverforestDark.d.ts +1 -2
- package/dist/themes/EverforestDark.js +1 -1
- package/dist/themes/EverforestLight.cjs +1 -1
- package/dist/themes/EverforestLight.d.cts +3 -9
- package/dist/themes/EverforestLight.d.ts +3 -9
- package/dist/themes/FluentDark.cjs +1 -1
- package/dist/themes/FluentDark.d.cts +3 -11
- package/dist/themes/FluentDark.d.ts +3 -11
- package/dist/themes/FluentDark.js +1 -1
- package/dist/themes/{FluentBrand.cjs → FluentLight.cjs} +1 -1
- package/dist/themes/{FluentBrand.d.cts → FluentLight.d.cts} +1 -1
- package/dist/themes/{FluentBrand.d.ts → FluentLight.d.ts} +1 -1
- package/dist/themes/{FluentBrand.js → FluentLight.js} +1 -1
- package/dist/themes/GraphiteDark.cjs +1 -1
- package/dist/themes/GraphiteDark.d.cts +3 -8
- package/dist/themes/GraphiteDark.d.ts +3 -8
- package/dist/themes/GraphiteDark.js +1 -1
- package/dist/themes/{GraphiteBrand.cjs → GraphiteLight.cjs} +1 -1
- package/dist/themes/{GraphiteBrand.d.cts → GraphiteLight.d.cts} +1 -1
- package/dist/themes/{GraphiteBrand.d.ts → GraphiteLight.d.ts} +1 -1
- package/dist/themes/{GraphiteBrand.js → GraphiteLight.js} +1 -1
- package/dist/themes/GruvboxDark.cjs +1 -1
- package/dist/themes/GruvboxDark.d.cts +1 -7
- package/dist/themes/GruvboxDark.d.ts +1 -7
- package/dist/themes/GruvboxDark.js +1 -1
- package/dist/themes/GruvboxLight.cjs +1 -1
- package/dist/themes/GruvboxLight.d.cts +3 -13
- package/dist/themes/GruvboxLight.d.ts +3 -13
- package/dist/themes/GruvboxLight.js +1 -1
- package/dist/themes/MaterialDark.cjs +1 -1
- package/dist/themes/MaterialDark.d.cts +3 -12
- package/dist/themes/MaterialDark.d.ts +3 -12
- package/dist/themes/MaterialDark.js +1 -1
- package/dist/themes/{MaterialBrand.cjs → MaterialLight.cjs} +1 -1
- package/dist/themes/MaterialLight.d.cts +3 -0
- package/dist/themes/MaterialLight.d.ts +3 -0
- package/dist/themes/{MaterialBrand.js → MaterialLight.js} +1 -1
- package/dist/themes/MidnightDark.cjs +1 -0
- package/dist/themes/MidnightDark.d.cts +3 -0
- package/dist/themes/MidnightDark.d.ts +3 -0
- package/dist/themes/{MidnightBrand.js → MidnightDark.js} +1 -1
- package/dist/themes/MidnightLight.cjs +1 -1
- package/dist/themes/MidnightLight.d.cts +4 -6
- package/dist/themes/MidnightLight.d.ts +4 -6
- package/dist/themes/MidnightLight.js +1 -1
- package/dist/themes/NordDark.cjs +1 -1
- package/dist/themes/NordDark.js +1 -1
- package/dist/themes/NordLight.cjs +1 -1
- package/dist/themes/NordLight.d.cts +3 -13
- package/dist/themes/NordLight.d.ts +3 -13
- package/dist/themes/NordLight.js +1 -1
- package/dist/themes/OneDark.cjs +1 -1
- package/dist/themes/OneDark.d.cts +1 -7
- package/dist/themes/OneDark.d.ts +1 -7
- package/dist/themes/OneDark.js +1 -1
- package/dist/themes/OneLight.cjs +1 -1
- package/dist/themes/OneLight.d.cts +3 -9
- package/dist/themes/OneLight.d.ts +3 -9
- package/dist/themes/OneLight.js +1 -1
- package/dist/themes/PrimerDark.cjs +1 -1
- package/dist/themes/PrimerDark.d.cts +0 -1
- package/dist/themes/PrimerDark.d.ts +0 -1
- package/dist/themes/PrimerDark.js +1 -1
- package/dist/themes/PrimerLight.d.cts +1 -7
- package/dist/themes/PrimerLight.d.ts +1 -7
- package/dist/themes/RosePine.cjs +1 -1
- package/dist/themes/RosePine.d.cts +1 -7
- package/dist/themes/RosePine.d.ts +1 -7
- package/dist/themes/RosePine.js +1 -1
- package/dist/themes/RosePineDawn.cjs +1 -1
- package/dist/themes/RosePineDawn.d.cts +3 -9
- package/dist/themes/RosePineDawn.d.ts +3 -9
- package/dist/themes/RosePineDawn.js +1 -1
- package/dist/themes/SkandaDark.cjs +1 -1
- package/dist/themes/SkandaDark.d.cts +5 -8
- package/dist/themes/SkandaDark.d.ts +5 -8
- package/dist/themes/SkandaDark.js +1 -1
- package/dist/themes/SkandaLight.cjs +1 -1
- package/dist/themes/SkandaLight.js +1 -1
- package/dist/themes/SolarizedDark.d.cts +1 -7
- package/dist/themes/SolarizedDark.d.ts +1 -7
- package/dist/themes/SolarizedLight.cjs +1 -1
- package/dist/themes/SolarizedLight.d.cts +1 -7
- package/dist/themes/SolarizedLight.d.ts +1 -7
- package/dist/themes/SolarizedLight.js +1 -1
- package/dist/themes/SynthwaveDark.d.cts +1 -7
- package/dist/themes/SynthwaveDark.d.ts +1 -7
- package/dist/themes/SynthwaveLight.cjs +1 -1
- package/dist/themes/SynthwaveLight.d.cts +3 -12
- package/dist/themes/SynthwaveLight.d.ts +3 -12
- package/dist/themes/SynthwaveLight.js +1 -1
- package/dist/themes/brands.cjs +1 -1
- package/dist/themes/brands.d.cts +5 -28
- package/dist/themes/brands.d.ts +5 -28
- package/dist/themes/brands.js +1 -1
- package/dist/themes/createBrandTheme.cjs +1 -1
- package/dist/themes/createBrandTheme.d.cts +11 -23
- package/dist/themes/createBrandTheme.d.ts +11 -23
- package/dist/themes/createBrandTheme.js +1 -1
- package/dist/themes/index.cjs +1 -1
- package/dist/themes/index.d.cts +10 -9
- package/dist/themes/index.d.ts +10 -9
- package/dist/themes/index.js +1 -1
- package/dist/themes.css +1 -1
- package/dist/tokens.css +1 -1
- package/dist/tokens.dtcg.json +14246 -0
- package/dist/utils/aliases.cjs +9 -3
- package/dist/utils/aliases.d.cts +19 -99
- package/dist/utils/aliases.d.ts +19 -99
- package/dist/utils/aliases.js +9 -3
- package/dist/utils/contrast.d.cts +2 -17
- package/dist/utils/contrast.d.ts +2 -17
- package/dist/utils/cssVars.cjs +2 -2
- package/dist/utils/cssVars.d.cts +12 -37
- package/dist/utils/cssVars.d.ts +12 -37
- package/dist/utils/cssVars.js +2 -2
- package/dist/utils/foundation.cjs +4 -4
- package/dist/utils/foundation.d.cts +24 -177
- package/dist/utils/foundation.d.ts +24 -177
- package/dist/utils/foundation.js +3 -3
- package/dist/utils/mode.cjs +1 -1
- package/dist/utils/mode.d.cts +18 -57
- package/dist/utils/mode.d.ts +18 -57
- package/dist/utils/mode.js +1 -1
- package/dist/utils/theme.cjs +1 -1
- package/dist/utils/theme.d.cts +68 -292
- package/dist/utils/theme.d.ts +68 -292
- package/dist/utils/toCss.cjs +5 -5
- package/dist/utils/toCss.d.cts +22 -60
- package/dist/utils/toCss.d.ts +22 -60
- package/dist/utils/toCss.js +5 -5
- package/package.json +5 -4
- package/dist/themes/MaterialBrand.d.cts +0 -3
- package/dist/themes/MaterialBrand.d.ts +0 -3
- package/dist/themes/MidnightBrand.cjs +0 -1
- package/dist/themes/MidnightBrand.d.cts +0 -11
- package/dist/themes/MidnightBrand.d.ts +0 -11
package/dist/utils/toCss.d.cts
CHANGED
|
@@ -1,92 +1,54 @@
|
|
|
1
|
+
import { type CssVar } from './cssVars.cjs';
|
|
1
2
|
import { type Theme } from './theme.cjs';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* The lower-level primitive behind {@link themeToCss} and {@link applyTheme};
|
|
6
|
-
* reach for one of those two instead unless you need the raw variable map
|
|
7
|
-
* (e.g. to diff two themes, or hand to a non-DOM renderer).
|
|
8
|
-
*
|
|
9
|
-
* **Colors only** (plus a theme's optional `typography`/`motion`). The type scale,
|
|
10
|
-
* spacing, radii, shadow geometry and motion come from `foundationToCssVars()`
|
|
11
|
-
* — see {@link Theme} for why. The two maps are disjoint, so a consumer can
|
|
12
|
-
* merge them without a precedence rule.
|
|
13
|
-
*
|
|
14
|
-
* @returns A plain object keyed by CSS custom property name (e.g. `'--skdx-color-primary-500'`), unprefixed by any selector.
|
|
15
|
-
*
|
|
4
|
+
* Flatten {@link Theme} into `{ '--skdx-…': value }` map. Colors only
|
|
5
|
+
* (plus optional `typography`/`motion`). @returns Unscoped CSS variables.
|
|
16
6
|
* @example
|
|
17
7
|
* ```ts
|
|
18
8
|
* themeToCssVars(defaultTheme)
|
|
19
9
|
* // => { '--skdx-color-primary-500': '#3d6eef', '--skdx-shadow-color': '2 6 23', … }
|
|
20
10
|
* ```
|
|
21
|
-
*
|
|
22
11
|
* @public
|
|
23
12
|
*/
|
|
24
|
-
export declare function themeToCssVars(theme: Theme): Record<
|
|
25
|
-
/** Options for {@link themeToCss}
|
|
13
|
+
export declare function themeToCssVars(theme: Theme): Record<CssVar, string>;
|
|
14
|
+
/** Options for {@link themeToCss}. @public */
|
|
26
15
|
export interface ThemeToCssOptions {
|
|
27
16
|
/**
|
|
28
|
-
* CSS selector
|
|
29
|
-
*
|
|
17
|
+
* CSS selector for variable scope. @default `[data-skdx-theme="<name>"]`
|
|
18
|
+
* (allows multiple themes to coexist).
|
|
30
19
|
*/
|
|
31
20
|
selector?: string;
|
|
32
21
|
}
|
|
33
22
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
23
|
+
* Render {@link Theme} as CSS rule block (build-time counterpart to {@link applyTheme}).
|
|
24
|
+
* Colors only; `foundationToCss()` required for complete stylesheet. Emits
|
|
25
|
+
* `@media (prefers-reduced-motion: reduce)` if theme retunes motion (re-declares
|
|
26
|
+
* as `0ms` to preserve WCAG 2.3.3 guarantee across higher specificity).
|
|
37
27
|
*
|
|
38
|
-
*
|
|
39
|
-
* colors; `foundationToCss()` emits everything else and must be injected once
|
|
40
|
-
* alongside it.
|
|
41
|
-
*
|
|
42
|
-
* A `@media (prefers-reduced-motion: reduce)` block follows only when the
|
|
43
|
-
* theme retunes motion through `ThemeMotionDeviation` — otherwise the
|
|
44
|
-
* foundation's own block already covers it, and repeating it 38 times was how
|
|
45
|
-
* the old output got to 43% non-color. When it is emitted it re-declares every
|
|
46
|
-
* `--skdx-motion-duration-*` and `--skdx-motion-stagger-*` as `0ms` at this
|
|
47
|
-
* theme's selector, which is what keeps the WCAG 2.3.3 guarantee from being
|
|
48
|
-
* lost to the deviation's higher specificity. The easing curve is left alone:
|
|
49
|
-
* it's a shape, not a duration, and is inert at `0ms`.
|
|
50
|
-
*
|
|
51
|
-
* @param theme - The theme to render.
|
|
28
|
+
* @param theme - Theme to render.
|
|
52
29
|
* @param options - See {@link ThemeToCssOptions}.
|
|
53
|
-
* @returns
|
|
54
|
-
*
|
|
30
|
+
* @returns CSS string.
|
|
55
31
|
* @example
|
|
56
32
|
* ```ts
|
|
57
33
|
* import { foundationToCss, themeToCss, skandaLight } from '@skdx/tokens';
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* fs.writeFileSync('skanda-light.css', foundationToCss() + themeToCss(skandaLight));
|
|
34
|
+
* fs.writeFileSync('skanda.css', foundationToCss() + themeToCss(skandaLight));
|
|
61
35
|
* ```
|
|
62
|
-
*
|
|
63
36
|
* @public
|
|
64
37
|
*/
|
|
65
38
|
export declare function themeToCss(theme: Theme, options?: ThemeToCssOptions): string;
|
|
66
39
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* mechanism behind live theme preview (e.g. a theme builder, or a runtime
|
|
71
|
-
* brand switcher). Multiple themes can coexist by applying each to a
|
|
72
|
-
* different subtree.
|
|
73
|
-
*
|
|
74
|
-
* Sets the theme's own variables only. The shared tokens are expected to be on
|
|
75
|
-
* the document already (`foundationToCss()` at `:root`) and inherit down into
|
|
76
|
-
* `element` — which is why applying a theme to a subtree re-colors it without
|
|
77
|
-
* re-declaring the type scale for it.
|
|
78
|
-
*
|
|
79
|
-
* @param theme - The theme to apply.
|
|
80
|
-
* @param element - Element to apply the theme to. @default document.documentElement
|
|
40
|
+
* Apply {@link Theme} at runtime via `element.style.setProperty`, stamping
|
|
41
|
+
* `data-skdx-theme`/`data-skdx-mode`. Theme-only variables; shared tokens
|
|
42
|
+
* inherit. Subtree re-colors without re-declaring type scale.
|
|
81
43
|
*
|
|
44
|
+
* @param theme - Theme to apply.
|
|
45
|
+
* @param element - Target element. @default document.documentElement
|
|
82
46
|
* @example
|
|
83
47
|
* ```ts
|
|
84
|
-
* import { applyTheme,
|
|
85
|
-
*
|
|
86
|
-
* applyTheme(
|
|
87
|
-
* applyTheme(midnightBrand, document.getElementById('preview')!); // scoped subtree
|
|
48
|
+
* import { applyTheme, midnightDark } from '@skdx/tokens';
|
|
49
|
+
* applyTheme(midnightDark); // whole page
|
|
50
|
+
* applyTheme(midnightDark, el); // scoped
|
|
88
51
|
* ```
|
|
89
|
-
*
|
|
90
52
|
* @public
|
|
91
53
|
*/
|
|
92
54
|
export declare function applyTheme(theme: Theme, element?: HTMLElement): void;
|
package/dist/utils/toCss.d.ts
CHANGED
|
@@ -1,92 +1,54 @@
|
|
|
1
|
+
import { type CssVar } from './cssVars.js';
|
|
1
2
|
import { type Theme } from './theme.js';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* The lower-level primitive behind {@link themeToCss} and {@link applyTheme};
|
|
6
|
-
* reach for one of those two instead unless you need the raw variable map
|
|
7
|
-
* (e.g. to diff two themes, or hand to a non-DOM renderer).
|
|
8
|
-
*
|
|
9
|
-
* **Colors only** (plus a theme's optional `typography`/`motion`). The type scale,
|
|
10
|
-
* spacing, radii, shadow geometry and motion come from `foundationToCssVars()`
|
|
11
|
-
* — see {@link Theme} for why. The two maps are disjoint, so a consumer can
|
|
12
|
-
* merge them without a precedence rule.
|
|
13
|
-
*
|
|
14
|
-
* @returns A plain object keyed by CSS custom property name (e.g. `'--skdx-color-primary-500'`), unprefixed by any selector.
|
|
15
|
-
*
|
|
4
|
+
* Flatten {@link Theme} into `{ '--skdx-…': value }` map. Colors only
|
|
5
|
+
* (plus optional `typography`/`motion`). @returns Unscoped CSS variables.
|
|
16
6
|
* @example
|
|
17
7
|
* ```ts
|
|
18
8
|
* themeToCssVars(defaultTheme)
|
|
19
9
|
* // => { '--skdx-color-primary-500': '#3d6eef', '--skdx-shadow-color': '2 6 23', … }
|
|
20
10
|
* ```
|
|
21
|
-
*
|
|
22
11
|
* @public
|
|
23
12
|
*/
|
|
24
|
-
export declare function themeToCssVars(theme: Theme): Record<
|
|
25
|
-
/** Options for {@link themeToCss}
|
|
13
|
+
export declare function themeToCssVars(theme: Theme): Record<CssVar, string>;
|
|
14
|
+
/** Options for {@link themeToCss}. @public */
|
|
26
15
|
export interface ThemeToCssOptions {
|
|
27
16
|
/**
|
|
28
|
-
* CSS selector
|
|
29
|
-
*
|
|
17
|
+
* CSS selector for variable scope. @default `[data-skdx-theme="<name>"]`
|
|
18
|
+
* (allows multiple themes to coexist).
|
|
30
19
|
*/
|
|
31
20
|
selector?: string;
|
|
32
21
|
}
|
|
33
22
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
23
|
+
* Render {@link Theme} as CSS rule block (build-time counterpart to {@link applyTheme}).
|
|
24
|
+
* Colors only; `foundationToCss()` required for complete stylesheet. Emits
|
|
25
|
+
* `@media (prefers-reduced-motion: reduce)` if theme retunes motion (re-declares
|
|
26
|
+
* as `0ms` to preserve WCAG 2.3.3 guarantee across higher specificity).
|
|
37
27
|
*
|
|
38
|
-
*
|
|
39
|
-
* colors; `foundationToCss()` emits everything else and must be injected once
|
|
40
|
-
* alongside it.
|
|
41
|
-
*
|
|
42
|
-
* A `@media (prefers-reduced-motion: reduce)` block follows only when the
|
|
43
|
-
* theme retunes motion through `ThemeMotionDeviation` — otherwise the
|
|
44
|
-
* foundation's own block already covers it, and repeating it 38 times was how
|
|
45
|
-
* the old output got to 43% non-color. When it is emitted it re-declares every
|
|
46
|
-
* `--skdx-motion-duration-*` and `--skdx-motion-stagger-*` as `0ms` at this
|
|
47
|
-
* theme's selector, which is what keeps the WCAG 2.3.3 guarantee from being
|
|
48
|
-
* lost to the deviation's higher specificity. The easing curve is left alone:
|
|
49
|
-
* it's a shape, not a duration, and is inert at `0ms`.
|
|
50
|
-
*
|
|
51
|
-
* @param theme - The theme to render.
|
|
28
|
+
* @param theme - Theme to render.
|
|
52
29
|
* @param options - See {@link ThemeToCssOptions}.
|
|
53
|
-
* @returns
|
|
54
|
-
*
|
|
30
|
+
* @returns CSS string.
|
|
55
31
|
* @example
|
|
56
32
|
* ```ts
|
|
57
33
|
* import { foundationToCss, themeToCss, skandaLight } from '@skdx/tokens';
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* fs.writeFileSync('skanda-light.css', foundationToCss() + themeToCss(skandaLight));
|
|
34
|
+
* fs.writeFileSync('skanda.css', foundationToCss() + themeToCss(skandaLight));
|
|
61
35
|
* ```
|
|
62
|
-
*
|
|
63
36
|
* @public
|
|
64
37
|
*/
|
|
65
38
|
export declare function themeToCss(theme: Theme, options?: ThemeToCssOptions): string;
|
|
66
39
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* mechanism behind live theme preview (e.g. a theme builder, or a runtime
|
|
71
|
-
* brand switcher). Multiple themes can coexist by applying each to a
|
|
72
|
-
* different subtree.
|
|
73
|
-
*
|
|
74
|
-
* Sets the theme's own variables only. The shared tokens are expected to be on
|
|
75
|
-
* the document already (`foundationToCss()` at `:root`) and inherit down into
|
|
76
|
-
* `element` — which is why applying a theme to a subtree re-colors it without
|
|
77
|
-
* re-declaring the type scale for it.
|
|
78
|
-
*
|
|
79
|
-
* @param theme - The theme to apply.
|
|
80
|
-
* @param element - Element to apply the theme to. @default document.documentElement
|
|
40
|
+
* Apply {@link Theme} at runtime via `element.style.setProperty`, stamping
|
|
41
|
+
* `data-skdx-theme`/`data-skdx-mode`. Theme-only variables; shared tokens
|
|
42
|
+
* inherit. Subtree re-colors without re-declaring type scale.
|
|
81
43
|
*
|
|
44
|
+
* @param theme - Theme to apply.
|
|
45
|
+
* @param element - Target element. @default document.documentElement
|
|
82
46
|
* @example
|
|
83
47
|
* ```ts
|
|
84
|
-
* import { applyTheme,
|
|
85
|
-
*
|
|
86
|
-
* applyTheme(
|
|
87
|
-
* applyTheme(midnightBrand, document.getElementById('preview')!); // scoped subtree
|
|
48
|
+
* import { applyTheme, midnightDark } from '@skdx/tokens';
|
|
49
|
+
* applyTheme(midnightDark); // whole page
|
|
50
|
+
* applyTheme(midnightDark, el); // scoped
|
|
88
51
|
* ```
|
|
89
|
-
*
|
|
90
52
|
* @public
|
|
91
53
|
*/
|
|
92
54
|
export declare function applyTheme(theme: Theme, element?: HTMLElement): void;
|
package/dist/utils/toCss.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{reducedMotionVarNames as
|
|
2
|
-
${
|
|
1
|
+
import{reducedMotionVarNames as m,sectionsToCssVars as d,varsToDeclarations as p}from"./cssVars.js";import{defaultMotion as u}from"./theme.js";function i(o){return d([["color",o.colors],["shadow",o.shadow],["font",o.typography],["motion",o.motion?{...u,...o.motion}:void 0]])}function l(o,e={}){let t=e.selector??`[data-skdx-theme="${o.name}"]`,s=i(o),n=`${t} {
|
|
2
|
+
${p(s)}
|
|
3
3
|
}
|
|
4
|
-
`,r=
|
|
5
|
-
${
|
|
4
|
+
`,r=m(s);if(r.length===0)return n;let a=r.map(c=>` ${c}: 0ms;`);return n+`@media (prefers-reduced-motion: reduce) {
|
|
5
|
+
${t} {
|
|
6
6
|
${a.join(`
|
|
7
7
|
`)}
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
`}function
|
|
10
|
+
`}function C(o,e=document.documentElement){let t=i(o);for(let[s,n]of Object.entries(t))e.style.setProperty(s,n);e.setAttribute("data-skdx-theme",o.name),e.setAttribute("data-skdx-mode",o.mode)}export{C as applyTheme,l as themeToCss,i as themeToCssVars};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skdx/tokens",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"description": "Theme contract and design tokens for the SkandaDX design system",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"type": "module",
|
|
19
19
|
"engines": {
|
|
20
|
-
"node": ">=
|
|
20
|
+
"node": ">=24.15.0"
|
|
21
21
|
},
|
|
22
22
|
"main": "./dist/index.cjs",
|
|
23
23
|
"module": "./dist/index.js",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"./css": "./dist/tokens.css",
|
|
42
42
|
"./foundation.css": "./dist/foundation.css",
|
|
43
43
|
"./themes.css": "./dist/themes.css",
|
|
44
|
+
"./tokens.dtcg.json": "./dist/tokens.dtcg.json",
|
|
44
45
|
"./package.json": "./package.json"
|
|
45
46
|
},
|
|
46
47
|
"sideEffects": [
|
|
@@ -60,9 +61,9 @@
|
|
|
60
61
|
"vitest": "^4.1.10"
|
|
61
62
|
},
|
|
62
63
|
"scripts": {
|
|
63
|
-
"
|
|
64
|
+
"lint": "eslint . --cache --cache-location node_modules/.cache/eslint/",
|
|
65
|
+
"build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && tsup && tsc --emitDeclarationOnly -p tsconfig.build.json && node ../../scripts/declarations-cjs.mjs && node scripts/build-css.mjs && node scripts/build-dtcg.mjs && node ../../scripts/minify-css.mjs dist",
|
|
64
66
|
"typecheck": "tsc --noEmit --incremental --tsBuildInfoFile node_modules/.cache/tsc/typecheck.tsbuildinfo",
|
|
65
|
-
"export:dtcg": "node scripts/export-dtcg.mjs",
|
|
66
67
|
"test": "vitest run",
|
|
67
68
|
"test:watch": "vitest",
|
|
68
69
|
"test:coverage": "vitest run --coverage"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var o=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var p=(e,r)=>{for(var m in r)o(e,m,{get:r[m],enumerable:!0})},u=(e,r,m,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of i(r))!h.call(e,a)&&a!==m&&o(e,a,{get:()=>r[a],enumerable:!(n=d(r,a))||n.enumerable});return e};var c=e=>u(o({},"__esModule",{value:!0}),e);var l={};p(l,{midnightBrand:()=>g});module.exports=c(l);var t=require("./createBrandTheme.cjs"),g=(0,t.createBrandTheme)({name:"midnight-brand",mode:"dark",primaryHue:271,primaryChroma:91,neutralHue:265,neutralChroma:25,override:{shadow:{color:"0 0 0",strength:"5.2"}}});0&&(module.exports={midnightBrand});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Midnight purple dark theme: violet actions on deep indigo surfaces.
|
|
3
|
-
*
|
|
4
|
-
* The first brand generated from a `BrandSeed` rather than hand-written — its
|
|
5
|
-
* ramps and semantic roles come out of {@link createBrandTheme}, which drives
|
|
6
|
-
* every WCAG AA pair to threshold instead of leaving it to review. Only the
|
|
7
|
-
* dark shadow stack is hand-kept, since shadow alpha isn't derived from hue.
|
|
8
|
-
*
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
export declare const midnightBrand: import("../index.cjs").Theme;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Midnight purple dark theme: violet actions on deep indigo surfaces.
|
|
3
|
-
*
|
|
4
|
-
* The first brand generated from a `BrandSeed` rather than hand-written — its
|
|
5
|
-
* ramps and semantic roles come out of {@link createBrandTheme}, which drives
|
|
6
|
-
* every WCAG AA pair to threshold instead of leaving it to review. Only the
|
|
7
|
-
* dark shadow stack is hand-kept, since shadow alpha isn't derived from hue.
|
|
8
|
-
*
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
export declare const midnightBrand: import("../index.js").Theme;
|