@beam-ui/design-tokens 1.0.0 → 2.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/CHANGELOG.md +13 -1
- package/LICENSE +21 -0
- package/README.md +240 -319
- package/build/base/tokens.es6.js +9 -6
- package/build/base/tokens.json +9 -6
- package/build/base/variables.css +7 -6
- package/build/semantic/tokens.es6.js +46 -16
- package/build/semantic/tokens.json +39 -16
- package/build/semantic/variables.css +29 -8
- package/package.json +10 -7
- package/USAGE.md +0 -286
package/USAGE.md
DELETED
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
# Beam UI Design Tokens - Usage Guide
|
|
2
|
-
|
|
3
|
-
A centralized collection of design decisions and other artifacts for the Beam UI Design System.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
Design tokens are the visual design atoms — specifically, they are named entities that store various design decisions. This package provides these tokens in multiple formats for consistent use across applications.
|
|
8
|
-
|
|
9
|
-
## Installation
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npm install @beam-ui/design-tokens
|
|
13
|
-
# or
|
|
14
|
-
yarn add @beam-ui/design-tokens
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Available Output Formats
|
|
18
|
-
|
|
19
|
-
All tokens are available in three formats:
|
|
20
|
-
- **CSS Variables** (`variables.css`) - CSS custom properties
|
|
21
|
-
- **JavaScript ES6** (`tokens.es6.js`) - ES6 module exports
|
|
22
|
-
- **JSON** (`tokens.json`) - Nested JSON structure
|
|
23
|
-
|
|
24
|
-
## Token Layers
|
|
25
|
-
|
|
26
|
-
Tokens are organized in three layers:
|
|
27
|
-
|
|
28
|
-
- **`build/globals/`** - Global tokens (breakpoints, accessibility, etc.)
|
|
29
|
-
- **`build/base/`** - Default base tokens (colors, fonts, spacing, etc.)
|
|
30
|
-
- **`build/semantic/`** - Default semantic tokens (buttons, typography, etc.)
|
|
31
|
-
|
|
32
|
-
Brand-specific tokens can be found at `build/{brand}/base/` and `build/{brand}/semantic/` if custom brands exist.
|
|
33
|
-
|
|
34
|
-
## Usage
|
|
35
|
-
|
|
36
|
-
### Using CSS Variables
|
|
37
|
-
|
|
38
|
-
#### Important: Semantic Tokens Require Base and Global Tokens
|
|
39
|
-
|
|
40
|
-
**Semantic CSS tokens reference base and global tokens using CSS custom properties (`var()`)**, which means you must import all token files in the correct order for semantic tokens to work correctly.
|
|
41
|
-
|
|
42
|
-
#### Recommended Import Order
|
|
43
|
-
|
|
44
|
-
```css
|
|
45
|
-
/* Import in this order: */
|
|
46
|
-
@import '@beam-ui/design-tokens/build/globals/variables.css';
|
|
47
|
-
@import '@beam-ui/design-tokens/build/base/variables.css';
|
|
48
|
-
@import '@beam-ui/design-tokens/build/semantic/variables.css';
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Or in your HTML:
|
|
52
|
-
```html
|
|
53
|
-
<link rel="stylesheet" href="node_modules/@beam-ui/design-tokens/build/globals/variables.css">
|
|
54
|
-
<link rel="stylesheet" href="node_modules/@beam-ui/design-tokens/build/base/variables.css">
|
|
55
|
-
<link rel="stylesheet" href="node_modules/@beam-ui/design-tokens/build/semantic/variables.css">
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
#### Why All Three Files Are Required
|
|
59
|
-
|
|
60
|
-
Tokens use `var()` references to maintain relationships across all layers:
|
|
61
|
-
|
|
62
|
-
```css
|
|
63
|
-
/* 1. Global tokens define shared values */
|
|
64
|
-
:root {
|
|
65
|
-
--breakpoint-medium: 768px;
|
|
66
|
-
--a11y-min-touch-target: 40px;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/* 2. Base tokens define the actual brand values */
|
|
70
|
-
:root {
|
|
71
|
-
--color-gray-black: hsl(0, 0%, 0%);
|
|
72
|
-
--color-gray-white: hsl(0, 0%, 100%);
|
|
73
|
-
--color-transparent: hsla(0, 0%, 0%, 0);
|
|
74
|
-
--font-size-medium: 1.6rem;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/* 3. Semantic tokens reference base and global tokens */
|
|
78
|
-
:root {
|
|
79
|
-
--button-primary-background: var(--color-gray-black);
|
|
80
|
-
--button-primary-text: var(--color-gray-white);
|
|
81
|
-
--button-tertiary-border: var(--color-transparent);
|
|
82
|
-
--button-primary-font-size: var(--font-size-medium);
|
|
83
|
-
--button-size-sm-min-width: var(--a11y-min-touch-target);
|
|
84
|
-
}
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
#### Benefits of This Approach
|
|
88
|
-
|
|
89
|
-
- **Single source of truth** - Update base token values and all semantic tokens automatically reflect the change
|
|
90
|
-
- **Smaller file sizes** - References are more efficient than duplicated values
|
|
91
|
-
- **Runtime flexibility** - Override base tokens to theme entire components
|
|
92
|
-
- **Maintainability** - Clear relationships between foundation and application layers
|
|
93
|
-
|
|
94
|
-
#### Using Only Base Tokens
|
|
95
|
-
|
|
96
|
-
If you only need base tokens (colors, spacing, fonts) without semantic tokens, you can import just the base and global files:
|
|
97
|
-
|
|
98
|
-
```css
|
|
99
|
-
@import '@beam-ui/design-tokens/build/globals/variables.css';
|
|
100
|
-
@import '@beam-ui/design-tokens/build/base/variables.css';
|
|
101
|
-
|
|
102
|
-
.custom-button {
|
|
103
|
-
background-color: var(--color-gray-black);
|
|
104
|
-
padding: var(--spacing-medium);
|
|
105
|
-
font-size: var(--font-size-medium);
|
|
106
|
-
min-height: var(--a11y-min-touch-target);
|
|
107
|
-
}
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
**Note:** Base tokens may reference global tokens (like accessibility values), so it's recommended to include globals even when not using semantic tokens.
|
|
111
|
-
|
|
112
|
-
### Using JavaScript/TypeScript Tokens
|
|
113
|
-
|
|
114
|
-
JavaScript and JSON formats output resolved values, so semantic tokens can be used independently:
|
|
115
|
-
|
|
116
|
-
```javascript
|
|
117
|
-
// Semantic tokens contain resolved values
|
|
118
|
-
import { buttonPrimaryBackground, buttonPrimaryText } from '@beam-ui/design-tokens/build/semantic/tokens.es6.js';
|
|
119
|
-
|
|
120
|
-
const button = {
|
|
121
|
-
backgroundColor: buttonPrimaryBackground, // "hsl(0, 0%, 0%)"
|
|
122
|
-
color: buttonPrimaryText // "hsl(0, 0%, 100%)"
|
|
123
|
-
};
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
#### Importing Base Tokens
|
|
127
|
-
|
|
128
|
-
```javascript
|
|
129
|
-
import { colorGrayBlack, fontSizeMedium, spacingLarge } from '@beam-ui/design-tokens/build/base/tokens.es6.js';
|
|
130
|
-
|
|
131
|
-
const styles = {
|
|
132
|
-
color: colorGrayBlack, // "hsl(0, 0%, 0%)"
|
|
133
|
-
fontSize: fontSizeMedium, // "1.6rem"
|
|
134
|
-
padding: spacingLarge // "2.4rem"
|
|
135
|
-
};
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
#### Importing Global Tokens
|
|
139
|
-
|
|
140
|
-
```javascript
|
|
141
|
-
import { breakpointMedium, a11yMinTouchTarget } from '@beam-ui/design-tokens/build/globals/tokens.es6.js';
|
|
142
|
-
|
|
143
|
-
const config = {
|
|
144
|
-
breakpoint: breakpointMedium, // "768px"
|
|
145
|
-
minTouchSize: a11yMinTouchTarget // "40px"
|
|
146
|
-
};
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
### Using JSON Tokens
|
|
150
|
-
|
|
151
|
-
JSON format provides a nested structure:
|
|
152
|
-
|
|
153
|
-
```javascript
|
|
154
|
-
import tokens from '@beam-ui/design-tokens/build/semantic/tokens.json';
|
|
155
|
-
|
|
156
|
-
console.log(tokens.button.primary.background); // "hsl(0, 0%, 0%)"
|
|
157
|
-
console.log(tokens.color.background.primary); // "hsl(0, 0%, 100%)"
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
## Token Reference
|
|
161
|
-
|
|
162
|
-
### Global Tokens
|
|
163
|
-
|
|
164
|
-
**Breakpoints**
|
|
165
|
-
- `breakpoint-small`, `breakpoint-medium`, `breakpoint-large`, `breakpoint-x-large`
|
|
166
|
-
|
|
167
|
-
**Accessibility**
|
|
168
|
-
- `a11y-min-touch-target` - Minimum touch target size for interactive elements
|
|
169
|
-
|
|
170
|
-
### Base Tokens
|
|
171
|
-
|
|
172
|
-
**Colors**
|
|
173
|
-
- Brand colors: `color-tatari-red`, `color-tatari-blue`, etc.
|
|
174
|
-
- Gray scale: `color-gray-black`, `color-gray-800` through `color-gray-50`, `color-gray-white`
|
|
175
|
-
- Color palettes: `color-red-*`, `color-blue-*`, `color-green-*`, etc. (100-700 scales)
|
|
176
|
-
- Special: `color-transparent`, `color-overlay-dark`, `color-overlay-light`
|
|
177
|
-
|
|
178
|
-
**Typography**
|
|
179
|
-
- Font sizes: `font-size-xx-small` through `font-size-xxx-large`
|
|
180
|
-
- Line heights: `line-height-xx-small` through `line-height-xxx-large`
|
|
181
|
-
- Letter spacing: `letter-spacing-xx-small` through `letter-spacing-xxx-large`
|
|
182
|
-
|
|
183
|
-
**Spacing**
|
|
184
|
-
- `spacing-xx-small` through `spacing-xxx-large`
|
|
185
|
-
|
|
186
|
-
**Borders**
|
|
187
|
-
- Border radius: `border-radius-xx-small` through `border-radius-xxx-large`, `border-radius-circle`
|
|
188
|
-
- Border width: `border-width-thin`, `border-width-regular`, `border-width-thick`
|
|
189
|
-
|
|
190
|
-
### Semantic Tokens
|
|
191
|
-
|
|
192
|
-
**Button Tokens**
|
|
193
|
-
- Variants: `button-primary-*`, `button-secondary-*`, `button-tertiary-*`
|
|
194
|
-
- Danger states: `button-danger-primary-*`, `button-danger-secondary-*`
|
|
195
|
-
- States: `-background`, `-background-hover`, `-background-active`, `-background-disabled`
|
|
196
|
-
- Text: `-text`, `-text-hover`, `-text-active`, `-text-disabled`
|
|
197
|
-
- Border: `-border`, `-border-hover`, `-border-active`, `-border-disabled`
|
|
198
|
-
- Sizes: `button-size-sm-*`, `button-size-md-*`, `button-size-lg-*`
|
|
199
|
-
|
|
200
|
-
**Color Tokens**
|
|
201
|
-
- Background: `color-background-primary`, `color-background-secondary`, etc.
|
|
202
|
-
- Surface: `color-surface-primary`, `color-surface-hover`, etc.
|
|
203
|
-
- Border: `color-border-primary`, `color-border-focus`, etc.
|
|
204
|
-
- Text: `color-text-primary`, `color-text-link`, etc.
|
|
205
|
-
- Icon: `color-icon-primary`, `color-icon-interactive`, etc.
|
|
206
|
-
- Interactive states: `color-interactive-primary-default`, etc.
|
|
207
|
-
- Status colors: `color-status-success-base`, `color-status-error-base`, etc.
|
|
208
|
-
- Brand colors: `color-brand-primary-base`, `color-brand-secondary-base`, etc.
|
|
209
|
-
|
|
210
|
-
**Typography Tokens**
|
|
211
|
-
- Headings: `typography-heading-100-*` through `typography-heading-600-*`
|
|
212
|
-
- Body text: `typography-body-100-*`, `typography-body-200-*`
|
|
213
|
-
- Captions: `typography-caption-100-*`, `typography-caption-200-*`
|
|
214
|
-
- Properties: `-font-size`, `-line-height`, `-letter-spacing`
|
|
215
|
-
|
|
216
|
-
## Examples
|
|
217
|
-
|
|
218
|
-
### Complete Button Component (CSS)
|
|
219
|
-
|
|
220
|
-
```css
|
|
221
|
-
/* Import all required token files */
|
|
222
|
-
@import '@beam-ui/design-tokens/build/globals/variables.css';
|
|
223
|
-
@import '@beam-ui/design-tokens/build/base/variables.css';
|
|
224
|
-
@import '@beam-ui/design-tokens/build/semantic/variables.css';
|
|
225
|
-
|
|
226
|
-
.button-primary {
|
|
227
|
-
background-color: var(--button-primary-background);
|
|
228
|
-
color: var(--button-primary-text);
|
|
229
|
-
border: var(--button-primary-border-width) solid var(--button-primary-border);
|
|
230
|
-
border-radius: var(--button-primary-border-radius);
|
|
231
|
-
font-size: var(--button-primary-font-size);
|
|
232
|
-
line-height: var(--button-primary-line-height);
|
|
233
|
-
padding-inline: var(--button-size-md-padding-inline);
|
|
234
|
-
padding-block: var(--button-size-md-padding-block);
|
|
235
|
-
min-width: var(--button-size-md-min-width);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
.button-primary:hover {
|
|
239
|
-
background-color: var(--button-primary-background-hover);
|
|
240
|
-
color: var(--button-primary-text-hover);
|
|
241
|
-
border-color: var(--button-primary-border-hover);
|
|
242
|
-
}
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
### React Component with TypeScript
|
|
246
|
-
|
|
247
|
-
```typescript
|
|
248
|
-
import {
|
|
249
|
-
buttonPrimaryBackground,
|
|
250
|
-
buttonPrimaryText,
|
|
251
|
-
buttonPrimaryBorderRadius,
|
|
252
|
-
buttonSizeMdPaddingInline,
|
|
253
|
-
buttonSizeMdPaddingBlock
|
|
254
|
-
} from '@beam-ui/design-tokens/build/semantic/tokens.es6.js';
|
|
255
|
-
|
|
256
|
-
interface ButtonProps {
|
|
257
|
-
children: React.ReactNode;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
export const Button: React.FC<ButtonProps> = ({ children }) => {
|
|
261
|
-
return (
|
|
262
|
-
<button
|
|
263
|
-
style={{
|
|
264
|
-
backgroundColor: buttonPrimaryBackground,
|
|
265
|
-
color: buttonPrimaryText,
|
|
266
|
-
borderRadius: buttonPrimaryBorderRadius,
|
|
267
|
-
paddingInline: buttonSizeMdPaddingInline,
|
|
268
|
-
paddingBlock: buttonSizeMdPaddingBlock
|
|
269
|
-
}}
|
|
270
|
-
>
|
|
271
|
-
{children}
|
|
272
|
-
</button>
|
|
273
|
-
);
|
|
274
|
-
};
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
## Support
|
|
278
|
-
|
|
279
|
-
For issues, questions, or contributions, please visit:
|
|
280
|
-
- [GitHub Repository](https://github.com/tatari-tv/beam-ui)
|
|
281
|
-
- [Issue Tracker](https://github.com/tatari-tv/beam-ui/issues)
|
|
282
|
-
|
|
283
|
-
## License
|
|
284
|
-
|
|
285
|
-
MIT
|
|
286
|
-
|