@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.
Files changed (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +77 -57
  3. package/dist/themes/AntDark.d.cts +3 -7
  4. package/dist/themes/AntDark.d.ts +3 -7
  5. package/dist/themes/ChakraDark.d.cts +3 -7
  6. package/dist/themes/ChakraDark.d.ts +3 -7
  7. package/dist/themes/DefaultTheme.d.cts +1 -2
  8. package/dist/themes/DefaultTheme.d.ts +1 -2
  9. package/dist/themes/DraculaLight.d.cts +1 -9
  10. package/dist/themes/DraculaLight.d.ts +1 -9
  11. package/dist/themes/EverforestDark.d.cts +1 -2
  12. package/dist/themes/EverforestDark.d.ts +1 -2
  13. package/dist/themes/EverforestLight.d.cts +4 -8
  14. package/dist/themes/EverforestLight.d.ts +4 -8
  15. package/dist/themes/FluentDark.d.cts +2 -6
  16. package/dist/themes/FluentDark.d.ts +2 -6
  17. package/dist/themes/GruvboxLight.d.cts +1 -2
  18. package/dist/themes/GruvboxLight.d.ts +1 -2
  19. package/dist/themes/MaterialBrand.d.cts +1 -1
  20. package/dist/themes/MaterialBrand.d.ts +1 -1
  21. package/dist/themes/MaterialDark.d.cts +3 -7
  22. package/dist/themes/MaterialDark.d.ts +3 -7
  23. package/dist/themes/MidnightBrand.d.cts +2 -5
  24. package/dist/themes/MidnightBrand.d.ts +2 -5
  25. package/dist/themes/MidnightLight.d.cts +2 -5
  26. package/dist/themes/MidnightLight.d.ts +2 -5
  27. package/dist/themes/NordLight.d.cts +1 -2
  28. package/dist/themes/NordLight.d.ts +1 -2
  29. package/dist/themes/OneLight.d.cts +4 -8
  30. package/dist/themes/OneLight.d.ts +4 -8
  31. package/dist/themes/PrimerDark.d.cts +0 -1
  32. package/dist/themes/PrimerDark.d.ts +0 -1
  33. package/dist/themes/RosePineDawn.d.cts +4 -8
  34. package/dist/themes/RosePineDawn.d.ts +4 -8
  35. package/dist/themes/SkandaDark.d.cts +3 -7
  36. package/dist/themes/SkandaDark.d.ts +3 -7
  37. package/dist/themes/SynthwaveLight.d.cts +3 -7
  38. package/dist/themes/SynthwaveLight.d.ts +3 -7
  39. package/dist/themes/brands.d.cts +7 -14
  40. package/dist/themes/brands.d.ts +7 -14
  41. package/dist/themes/createBrandTheme.d.cts +13 -21
  42. package/dist/themes/createBrandTheme.d.ts +13 -21
  43. package/dist/utils/aliases.d.cts +22 -92
  44. package/dist/utils/aliases.d.ts +22 -92
  45. package/dist/utils/contrast.d.cts +2 -17
  46. package/dist/utils/contrast.d.ts +2 -17
  47. package/dist/utils/cssVars.d.cts +7 -29
  48. package/dist/utils/cssVars.d.ts +7 -29
  49. package/dist/utils/foundation.d.cts +47 -143
  50. package/dist/utils/foundation.d.ts +47 -143
  51. package/dist/utils/mode.d.cts +31 -43
  52. package/dist/utils/mode.d.ts +31 -43
  53. package/dist/utils/theme.d.cts +83 -240
  54. package/dist/utils/theme.d.ts +83 -240
  55. package/dist/utils/toCss.d.cts +18 -57
  56. package/dist/utils/toCss.d.ts +18 -57
  57. package/package.json +1 -1
@@ -1,92 +1,53 @@
1
1
  import { type Theme } from './theme.js';
2
2
  /**
3
- * Flattens a {@link Theme} into a map of CSS custom property names to values,
4
- * e.g. `--skdx-color-primary-500`, `--skdx-shadow-color`.
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} controlling how a theme's CSS rule block is generated. @public */
13
+ /** Options for {@link themeToCss}. @public */
26
14
  export interface ThemeToCssOptions {
27
15
  /**
28
- * CSS selector the variables are scoped to.
29
- * Defaults to `[data-skdx-theme="<name>"]` so multiple themes can coexist.
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
- * Renders a {@link Theme} as a CSS rule block ready to inject into a
35
- * `<style>` tag or write to a `.css` file the build-time counterpart to
36
- * {@link applyTheme}'s runtime application.
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
- * **This is not a complete stylesheet on its own.** It emits the theme's
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 A CSS string, e.g. `'[data-skdx-theme="skanda-light"] {\n --skdx-color-primary-500: #3d6eef;\n …\n}\n'`.
54
- *
29
+ * @returns CSS string.
55
30
  * @example
56
31
  * ```ts
57
32
  * import { foundationToCss, themeToCss, skandaLight } from '@skdx/tokens';
58
- * import fs from 'node:fs';
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
- * Applies a {@link Theme} to an element at runtime by setting its CSS custom
68
- * properties directly (via `element.style.setProperty`) and stamping
69
- * `data-skdx-theme="<name>"` plus `data-skdx-mode="<light|dark>"` on it the
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, document.getElementById('preview')!); // scoped subtree
49
+ * applyTheme(midnightBrand, el); // scoped
88
50
  * ```
89
- *
90
51
  * @public
91
52
  */
92
53
  export declare function applyTheme(theme: Theme, element?: HTMLElement): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skdx/tokens",
3
- "version": "0.26.0",
3
+ "version": "0.28.0",
4
4
  "description": "Theme contract and design tokens for the SkandaDX design system",
5
5
  "license": "MIT",
6
6
  "publishConfig": {