@skdx/tokens 0.26.0 → 0.28.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 +77 -57
- package/dist/themes/AntDark.d.cts +3 -7
- package/dist/themes/AntDark.d.ts +3 -7
- package/dist/themes/ChakraDark.d.cts +3 -7
- package/dist/themes/ChakraDark.d.ts +3 -7
- package/dist/themes/DefaultTheme.d.cts +1 -2
- package/dist/themes/DefaultTheme.d.ts +1 -2
- package/dist/themes/DraculaLight.d.cts +1 -9
- package/dist/themes/DraculaLight.d.ts +1 -9
- package/dist/themes/EverforestDark.d.cts +1 -2
- package/dist/themes/EverforestDark.d.ts +1 -2
- package/dist/themes/EverforestLight.d.cts +4 -8
- package/dist/themes/EverforestLight.d.ts +4 -8
- package/dist/themes/FluentDark.d.cts +2 -6
- package/dist/themes/FluentDark.d.ts +2 -6
- package/dist/themes/GruvboxLight.d.cts +1 -2
- package/dist/themes/GruvboxLight.d.ts +1 -2
- package/dist/themes/MaterialBrand.d.cts +1 -1
- package/dist/themes/MaterialBrand.d.ts +1 -1
- package/dist/themes/MaterialDark.d.cts +3 -7
- package/dist/themes/MaterialDark.d.ts +3 -7
- package/dist/themes/MidnightBrand.d.cts +2 -5
- package/dist/themes/MidnightBrand.d.ts +2 -5
- package/dist/themes/MidnightLight.d.cts +2 -5
- package/dist/themes/MidnightLight.d.ts +2 -5
- package/dist/themes/NordLight.d.cts +1 -2
- package/dist/themes/NordLight.d.ts +1 -2
- package/dist/themes/OneLight.d.cts +4 -8
- package/dist/themes/OneLight.d.ts +4 -8
- package/dist/themes/PrimerDark.d.cts +0 -1
- package/dist/themes/PrimerDark.d.ts +0 -1
- package/dist/themes/RosePineDawn.d.cts +4 -8
- package/dist/themes/RosePineDawn.d.ts +4 -8
- package/dist/themes/SkandaDark.d.cts +3 -7
- package/dist/themes/SkandaDark.d.ts +3 -7
- package/dist/themes/SynthwaveLight.d.cts +3 -7
- package/dist/themes/SynthwaveLight.d.ts +3 -7
- package/dist/themes/brands.d.cts +7 -14
- package/dist/themes/brands.d.ts +7 -14
- package/dist/themes/createBrandTheme.d.cts +13 -21
- package/dist/themes/createBrandTheme.d.ts +13 -21
- package/dist/utils/aliases.d.cts +22 -92
- package/dist/utils/aliases.d.ts +22 -92
- package/dist/utils/contrast.d.cts +2 -17
- package/dist/utils/contrast.d.ts +2 -17
- package/dist/utils/cssVars.d.cts +7 -29
- package/dist/utils/cssVars.d.ts +7 -29
- package/dist/utils/foundation.d.cts +47 -143
- package/dist/utils/foundation.d.ts +47 -143
- package/dist/utils/mode.d.cts +31 -43
- package/dist/utils/mode.d.ts +31 -43
- package/dist/utils/theme.d.cts +83 -240
- package/dist/utils/theme.d.ts +83 -240
- package/dist/utils/toCss.d.cts +18 -57
- package/dist/utils/toCss.d.ts +18 -57
- package/package.json +1 -1
package/dist/utils/toCss.d.ts
CHANGED
|
@@ -1,92 +1,53 @@
|
|
|
1
1
|
import { type Theme } from './theme.js';
|
|
2
2
|
/**
|
|
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
|
-
*
|
|
3
|
+
* Flatten {@link Theme} into `{ '--skdx-…': value }` map. Colors only
|
|
4
|
+
* (plus optional `typography`/`motion`). @returns Unscoped CSS variables.
|
|
16
5
|
* @example
|
|
17
6
|
* ```ts
|
|
18
7
|
* themeToCssVars(defaultTheme)
|
|
19
8
|
* // => { '--skdx-color-primary-500': '#3d6eef', '--skdx-shadow-color': '2 6 23', … }
|
|
20
9
|
* ```
|
|
21
|
-
*
|
|
22
10
|
* @public
|
|
23
11
|
*/
|
|
24
12
|
export declare function themeToCssVars(theme: Theme): Record<string, string>;
|
|
25
|
-
/** Options for {@link themeToCss}
|
|
13
|
+
/** Options for {@link themeToCss}. @public */
|
|
26
14
|
export interface ThemeToCssOptions {
|
|
27
15
|
/**
|
|
28
|
-
* CSS selector
|
|
29
|
-
*
|
|
16
|
+
* CSS selector for variable scope. @default `[data-skdx-theme="<name>"]`
|
|
17
|
+
* (allows multiple themes to coexist).
|
|
30
18
|
*/
|
|
31
19
|
selector?: string;
|
|
32
20
|
}
|
|
33
21
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
22
|
+
* Render {@link Theme} as CSS rule block (build-time counterpart to {@link applyTheme}).
|
|
23
|
+
* Colors only; `foundationToCss()` required for complete stylesheet. Emits
|
|
24
|
+
* `@media (prefers-reduced-motion: reduce)` if theme retunes motion (re-declares
|
|
25
|
+
* as `0ms` to preserve WCAG 2.3.3 guarantee across higher specificity).
|
|
37
26
|
*
|
|
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.
|
|
27
|
+
* @param theme - Theme to render.
|
|
52
28
|
* @param options - See {@link ThemeToCssOptions}.
|
|
53
|
-
* @returns
|
|
54
|
-
*
|
|
29
|
+
* @returns CSS string.
|
|
55
30
|
* @example
|
|
56
31
|
* ```ts
|
|
57
32
|
* import { foundationToCss, themeToCss, skandaLight } from '@skdx/tokens';
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* fs.writeFileSync('skanda-light.css', foundationToCss() + themeToCss(skandaLight));
|
|
33
|
+
* fs.writeFileSync('skanda.css', foundationToCss() + themeToCss(skandaLight));
|
|
61
34
|
* ```
|
|
62
|
-
*
|
|
63
35
|
* @public
|
|
64
36
|
*/
|
|
65
37
|
export declare function themeToCss(theme: Theme, options?: ThemeToCssOptions): string;
|
|
66
38
|
/**
|
|
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
|
|
39
|
+
* Apply {@link Theme} at runtime via `element.style.setProperty`, stamping
|
|
40
|
+
* `data-skdx-theme`/`data-skdx-mode`. Theme-only variables; shared tokens
|
|
41
|
+
* inherit. Subtree re-colors without re-declaring type scale.
|
|
81
42
|
*
|
|
43
|
+
* @param theme - Theme to apply.
|
|
44
|
+
* @param element - Target element. @default document.documentElement
|
|
82
45
|
* @example
|
|
83
46
|
* ```ts
|
|
84
47
|
* import { applyTheme, midnightBrand } from '@skdx/tokens';
|
|
85
|
-
*
|
|
86
48
|
* applyTheme(midnightBrand); // whole page
|
|
87
|
-
* applyTheme(midnightBrand,
|
|
49
|
+
* applyTheme(midnightBrand, el); // scoped
|
|
88
50
|
* ```
|
|
89
|
-
*
|
|
90
51
|
* @public
|
|
91
52
|
*/
|
|
92
53
|
export declare function applyTheme(theme: Theme, element?: HTMLElement): void;
|