@skdx/tokens 0.26.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/README.md +439 -0
- package/dist/foundation.css +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +1 -0
- package/dist/themes/AntBrand.cjs +1 -0
- package/dist/themes/AntBrand.d.cts +3 -0
- package/dist/themes/AntBrand.d.ts +3 -0
- package/dist/themes/AntBrand.js +1 -0
- package/dist/themes/AntDark.cjs +1 -0
- package/dist/themes/AntDark.d.cts +12 -0
- package/dist/themes/AntDark.d.ts +12 -0
- package/dist/themes/AntDark.js +1 -0
- package/dist/themes/CatppuccinLatte.cjs +1 -0
- package/dist/themes/CatppuccinLatte.d.cts +9 -0
- package/dist/themes/CatppuccinLatte.d.ts +9 -0
- package/dist/themes/CatppuccinLatte.js +1 -0
- package/dist/themes/CatppuccinMocha.cjs +1 -0
- package/dist/themes/CatppuccinMocha.d.cts +9 -0
- package/dist/themes/CatppuccinMocha.d.ts +9 -0
- package/dist/themes/CatppuccinMocha.js +1 -0
- package/dist/themes/ChakraBrand.cjs +1 -0
- package/dist/themes/ChakraBrand.d.cts +3 -0
- package/dist/themes/ChakraBrand.d.ts +3 -0
- package/dist/themes/ChakraBrand.js +1 -0
- package/dist/themes/ChakraDark.cjs +1 -0
- package/dist/themes/ChakraDark.d.cts +12 -0
- package/dist/themes/ChakraDark.d.ts +12 -0
- package/dist/themes/ChakraDark.js +1 -0
- package/dist/themes/CupcakeDark.cjs +1 -0
- package/dist/themes/CupcakeDark.d.cts +9 -0
- package/dist/themes/CupcakeDark.d.ts +9 -0
- package/dist/themes/CupcakeDark.js +1 -0
- package/dist/themes/CupcakeLight.cjs +1 -0
- package/dist/themes/CupcakeLight.d.cts +10 -0
- package/dist/themes/CupcakeLight.d.ts +10 -0
- package/dist/themes/CupcakeLight.js +1 -0
- package/dist/themes/DefaultTheme.cjs +1 -0
- package/dist/themes/DefaultTheme.d.cts +37 -0
- package/dist/themes/DefaultTheme.d.ts +37 -0
- package/dist/themes/DefaultTheme.js +1 -0
- package/dist/themes/DraculaDark.cjs +1 -0
- package/dist/themes/DraculaDark.d.cts +3 -0
- package/dist/themes/DraculaDark.d.ts +3 -0
- package/dist/themes/DraculaDark.js +1 -0
- package/dist/themes/DraculaLight.cjs +1 -0
- package/dist/themes/DraculaLight.d.cts +14 -0
- package/dist/themes/DraculaLight.d.ts +14 -0
- package/dist/themes/DraculaLight.js +1 -0
- package/dist/themes/EmeraldBrand.cjs +1 -0
- package/dist/themes/EmeraldBrand.d.cts +3 -0
- package/dist/themes/EmeraldBrand.d.ts +3 -0
- package/dist/themes/EmeraldBrand.js +1 -0
- package/dist/themes/EmeraldDark.cjs +1 -0
- package/dist/themes/EmeraldDark.d.cts +8 -0
- package/dist/themes/EmeraldDark.d.ts +8 -0
- package/dist/themes/EmeraldDark.js +1 -0
- package/dist/themes/EverforestDark.cjs +1 -0
- package/dist/themes/EverforestDark.d.cts +9 -0
- package/dist/themes/EverforestDark.d.ts +9 -0
- package/dist/themes/EverforestDark.js +1 -0
- package/dist/themes/EverforestLight.cjs +1 -0
- package/dist/themes/EverforestLight.d.cts +13 -0
- package/dist/themes/EverforestLight.d.ts +13 -0
- package/dist/themes/EverforestLight.js +1 -0
- package/dist/themes/FluentBrand.cjs +1 -0
- package/dist/themes/FluentBrand.d.cts +3 -0
- package/dist/themes/FluentBrand.d.ts +3 -0
- package/dist/themes/FluentBrand.js +1 -0
- package/dist/themes/FluentDark.cjs +1 -0
- package/dist/themes/FluentDark.d.cts +11 -0
- package/dist/themes/FluentDark.d.ts +11 -0
- package/dist/themes/FluentDark.js +1 -0
- package/dist/themes/GraphiteBrand.cjs +1 -0
- package/dist/themes/GraphiteBrand.d.cts +3 -0
- package/dist/themes/GraphiteBrand.d.ts +3 -0
- package/dist/themes/GraphiteBrand.js +1 -0
- package/dist/themes/GraphiteDark.cjs +1 -0
- package/dist/themes/GraphiteDark.d.cts +8 -0
- package/dist/themes/GraphiteDark.d.ts +8 -0
- package/dist/themes/GraphiteDark.js +1 -0
- package/dist/themes/GruvboxDark.cjs +1 -0
- package/dist/themes/GruvboxDark.d.cts +9 -0
- package/dist/themes/GruvboxDark.d.ts +9 -0
- package/dist/themes/GruvboxDark.js +1 -0
- package/dist/themes/GruvboxLight.cjs +1 -0
- package/dist/themes/GruvboxLight.d.cts +13 -0
- package/dist/themes/GruvboxLight.d.ts +13 -0
- package/dist/themes/GruvboxLight.js +1 -0
- package/dist/themes/MaterialBrand.cjs +1 -0
- package/dist/themes/MaterialBrand.d.cts +3 -0
- package/dist/themes/MaterialBrand.d.ts +3 -0
- package/dist/themes/MaterialBrand.js +1 -0
- package/dist/themes/MaterialDark.cjs +1 -0
- package/dist/themes/MaterialDark.d.cts +12 -0
- package/dist/themes/MaterialDark.d.ts +12 -0
- package/dist/themes/MaterialDark.js +1 -0
- package/dist/themes/MidnightBrand.cjs +1 -0
- package/dist/themes/MidnightBrand.d.cts +11 -0
- package/dist/themes/MidnightBrand.d.ts +11 -0
- package/dist/themes/MidnightBrand.js +1 -0
- package/dist/themes/MidnightLight.cjs +1 -0
- package/dist/themes/MidnightLight.d.cts +10 -0
- package/dist/themes/MidnightLight.d.ts +10 -0
- package/dist/themes/MidnightLight.js +1 -0
- package/dist/themes/NordDark.cjs +1 -0
- package/dist/themes/NordDark.d.cts +3 -0
- package/dist/themes/NordDark.d.ts +3 -0
- package/dist/themes/NordDark.js +1 -0
- package/dist/themes/NordLight.cjs +1 -0
- package/dist/themes/NordLight.d.cts +13 -0
- package/dist/themes/NordLight.d.ts +13 -0
- package/dist/themes/NordLight.js +1 -0
- package/dist/themes/OneDark.cjs +1 -0
- package/dist/themes/OneDark.d.cts +9 -0
- package/dist/themes/OneDark.d.ts +9 -0
- package/dist/themes/OneDark.js +1 -0
- package/dist/themes/OneLight.cjs +1 -0
- package/dist/themes/OneLight.d.cts +13 -0
- package/dist/themes/OneLight.d.ts +13 -0
- package/dist/themes/OneLight.js +1 -0
- package/dist/themes/PrimerDark.cjs +1 -0
- package/dist/themes/PrimerDark.d.cts +9 -0
- package/dist/themes/PrimerDark.d.ts +9 -0
- package/dist/themes/PrimerDark.js +1 -0
- package/dist/themes/PrimerLight.cjs +1 -0
- package/dist/themes/PrimerLight.d.cts +9 -0
- package/dist/themes/PrimerLight.d.ts +9 -0
- package/dist/themes/PrimerLight.js +1 -0
- package/dist/themes/RosePine.cjs +1 -0
- package/dist/themes/RosePine.d.cts +9 -0
- package/dist/themes/RosePine.d.ts +9 -0
- package/dist/themes/RosePine.js +1 -0
- package/dist/themes/RosePineDawn.cjs +1 -0
- package/dist/themes/RosePineDawn.d.cts +13 -0
- package/dist/themes/RosePineDawn.d.ts +13 -0
- package/dist/themes/RosePineDawn.js +1 -0
- package/dist/themes/SkandaDark.cjs +1 -0
- package/dist/themes/SkandaDark.d.cts +12 -0
- package/dist/themes/SkandaDark.d.ts +12 -0
- package/dist/themes/SkandaDark.js +1 -0
- package/dist/themes/SkandaLight.cjs +1 -0
- package/dist/themes/SkandaLight.d.cts +3 -0
- package/dist/themes/SkandaLight.d.ts +3 -0
- package/dist/themes/SkandaLight.js +1 -0
- package/dist/themes/SolarizedDark.cjs +1 -0
- package/dist/themes/SolarizedDark.d.cts +9 -0
- package/dist/themes/SolarizedDark.d.ts +9 -0
- package/dist/themes/SolarizedDark.js +1 -0
- package/dist/themes/SolarizedLight.cjs +1 -0
- package/dist/themes/SolarizedLight.d.cts +9 -0
- package/dist/themes/SolarizedLight.d.ts +9 -0
- package/dist/themes/SolarizedLight.js +1 -0
- package/dist/themes/SynthwaveDark.cjs +1 -0
- package/dist/themes/SynthwaveDark.d.cts +9 -0
- package/dist/themes/SynthwaveDark.d.ts +9 -0
- package/dist/themes/SynthwaveDark.js +1 -0
- package/dist/themes/SynthwaveLight.cjs +1 -0
- package/dist/themes/SynthwaveLight.d.cts +12 -0
- package/dist/themes/SynthwaveLight.d.ts +12 -0
- package/dist/themes/SynthwaveLight.js +1 -0
- package/dist/themes/brands.cjs +1 -0
- package/dist/themes/brands.d.cts +41 -0
- package/dist/themes/brands.d.ts +41 -0
- package/dist/themes/brands.js +1 -0
- package/dist/themes/createBrandTheme.cjs +1 -0
- package/dist/themes/createBrandTheme.d.cts +55 -0
- package/dist/themes/createBrandTheme.d.ts +55 -0
- package/dist/themes/createBrandTheme.js +1 -0
- package/dist/themes/index.cjs +1 -0
- package/dist/themes/index.d.cts +41 -0
- package/dist/themes/index.d.ts +41 -0
- package/dist/themes/index.js +1 -0
- package/dist/themes.css +1 -0
- package/dist/tokens.css +1 -0
- package/dist/utils/aliases.cjs +9 -0
- package/dist/utils/aliases.d.cts +121 -0
- package/dist/utils/aliases.d.ts +121 -0
- package/dist/utils/aliases.js +9 -0
- package/dist/utils/contrast.cjs +1 -0
- package/dist/utils/contrast.d.cts +27 -0
- package/dist/utils/contrast.d.ts +27 -0
- package/dist/utils/contrast.js +1 -0
- package/dist/utils/cssVars.cjs +2 -0
- package/dist/utils/cssVars.d.cts +37 -0
- package/dist/utils/cssVars.d.ts +37 -0
- package/dist/utils/cssVars.js +2 -0
- package/dist/utils/foundation.cjs +15 -0
- package/dist/utils/foundation.d.cts +300 -0
- package/dist/utils/foundation.d.ts +300 -0
- package/dist/utils/foundation.js +15 -0
- package/dist/utils/mode.cjs +1 -0
- package/dist/utils/mode.d.cts +89 -0
- package/dist/utils/mode.d.ts +89 -0
- package/dist/utils/mode.js +1 -0
- package/dist/utils/theme.cjs +1 -0
- package/dist/utils/theme.d.cts +503 -0
- package/dist/utils/theme.d.ts +503 -0
- package/dist/utils/theme.js +1 -0
- package/dist/utils/toCss.cjs +10 -0
- package/dist/utils/toCss.d.cts +92 -0
- package/dist/utils/toCss.d.ts +92 -0
- package/dist/utils/toCss.js +10 -0
- package/package.json +70 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { type Theme } from './theme.js';
|
|
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
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* themeToCssVars(defaultTheme)
|
|
19
|
+
* // => { '--skdx-color-primary-500': '#3d6eef', '--skdx-shadow-color': '2 6 23', … }
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
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 */
|
|
26
|
+
export interface ThemeToCssOptions {
|
|
27
|
+
/**
|
|
28
|
+
* CSS selector the variables are scoped to.
|
|
29
|
+
* Defaults to `[data-skdx-theme="<name>"]` so multiple themes can coexist.
|
|
30
|
+
*/
|
|
31
|
+
selector?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
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.
|
|
37
|
+
*
|
|
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.
|
|
52
|
+
* @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
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* import { foundationToCss, themeToCss, skandaLight } from '@skdx/tokens';
|
|
58
|
+
* import fs from 'node:fs';
|
|
59
|
+
*
|
|
60
|
+
* fs.writeFileSync('skanda-light.css', foundationToCss() + themeToCss(skandaLight));
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
export declare function themeToCss(theme: Theme, options?: ThemeToCssOptions): string;
|
|
66
|
+
/**
|
|
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
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* import { applyTheme, midnightBrand } from '@skdx/tokens';
|
|
85
|
+
*
|
|
86
|
+
* applyTheme(midnightBrand); // whole page
|
|
87
|
+
* applyTheme(midnightBrand, document.getElementById('preview')!); // scoped subtree
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @public
|
|
91
|
+
*/
|
|
92
|
+
export declare function applyTheme(theme: Theme, element?: HTMLElement): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{reducedMotionVarNames as d,sectionsToCssVars as m,varsToDeclarations as u}from"./cssVars.js";import{defaultMotion as p}from"./theme.js";function i(n){return m([["color",n.colors],["shadow",n.shadow],["font",n.typography],["motion",n.motion?{...p,...n.motion}:void 0]])}function l(n,o={}){let e=o.selector??`[data-skdx-theme="${n.name}"]`,s=i(n),t=`${e} {
|
|
2
|
+
${u(s)}
|
|
3
|
+
}
|
|
4
|
+
`,r=d(s);if(r.length===0)return t;let a=r.map(c=>` ${c}: 0ms;`);return t+`@media (prefers-reduced-motion: reduce) {
|
|
5
|
+
${e} {
|
|
6
|
+
${a.join(`
|
|
7
|
+
`)}
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
`}function k(n,o=document.documentElement){let e=i(n);for(let[s,t]of Object.entries(e))o.style.setProperty(s,t);o.setAttribute("data-skdx-theme",n.name),o.setAttribute("data-skdx-mode",n.mode)}export{k as applyTheme,l as themeToCss,i as themeToCssVars};
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@skdx/tokens",
|
|
3
|
+
"version": "0.26.0",
|
|
4
|
+
"description": "Theme contract and design tokens for the SkandaDX design system",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://github.com/SkandaDX/ui.skdx/tree/main/packages/tokens#readme",
|
|
10
|
+
"repository": {
|
|
11
|
+
"directory": "packages/tokens",
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/SkandaDX/ui.skdx.git"
|
|
14
|
+
},
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/SkandaDX/ui.skdx/issues"
|
|
17
|
+
},
|
|
18
|
+
"type": "module",
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=18.18.0"
|
|
21
|
+
},
|
|
22
|
+
"main": "./dist/index.cjs",
|
|
23
|
+
"module": "./dist/index.js",
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"import": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"default": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"require": {
|
|
32
|
+
"types": "./dist/index.d.cts",
|
|
33
|
+
"default": "./dist/index.cjs"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"./themes/*": {
|
|
37
|
+
"types": "./dist/themes/*.d.ts",
|
|
38
|
+
"import": "./dist/themes/*.js",
|
|
39
|
+
"require": "./dist/themes/*.cjs"
|
|
40
|
+
},
|
|
41
|
+
"./css": "./dist/tokens.css",
|
|
42
|
+
"./foundation.css": "./dist/foundation.css",
|
|
43
|
+
"./themes.css": "./dist/themes.css",
|
|
44
|
+
"./package.json": "./package.json"
|
|
45
|
+
},
|
|
46
|
+
"sideEffects": [
|
|
47
|
+
"**/*.css"
|
|
48
|
+
],
|
|
49
|
+
"files": [
|
|
50
|
+
"dist",
|
|
51
|
+
"!dist/**/*.md",
|
|
52
|
+
"!dist/**/*.test.*",
|
|
53
|
+
"!dist/**/*.map"
|
|
54
|
+
],
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
57
|
+
"jsdom": "^29.1.1",
|
|
58
|
+
"tsup": "^8.5.1",
|
|
59
|
+
"typescript": "^6.0.3",
|
|
60
|
+
"vitest": "^4.1.10"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"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/minify-css.mjs dist",
|
|
64
|
+
"typecheck": "tsc --noEmit --incremental --tsBuildInfoFile node_modules/.cache/tsc/typecheck.tsbuildinfo",
|
|
65
|
+
"export:dtcg": "node scripts/export-dtcg.mjs",
|
|
66
|
+
"test": "vitest run",
|
|
67
|
+
"test:watch": "vitest",
|
|
68
|
+
"test:coverage": "vitest run --coverage"
|
|
69
|
+
}
|
|
70
|
+
}
|