@asafarim/design-tokens 0.4.5 → 0.4.9
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/CHANGELOG.md +26 -20
- package/LICENSE +21 -21
- package/README.md +139 -139
- package/css/index.css +8 -8
- package/css/tokens.base.css +168 -168
- package/css/tokens.dark.css +162 -162
- package/css/tokens.density.comfortable.css +6 -6
- package/css/tokens.density.compact.css +6 -6
- package/css/tokens.high-contrast.css +162 -162
- package/css/tokens.light.css +162 -162
- package/css/tokens.rtl.css +3 -3
- package/css/tokens.utilities.css +16 -16
- package/package.json +2 -2
- package/src/build/index.ts +5 -5
- package/src/build/toCssVars.ts +31 -31
- package/src/build/toJson.ts +20 -20
- package/src/build/validate.ts +90 -90
- package/src/core/types.ts +29 -29
- package/src/core/utils.ts +42 -42
- package/src/index.ts +60 -60
- package/src/themes/dark.ts +64 -64
- package/src/themes/densityComfortable.ts +11 -11
- package/src/themes/densityCompact.ts +11 -11
- package/src/themes/highContrast.ts +60 -60
- package/src/themes/index.ts +21 -21
- package/src/themes/light.ts +64 -64
- package/src/tokens/color/accent.ts +20 -20
- package/src/tokens/color/brand.ts +41 -41
- package/src/tokens/color/dataViz.ts +20 -20
- package/src/tokens/color/gradients.ts +13 -13
- package/src/tokens/color/index.ts +7 -7
- package/src/tokens/color/neutral.ts +32 -32
- package/src/tokens/color/overlays.ts +21 -21
- package/src/tokens/color/semantic.ts +36 -36
- package/src/tokens/effects/blur.ts +7 -7
- package/src/tokens/effects/index.ts +4 -4
- package/src/tokens/effects/opacity.ts +11 -11
- package/src/tokens/effects/shadows.ts +20 -20
- package/src/tokens/effects/textures.ts +11 -11
- package/src/tokens/iconography/index.ts +2 -2
- package/src/tokens/iconography/sizes.ts +9 -9
- package/src/tokens/iconography/strokeWidths.ts +7 -7
- package/src/tokens/index.ts +21 -21
- package/src/tokens/motion/duration.ts +7 -7
- package/src/tokens/motion/easing.ts +8 -8
- package/src/tokens/motion/index.ts +4 -4
- package/src/tokens/motion/reducedMotion.ts +9 -9
- package/src/tokens/motion/transitions.ts +16 -16
- package/src/tokens/shape/borders.ts +7 -7
- package/src/tokens/shape/index.ts +3 -3
- package/src/tokens/shape/radii.ts +9 -9
- package/src/tokens/shape/strokes.ts +7 -7
- package/src/tokens/spacing/density.ts +12 -12
- package/src/tokens/spacing/grid.ts +28 -28
- package/src/tokens/spacing/index.ts +5 -5
- package/src/tokens/spacing/layout.ts +20 -20
- package/src/tokens/spacing/rtl.ts +20 -20
- package/src/tokens/spacing/scale.ts +15 -15
- package/src/tokens/typography/families.ts +14 -14
- package/src/tokens/typography/headings.ts +29 -29
- package/src/tokens/typography/index.ts +7 -7
- package/src/tokens/typography/letterSpacing.ts +7 -7
- package/src/tokens/typography/lineHeights.ts +13 -13
- package/src/tokens/typography/responsive.ts +21 -21
- package/src/tokens/typography/sizes.ts +14 -14
- package/src/tokens/typography/weights.ts +13 -13
- package/src/tokens/ui/button.ts +25 -25
- package/src/tokens/ui/focus.ts +7 -7
- package/src/tokens/ui/index.ts +5 -5
- package/src/tokens/ui/input.ts +12 -12
- package/src/tokens/ui/overlay.ts +6 -6
- package/src/tokens/ui/surface.ts +9 -9
- package/src/tokens/zindex/index.ts +1 -1
- package/src/tokens/zindex/scale.ts +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,20 +1,26 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to `@asafarim/design-tokens` will be documented in this file.
|
|
4
|
-
|
|
5
|
-
This project follows [Semantic Versioning](https://semver.org/).
|
|
6
|
-
|
|
7
|
-
## 0.4.
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@asafarim/design-tokens` will be documented in this file.
|
|
4
|
+
|
|
5
|
+
This project follows [Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## 0.4.6
|
|
8
|
+
|
|
9
|
+
- Fixed GitHub Actions workflow to work without lock file
|
|
10
|
+
- Removed frozen-lockfile requirement from CI/CD
|
|
11
|
+
- Made package independent from monorepo workspace
|
|
12
|
+
|
|
13
|
+
## 0.4.4
|
|
14
|
+
|
|
15
|
+
- Added automated GitHub Pages demo deployment
|
|
16
|
+
- Demo app now deployed to https://alisafari-it.github.io/design-tokens/
|
|
17
|
+
- Fixed GitHub Actions workflow environment configuration
|
|
18
|
+
- Updated package homepage to point to live demo
|
|
19
|
+
|
|
20
|
+
## 0.1.0
|
|
21
|
+
|
|
22
|
+
- Initial release.
|
|
23
|
+
- Added token model with strongly typed token tree.
|
|
24
|
+
- Added CSS variable output (`--asm-*`) for base + light/dark/high-contrast + density + RTL.
|
|
25
|
+
- Added theme helpers (`applyThemeToElement`, `prefersColorScheme`).
|
|
26
|
+
- Added build helpers (`toCssVars`, `toJson`, `validateTokens`).
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 ASafariM
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 ASafariM
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,139 +1,139 @@
|
|
|
1
|
-
# @asafarim/design-tokens
|
|
2
|
-
|
|
3
|
-
A production-grade design-tokens package for the ASafariM ecosystem.
|
|
4
|
-
|
|
5
|
-
This package provides:
|
|
6
|
-
|
|
7
|
-
- CSS variables (runtime theming) for:
|
|
8
|
-
- light / dark / high-contrast
|
|
9
|
-
- density (compact / comfortable)
|
|
10
|
-
- RTL support (logical property guidance)
|
|
11
|
-
- TypeScript exports for strongly-typed token consumption
|
|
12
|
-
- Programmatic theming helpers (SSR-safe)
|
|
13
|
-
- Validation utilities for safe token evolution
|
|
14
|
-
|
|
15
|
-
## Why design tokens
|
|
16
|
-
|
|
17
|
-
Design tokens are the single source of truth for design decisions (color, typography, spacing, motion…).
|
|
18
|
-
|
|
19
|
-
- **Consistency** across apps (React/Angular/Vue/vanilla)
|
|
20
|
-
- **Themeability** at runtime via CSS variables
|
|
21
|
-
- **Governance**: controlled evolution with semantic versioning
|
|
22
|
-
|
|
23
|
-
## Install
|
|
24
|
-
|
|
25
|
-
From the monorepo root (pnpm workspaces):
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
pnpm -C packages/design-tokens build
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
In a consuming package/app:
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
pnpm add @asafarim/design-tokens
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## CSS usage (any framework)
|
|
38
|
-
|
|
39
|
-
Import the CSS entrypoint once at app startup:
|
|
40
|
-
|
|
41
|
-
```ts
|
|
42
|
-
import "@asafarim/design-tokens/css";
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
This ships a layered CSS setup:
|
|
46
|
-
|
|
47
|
-
1. `:root` base tokens (spacing, typography, motion, radii, z-index…)
|
|
48
|
-
2. `[data-theme]` theme tokens (colors, surfaces)
|
|
49
|
-
3. `[data-density]` density tokens
|
|
50
|
-
4. `[dir="rtl"]` RTL helpers
|
|
51
|
-
|
|
52
|
-
### Playground screenshots
|
|
53
|
-
|
|
54
|
-

|
|
55
|
-
|
|
56
|
-

|
|
57
|
-
|
|
58
|
-
### Theme switching
|
|
59
|
-
|
|
60
|
-
```ts
|
|
61
|
-
document.documentElement.dataset.theme = "light";
|
|
62
|
-
// or
|
|
63
|
-
document.documentElement.dataset.theme = "dark";
|
|
64
|
-
// or
|
|
65
|
-
document.documentElement.dataset.contrast = "high";
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### Density switching
|
|
69
|
-
|
|
70
|
-
```ts
|
|
71
|
-
document.documentElement.dataset.density = "compact";
|
|
72
|
-
// or
|
|
73
|
-
document.documentElement.dataset.density = "comfortable";
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## TypeScript usage
|
|
77
|
-
|
|
78
|
-
```ts
|
|
79
|
-
import { tokens, themes, applyThemeToElement } from "@asafarim/design-tokens";
|
|
80
|
-
|
|
81
|
-
console.log(tokens.color.brand.primary500.value); // "#3A5AFE"
|
|
82
|
-
|
|
83
|
-
applyThemeToElement(document.documentElement, themes.light);
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### Accessing CSS variable names
|
|
87
|
-
|
|
88
|
-
```ts
|
|
89
|
-
import { cssVarNames } from "@asafarim/design-tokens";
|
|
90
|
-
|
|
91
|
-
// dot-path -> CSS var
|
|
92
|
-
console.log(cssVarNames["color.brand.primary500"]); // "--asm-color-brand-primary-500"
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
## SSR safety
|
|
96
|
-
|
|
97
|
-
- `prefersColorScheme()` will not crash when `window` is unavailable.
|
|
98
|
-
- `applyThemeToElement()` can be used in tests or SSR hydration flows.
|
|
99
|
-
|
|
100
|
-
## Client overrides (branding)
|
|
101
|
-
|
|
102
|
-
You can apply partial overrides without forking the package:
|
|
103
|
-
|
|
104
|
-
```ts
|
|
105
|
-
import { applyThemeToElement, themes } from "@asafarim/design-tokens";
|
|
106
|
-
|
|
107
|
-
applyThemeToElement(document.documentElement, themes.light, {
|
|
108
|
-
overrides: {
|
|
109
|
-
"--asm-color-brand-primary-500": "#00A3FF"
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
## High-contrast + reduced motion guidance
|
|
115
|
-
|
|
116
|
-
- High contrast is enabled using `[data-contrast="high"]`.
|
|
117
|
-
- Reduced motion is handled via `@media (prefers-reduced-motion: reduce)` and the motion preset tokens.
|
|
118
|
-
|
|
119
|
-
## Contribution rules (token governance)
|
|
120
|
-
|
|
121
|
-
- **Never rename or delete** existing semantic token keys in a minor/patch release.
|
|
122
|
-
- **Prefer adding** new semantic tokens, deprecating old ones with `meta.deprecated`.
|
|
123
|
-
- When changing a value of an existing token:
|
|
124
|
-
- Patch: only if it’s a clear bug fix (e.g., invalid color)
|
|
125
|
-
- Minor: safe visual adjustments
|
|
126
|
-
- Major: visual/systemic shifts
|
|
127
|
-
|
|
128
|
-
Run validation before publishing:
|
|
129
|
-
|
|
130
|
-
```bash
|
|
131
|
-
pnpm -C packages/design-tokens build
|
|
132
|
-
node -e "import('@asafarim/design-tokens').then(m => console.log(m.validateTokens()))"
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
## Versioning rules
|
|
136
|
-
|
|
137
|
-
- **PATCH**: bug fixes, documentation, token metadata
|
|
138
|
-
- **MINOR**: additive tokens, new themes, non-breaking build changes
|
|
139
|
-
- **MAJOR**: renames/removals, behavior changes in theming helpers, breaking token semantics
|
|
1
|
+
# @asafarim/design-tokens
|
|
2
|
+
|
|
3
|
+
A production-grade design-tokens package for the ASafariM ecosystem.
|
|
4
|
+
|
|
5
|
+
This package provides:
|
|
6
|
+
|
|
7
|
+
- CSS variables (runtime theming) for:
|
|
8
|
+
- light / dark / high-contrast
|
|
9
|
+
- density (compact / comfortable)
|
|
10
|
+
- RTL support (logical property guidance)
|
|
11
|
+
- TypeScript exports for strongly-typed token consumption
|
|
12
|
+
- Programmatic theming helpers (SSR-safe)
|
|
13
|
+
- Validation utilities for safe token evolution
|
|
14
|
+
|
|
15
|
+
## Why design tokens
|
|
16
|
+
|
|
17
|
+
Design tokens are the single source of truth for design decisions (color, typography, spacing, motion…).
|
|
18
|
+
|
|
19
|
+
- **Consistency** across apps (React/Angular/Vue/vanilla)
|
|
20
|
+
- **Themeability** at runtime via CSS variables
|
|
21
|
+
- **Governance**: controlled evolution with semantic versioning
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
From the monorepo root (pnpm workspaces):
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pnpm -C packages/design-tokens build
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
In a consuming package/app:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pnpm add @asafarim/design-tokens
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## CSS usage (any framework)
|
|
38
|
+
|
|
39
|
+
Import the CSS entrypoint once at app startup:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import "@asafarim/design-tokens/css";
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
This ships a layered CSS setup:
|
|
46
|
+
|
|
47
|
+
1. `:root` base tokens (spacing, typography, motion, radii, z-index…)
|
|
48
|
+
2. `[data-theme]` theme tokens (colors, surfaces)
|
|
49
|
+
3. `[data-density]` density tokens
|
|
50
|
+
4. `[dir="rtl"]` RTL helpers
|
|
51
|
+
|
|
52
|
+
### Playground screenshots
|
|
53
|
+
|
|
54
|
+

|
|
55
|
+
|
|
56
|
+

|
|
57
|
+
|
|
58
|
+
### Theme switching
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
document.documentElement.dataset.theme = "light";
|
|
62
|
+
// or
|
|
63
|
+
document.documentElement.dataset.theme = "dark";
|
|
64
|
+
// or
|
|
65
|
+
document.documentElement.dataset.contrast = "high";
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Density switching
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
document.documentElement.dataset.density = "compact";
|
|
72
|
+
// or
|
|
73
|
+
document.documentElement.dataset.density = "comfortable";
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## TypeScript usage
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
import { tokens, themes, applyThemeToElement } from "@asafarim/design-tokens";
|
|
80
|
+
|
|
81
|
+
console.log(tokens.color.brand.primary500.value); // "#3A5AFE"
|
|
82
|
+
|
|
83
|
+
applyThemeToElement(document.documentElement, themes.light);
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Accessing CSS variable names
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import { cssVarNames } from "@asafarim/design-tokens";
|
|
90
|
+
|
|
91
|
+
// dot-path -> CSS var
|
|
92
|
+
console.log(cssVarNames["color.brand.primary500"]); // "--asm-color-brand-primary-500"
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## SSR safety
|
|
96
|
+
|
|
97
|
+
- `prefersColorScheme()` will not crash when `window` is unavailable.
|
|
98
|
+
- `applyThemeToElement()` can be used in tests or SSR hydration flows.
|
|
99
|
+
|
|
100
|
+
## Client overrides (branding)
|
|
101
|
+
|
|
102
|
+
You can apply partial overrides without forking the package:
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
import { applyThemeToElement, themes } from "@asafarim/design-tokens";
|
|
106
|
+
|
|
107
|
+
applyThemeToElement(document.documentElement, themes.light, {
|
|
108
|
+
overrides: {
|
|
109
|
+
"--asm-color-brand-primary-500": "#00A3FF"
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## High-contrast + reduced motion guidance
|
|
115
|
+
|
|
116
|
+
- High contrast is enabled using `[data-contrast="high"]`.
|
|
117
|
+
- Reduced motion is handled via `@media (prefers-reduced-motion: reduce)` and the motion preset tokens.
|
|
118
|
+
|
|
119
|
+
## Contribution rules (token governance)
|
|
120
|
+
|
|
121
|
+
- **Never rename or delete** existing semantic token keys in a minor/patch release.
|
|
122
|
+
- **Prefer adding** new semantic tokens, deprecating old ones with `meta.deprecated`.
|
|
123
|
+
- When changing a value of an existing token:
|
|
124
|
+
- Patch: only if it’s a clear bug fix (e.g., invalid color)
|
|
125
|
+
- Minor: safe visual adjustments
|
|
126
|
+
- Major: visual/systemic shifts
|
|
127
|
+
|
|
128
|
+
Run validation before publishing:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
pnpm -C packages/design-tokens build
|
|
132
|
+
node -e "import('@asafarim/design-tokens').then(m => console.log(m.validateTokens()))"
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Versioning rules
|
|
136
|
+
|
|
137
|
+
- **PATCH**: bug fixes, documentation, token metadata
|
|
138
|
+
- **MINOR**: additive tokens, new themes, non-breaking build changes
|
|
139
|
+
- **MAJOR**: renames/removals, behavior changes in theming helpers, breaking token semantics
|
package/css/index.css
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
@import "./tokens.base.css";
|
|
2
|
-
@import "./tokens.light.css";
|
|
3
|
-
@import "./tokens.dark.css";
|
|
4
|
-
@import "./tokens.high-contrast.css";
|
|
5
|
-
@import "./tokens.density.compact.css";
|
|
6
|
-
@import "./tokens.density.comfortable.css";
|
|
7
|
-
@import "./tokens.rtl.css";
|
|
8
|
-
@import "./tokens.utilities.css";
|
|
1
|
+
@import "./tokens.base.css";
|
|
2
|
+
@import "./tokens.light.css";
|
|
3
|
+
@import "./tokens.dark.css";
|
|
4
|
+
@import "./tokens.high-contrast.css";
|
|
5
|
+
@import "./tokens.density.compact.css";
|
|
6
|
+
@import "./tokens.density.comfortable.css";
|
|
7
|
+
@import "./tokens.rtl.css";
|
|
8
|
+
@import "./tokens.utilities.css";
|