@dsn-starter-kit/design-tokens 1.0.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 +287 -0
- package/dist/css/scoped/density-default.css +14 -0
- package/dist/css/scoped/density-information-dense.css +16 -0
- package/dist/css/scoped/wireframe-dark.css +340 -0
- package/dist/css/scoped/wireframe-light.css +340 -0
- package/dist/css/start-dark-default.css +1364 -0
- package/dist/css/start-dark-information-dense.css +1364 -0
- package/dist/css/start-light-default.css +1364 -0
- package/dist/css/start-light-information-dense.css +1364 -0
- package/dist/css/variables-dark.css +1364 -0
- package/dist/css/variables.css +1364 -0
- package/dist/css/wireframe-dark-default.css +1360 -0
- package/dist/css/wireframe-dark-information-dense.css +1360 -0
- package/dist/css/wireframe-light-default.css +1360 -0
- package/dist/css/wireframe-light-information-dense.css +1360 -0
- package/dist/js/start-dark-default.d.ts +1348 -0
- package/dist/js/start-dark-default.js +27420 -0
- package/dist/js/start-dark-information-dense.d.ts +1348 -0
- package/dist/js/start-dark-information-dense.js +27424 -0
- package/dist/js/start-light-default.d.ts +1348 -0
- package/dist/js/start-light-default.js +27418 -0
- package/dist/js/start-light-information-dense.d.ts +1348 -0
- package/dist/js/start-light-information-dense.js +27422 -0
- package/dist/js/tokens-dark.d.ts +1348 -0
- package/dist/js/tokens-dark.js +27420 -0
- package/dist/js/tokens.d.ts +1348 -0
- package/dist/js/tokens.js +27418 -0
- package/dist/js/wireframe-dark-default.d.ts +1344 -0
- package/dist/js/wireframe-dark-default.js +26975 -0
- package/dist/js/wireframe-dark-information-dense.d.ts +1344 -0
- package/dist/js/wireframe-dark-information-dense.js +26979 -0
- package/dist/js/wireframe-light-default.d.ts +1344 -0
- package/dist/js/wireframe-light-default.js +26975 -0
- package/dist/js/wireframe-light-information-dense.d.ts +1344 -0
- package/dist/js/wireframe-light-information-dense.js +26979 -0
- package/dist/json/start-dark-default.json +1350 -0
- package/dist/json/start-dark-information-dense.json +1350 -0
- package/dist/json/start-light-default.json +1350 -0
- package/dist/json/start-light-information-dense.json +1350 -0
- package/dist/json/tokens-dark.json +1350 -0
- package/dist/json/tokens.json +1350 -0
- package/dist/json/wireframe-dark-default.json +1346 -0
- package/dist/json/wireframe-dark-information-dense.json +1346 -0
- package/dist/json/wireframe-light-default.json +1346 -0
- package/dist/json/wireframe-light-information-dense.json +1346 -0
- package/dist/scss/_start-dark-default.scss +1351 -0
- package/dist/scss/_start-dark-information-dense.scss +1351 -0
- package/dist/scss/_start-light-default.scss +1351 -0
- package/dist/scss/_start-light-information-dense.scss +1351 -0
- package/dist/scss/_variables-dark.scss +1351 -0
- package/dist/scss/_variables.scss +1351 -0
- package/dist/scss/_wireframe-dark-default.scss +1347 -0
- package/dist/scss/_wireframe-dark-information-dense.scss +1347 -0
- package/dist/scss/_wireframe-light-default.scss +1347 -0
- package/dist/scss/_wireframe-light-information-dense.scss +1347 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jeffrey Lauwers
|
|
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
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
# @dsn-starter-kit/design-tokens
|
|
2
|
+
|
|
3
|
+
Design tokens for the design system: the single source of truth for colors, typography, spacing, sizing, borders, shadows, and more.
|
|
4
|
+
|
|
5
|
+
## Architecture
|
|
6
|
+
|
|
7
|
+
Tokens are organized in a **three-axis configuration model**:
|
|
8
|
+
|
|
9
|
+
| Axis | Values | Affects |
|
|
10
|
+
| ---------------- | ------------------------------ | -------------------------------------------------------- |
|
|
11
|
+
| **Theme** | `start`, `wireframe`, ... | All tokens (typography, spacing, borders, focus, colors) |
|
|
12
|
+
| **Mode** | `light`, `dark` | Only color tokens |
|
|
13
|
+
| **Project Type** | `default`, `information-dense` | Only font-size tokens |
|
|
14
|
+
|
|
15
|
+
This creates a matrix of configurations: **Theme × Mode × Project Type**.
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
start-light-default
|
|
19
|
+
start-light-information-dense
|
|
20
|
+
start-dark-default
|
|
21
|
+
start-dark-information-dense
|
|
22
|
+
wireframe-light-default
|
|
23
|
+
wireframe-light-information-dense
|
|
24
|
+
wireframe-dark-default
|
|
25
|
+
wireframe-dark-information-dense
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Why Three Axes?
|
|
29
|
+
|
|
30
|
+
- **Theme**: Defines the visual identity/branding. Different clients or products can have their own theme while sharing the same component library.
|
|
31
|
+
- **Mode**: Light/dark color schemes. Users can switch modes without changing the theme.
|
|
32
|
+
- **Project Type**: Typography density. Information-dense applications (dashboards, data tables) use fixed font sizes, while marketing sites use fluid typography.
|
|
33
|
+
|
|
34
|
+
## Folder Structure
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
src/tokens/
|
|
38
|
+
├── themes/
|
|
39
|
+
│ ├── start/ # Default theme
|
|
40
|
+
│ │ ├── base.json # Typography (excl font-size), spacing, sizing, borders, focus
|
|
41
|
+
│ │ ├── colors-light.json # Light mode colors
|
|
42
|
+
│ │ └── colors-dark.json # Dark mode colors
|
|
43
|
+
│ └── wireframe/ # Wireframe/prototype theme
|
|
44
|
+
│ ├── base.json # System fonts, minimal borders
|
|
45
|
+
│ ├── colors-light.json # Grayscale palette
|
|
46
|
+
│ └── colors-dark.json # Inverted grayscale
|
|
47
|
+
├── project-types/
|
|
48
|
+
│ ├── default/
|
|
49
|
+
│ │ └── typography.json # Fluid clamp() font-sizes
|
|
50
|
+
│ └── information-dense/
|
|
51
|
+
│ └── typography.json # Fixed font-sizes
|
|
52
|
+
└── components/
|
|
53
|
+
└── form-control.json # Component-level semantic tokens
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Token Categories
|
|
57
|
+
|
|
58
|
+
### In Theme Base (`themes/*/base.json`)
|
|
59
|
+
|
|
60
|
+
- **Typography**: Font families, weights, line heights
|
|
61
|
+
- **Spacing**: 5 concepts (block, inline, text, column, row)
|
|
62
|
+
- **Sizing**: Icon sizes (coupled to typography)
|
|
63
|
+
- **Borders**: Radius and width values
|
|
64
|
+
- **Focus States**: Accessible focus indicators
|
|
65
|
+
- **Form Controls**: Structural tokens (spacing, borders)
|
|
66
|
+
|
|
67
|
+
### In Theme Colors (`themes/*/colors-*.json`)
|
|
68
|
+
|
|
69
|
+
- **Colors**: 10 semantic color sets with full state coverage
|
|
70
|
+
- Neutral, Accent 1-3, Action 1-2, Positive, Negative, Warning, Info
|
|
71
|
+
- Each with: bg, border, color × document, subtle, default, hover, active
|
|
72
|
+
- Plus inverse variants for dark backgrounds
|
|
73
|
+
|
|
74
|
+
### In Project Type (`project-types/*/typography.json`)
|
|
75
|
+
|
|
76
|
+
- **Font Sizes**: sm, md, lg, xl, 2xl, 3xl, 4xl
|
|
77
|
+
- `default`: Fluid sizes using `clamp()` for responsive scaling
|
|
78
|
+
- `information-dense`: Fixed rem sizes for data-heavy UIs
|
|
79
|
+
|
|
80
|
+
## Installation
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
pnpm add @dsn-starter-kit/design-tokens
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Usage
|
|
87
|
+
|
|
88
|
+
### CSS Custom Properties
|
|
89
|
+
|
|
90
|
+
```css
|
|
91
|
+
/* Full configuration (recommended) */
|
|
92
|
+
@import '@dsn-starter-kit/design-tokens/dist/css/start-light-default.css';
|
|
93
|
+
|
|
94
|
+
/* Or use backward-compatible aliases */
|
|
95
|
+
@import '@dsn-starter-kit/design-tokens/css'; /* → start-light-default */
|
|
96
|
+
@import '@dsn-starter-kit/design-tokens/css/dark'; /* → start-dark-default */
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Available Configurations
|
|
100
|
+
|
|
101
|
+
| Configuration | Description |
|
|
102
|
+
| ----------------------------------- | --------------------------------------------- |
|
|
103
|
+
| `start-light-default` | Start theme, light mode, fluid typography |
|
|
104
|
+
| `start-light-information-dense` | Start theme, light mode, fixed typography |
|
|
105
|
+
| `start-dark-default` | Start theme, dark mode, fluid typography |
|
|
106
|
+
| `start-dark-information-dense` | Start theme, dark mode, fixed typography |
|
|
107
|
+
| `wireframe-light-default` | Wireframe theme, light mode, fluid typography |
|
|
108
|
+
| `wireframe-light-information-dense` | Wireframe theme, light mode, fixed typography |
|
|
109
|
+
| `wireframe-dark-default` | Wireframe theme, dark mode, fluid typography |
|
|
110
|
+
| `wireframe-dark-information-dense` | Wireframe theme, dark mode, fixed typography |
|
|
111
|
+
|
|
112
|
+
### SCSS
|
|
113
|
+
|
|
114
|
+
```scss
|
|
115
|
+
@import '@dsn-starter-kit/design-tokens/dist/scss/start-light-default';
|
|
116
|
+
|
|
117
|
+
/* Or backward-compatible */
|
|
118
|
+
@import '@dsn-starter-kit/design-tokens/scss';
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### JavaScript / TypeScript
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
import tokens from '@dsn-starter-kit/design-tokens/dist/js/start-light-default';
|
|
125
|
+
|
|
126
|
+
// Or backward-compatible
|
|
127
|
+
import tokens from '@dsn-starter-kit/design-tokens';
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Runtime Theme Switching
|
|
131
|
+
|
|
132
|
+
For applications that need to switch themes at runtime, import the full configuration CSS files dynamically:
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
function loadTheme(theme: string, mode: string, projectType: string) {
|
|
136
|
+
const configName = `${theme}-${mode}-${projectType}`;
|
|
137
|
+
|
|
138
|
+
// Remove existing theme stylesheet
|
|
139
|
+
document.querySelector('[data-dsn-theme]')?.remove();
|
|
140
|
+
|
|
141
|
+
// Load new configuration
|
|
142
|
+
const link = document.createElement('link');
|
|
143
|
+
link.rel = 'stylesheet';
|
|
144
|
+
link.href = `/path/to/design-tokens/dist/css/${configName}.css`;
|
|
145
|
+
link.setAttribute('data-dsn-theme', configName);
|
|
146
|
+
document.head.appendChild(link);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Example: Switch to wireframe dark mode
|
|
150
|
+
loadTheme('wireframe', 'dark', 'default');
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Output Formats
|
|
154
|
+
|
|
155
|
+
Built with [Style Dictionary](https://amzn.github.io/style-dictionary/), tokens are exported as:
|
|
156
|
+
|
|
157
|
+
| Format | Path Pattern |
|
|
158
|
+
| ---------------------- | ---------------------------------------------- |
|
|
159
|
+
| CSS Custom Properties | `dist/css/{theme}-{mode}-{projectType}.css` |
|
|
160
|
+
| SCSS Variables | `dist/scss/_{theme}-{mode}-{projectType}.scss` |
|
|
161
|
+
| JavaScript module | `dist/js/{theme}-{mode}-{projectType}.js` |
|
|
162
|
+
| TypeScript definitions | `dist/js/{theme}-{mode}-{projectType}.d.ts` |
|
|
163
|
+
| JSON | `dist/json/{theme}-{mode}-{projectType}.json` |
|
|
164
|
+
|
|
165
|
+
### Backward Compatibility Aliases
|
|
166
|
+
|
|
167
|
+
For existing consumers, these aliases are maintained:
|
|
168
|
+
|
|
169
|
+
| Alias | Points To |
|
|
170
|
+
| -------------------------------- | --------------------------- |
|
|
171
|
+
| `dist/css/variables.css` | `start-light-default.css` |
|
|
172
|
+
| `dist/css/variables-dark.css` | `start-dark-default.css` |
|
|
173
|
+
| `dist/scss/_variables.scss` | `_start-light-default.scss` |
|
|
174
|
+
| `dist/scss/_variables-dark.scss` | `_start-dark-default.scss` |
|
|
175
|
+
| `dist/js/tokens.js` | `start-light-default.js` |
|
|
176
|
+
| `dist/js/tokens-dark.js` | `start-dark-default.js` |
|
|
177
|
+
|
|
178
|
+
## Adding a New Theme
|
|
179
|
+
|
|
180
|
+
1. Create a new folder under `src/tokens/themes/`:
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
src/tokens/themes/my-theme/
|
|
184
|
+
├── base.json
|
|
185
|
+
├── colors-light.json
|
|
186
|
+
└── colors-dark.json
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
2. Copy an existing theme as a starting point:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
cp -r src/tokens/themes/start src/tokens/themes/my-theme
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
3. Update `src/config/config.js` to include your theme:
|
|
196
|
+
|
|
197
|
+
```js
|
|
198
|
+
const themes = ['start', 'wireframe', 'my-theme'];
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
4. Customize the token values in your new theme files.
|
|
202
|
+
|
|
203
|
+
5. Build:
|
|
204
|
+
```bash
|
|
205
|
+
pnpm build
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Adding a New Project Type
|
|
209
|
+
|
|
210
|
+
1. Create a new folder under `src/tokens/project-types/`:
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
src/tokens/project-types/my-density/
|
|
214
|
+
└── typography.json
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
2. Define font-size tokens (must include all sizes: sm, md, lg, xl, 2xl, 3xl, 4xl):
|
|
218
|
+
|
|
219
|
+
```json
|
|
220
|
+
{
|
|
221
|
+
"dsn": {
|
|
222
|
+
"text": {
|
|
223
|
+
"font-size": {
|
|
224
|
+
"sm": { "value": "0.75rem" },
|
|
225
|
+
"md": { "value": "0.875rem" },
|
|
226
|
+
...
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
3. Update `src/config/config.js`:
|
|
234
|
+
|
|
235
|
+
```js
|
|
236
|
+
const projectTypes = ['default', 'information-dense', 'my-density'];
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
4. Build.
|
|
240
|
+
|
|
241
|
+
## Theme Comparison
|
|
242
|
+
|
|
243
|
+
### Start Theme
|
|
244
|
+
|
|
245
|
+
- **Font**: IBM Plex Sans / IBM Plex Mono
|
|
246
|
+
- **Border radius**: 4px (sm), 8px (md), 16px (lg)
|
|
247
|
+
- **Colors**: Full brand palette with blues, greens, reds, oranges
|
|
248
|
+
- **Focus**: Yellow background with dashed outline (GOV.UK style)
|
|
249
|
+
|
|
250
|
+
### Wireframe Theme
|
|
251
|
+
|
|
252
|
+
- **Font**: System UI stack (system-ui, -apple-system, etc.)
|
|
253
|
+
- **Border radius**: 2px (sm), 4px (md), 8px (lg): more minimal
|
|
254
|
+
- **Colors**: Grayscale only: all semantic colors alias to neutral/accent-1
|
|
255
|
+
- **Focus**: Blue outline (standard browser style)
|
|
256
|
+
|
|
257
|
+
### Default vs Information-Dense
|
|
258
|
+
|
|
259
|
+
| Size | Default (Fluid) | Information-Dense (Fixed) |
|
|
260
|
+
| ---- | ------------------------------------------------ | ------------------------- |
|
|
261
|
+
| sm | `clamp(0.875rem, 0.75rem + 0.25vw, 1.0625rem)` | `0.875rem` |
|
|
262
|
+
| md | `clamp(1rem, 0.875rem + 0.375vw, 1.28125rem)` | `1rem` |
|
|
263
|
+
| lg | `clamp(1.25rem, 1.125rem + 0.375vw, 1.53125rem)` | `1.125rem` |
|
|
264
|
+
| xl | `clamp(1.5rem, 1.25rem + 0.625vw, 1.9375rem)` | `1.25rem` |
|
|
265
|
+
| 2xl | `clamp(2rem, 1.75rem + 0.75vw, 2.5625rem)` | `1.5rem` |
|
|
266
|
+
| 3xl | `clamp(2.5rem, 2.125rem + 1.125vw, 3.3125rem)` | `1.875rem` |
|
|
267
|
+
| 4xl | `clamp(3rem, 2.5rem + 1.5vw, 4.125rem)` | `2.25rem` |
|
|
268
|
+
|
|
269
|
+
## Building
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
pnpm --filter @dsn-starter-kit/design-tokens build
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## Storybook Integration
|
|
276
|
+
|
|
277
|
+
Storybook is configured with three toolbar controls:
|
|
278
|
+
|
|
279
|
+
- **Theme**: Switch between Start and Wireframe
|
|
280
|
+
- **Mode**: Switch between Light and Dark
|
|
281
|
+
- **Density**: Switch between Default (Fluid) and Information Dense (Fixed)
|
|
282
|
+
|
|
283
|
+
The TokenTable component shows live computed CSS values that update when you change these settings.
|
|
284
|
+
|
|
285
|
+
## License
|
|
286
|
+
|
|
287
|
+
MIT
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Do not edit directly
|
|
3
|
+
* Generated on Sat, 16 May 2026 08:34:09 GMT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
:root {
|
|
7
|
+
--dsn-text-font-size-sm: undefined;
|
|
8
|
+
--dsn-text-font-size-md: undefined;
|
|
9
|
+
--dsn-text-font-size-lg: undefined;
|
|
10
|
+
--dsn-text-font-size-xl: undefined;
|
|
11
|
+
--dsn-text-font-size-2xl: undefined;
|
|
12
|
+
--dsn-text-font-size-3xl: undefined;
|
|
13
|
+
--dsn-text-font-size-4xl: undefined;
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Do not edit directly
|
|
3
|
+
* Generated on Sat, 16 May 2026 08:34:09 GMT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
.dsn-density-dense {
|
|
7
|
+
--dsn-grid-gutter: undefined;
|
|
8
|
+
--dsn-grid-row-gap: undefined;
|
|
9
|
+
--dsn-text-font-size-sm: undefined;
|
|
10
|
+
--dsn-text-font-size-md: undefined;
|
|
11
|
+
--dsn-text-font-size-lg: undefined;
|
|
12
|
+
--dsn-text-font-size-xl: undefined;
|
|
13
|
+
--dsn-text-font-size-2xl: undefined;
|
|
14
|
+
--dsn-text-font-size-3xl: undefined;
|
|
15
|
+
--dsn-text-font-size-4xl: undefined;
|
|
16
|
+
}
|