@transcodes/design-tokens 0.2.0 → 0.3.1

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 ADDED
@@ -0,0 +1,52 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.3.1] - 2025-12-11
9
+
10
+ ### Added
11
+
12
+ - CSS auto-import: `import '@transcodes/design-tokens'`로 CSS 자동 로드 (하위 호환성 복구)
13
+ - 다크모드 dual selector 지원: `prefers-color-scheme` 자동 감지 + `data-theme` 수동 오버라이드
14
+ - CSS minification: lightningcss 기반 압축 (평균 45% 용량 감소)
15
+
16
+ ### Changed
17
+
18
+ - 다크모드 CSS 선택자 개선: `@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) }` + `[data-theme="dark"]`
19
+ - package.json에 `sideEffects` 필드 추가로 번들러 최적화 지원
20
+
21
+ ## [0.3.0] - 2025-12-11
22
+
23
+ ### Added
24
+
25
+ - JS main export 추가 (`index.js`, `index.d.ts`) - ESBuild 등 번들러 호환성 개선
26
+ - `tokens` 객체 export (camelCase 키)
27
+ - `cssVars` 객체 export (CSS 변수명 키)
28
+ - 버튼 시맨틱 토큰: `--button-dark`, `--button-dark-hover`, `--button-light`, `--button-light-hover`
29
+ - 시맨틱 배경 토큰: `--semantic-warning-bg`, `--semantic-warning-light`, `--semantic-success-bg`, `--semantic-info-bg`
30
+
31
+ ### Changed
32
+
33
+ - package.json exports 구조 개선: main export를 CSS에서 JS로 변경
34
+ - CSS import 경로 변경: `@transcodes/design-tokens` → `@transcodes/design-tokens/css`
35
+
36
+ ## [0.2.0] - 2025-12-10
37
+
38
+ ### Changed
39
+
40
+ - Bun native API로 빌드 스크립트 전환 (빌드 성능 개선)
41
+
42
+ ## [0.1.0] - 2025-12-10
43
+
44
+ ### Added
45
+
46
+ - Initial release of design tokens
47
+ - CSS custom properties for colors, typography, spacing, shadows, and borders
48
+ - Dark mode support via `[data-theme="dark"]` selector
49
+ - TypeScript type definitions (`tokens.d.ts`)
50
+ - Component CSS classes (`.button`, `.input`, `.notice`, `.field-group`, etc.)
51
+ - WCAG AA compliant color contrast ratios (4.5:1+)
52
+ - DTCG standard compliant token format (`$value`, `$type`)
package/README.md CHANGED
@@ -7,40 +7,31 @@ A comprehensive design token system built with [Style Dictionary](https://amzn.g
7
7
 
8
8
  ## Features
9
9
 
10
- - **Dark Mode Support** - Built-in light and dark themes with `data-theme` attribute
10
+ - **Dark Mode Support** - Automatic system detection + manual override with `data-theme`
11
11
  - **WCAG AA Compliant** - All color combinations meet accessibility contrast requirements
12
12
  - **Responsive Values** - Fluid typography and spacing using CSS `clamp()`
13
13
  - **TypeScript Support** - Full type definitions included
14
- - **Zero Runtime** - Pure CSS variables with no JavaScript required
14
+ - **CSS Auto-import** - Zero-config CSS loading (v0.3.1+)
15
+ - **Tree-shakable** - Optimized for modern bundlers
15
16
 
16
17
  ## Installation
17
18
 
18
19
  ```bash
19
20
  npm install @transcodes/design-tokens
20
21
  # or
21
- yarn add @transcodes/design-tokens
22
- # or
23
- pnpm add @transcodes/design-tokens
24
- # or
25
22
  bun add @transcodes/design-tokens
26
23
  ```
27
24
 
28
25
  ## Quick Start
29
26
 
30
- ### 1. Import the tokens
27
+ ### Automatic CSS Loading (v0.3.1+)
31
28
 
32
29
  ```typescript
33
- // Import base tokens (light theme by default)
30
+ // CSS automatically loaded (light + dark themes)
34
31
  import '@transcodes/design-tokens';
35
-
36
- // Optional: Import dark theme support
37
- import '@transcodes/design-tokens/tokens-dark.css';
38
-
39
- // Optional: Import component utility classes
40
- import '@transcodes/design-tokens/components.css';
41
32
  ```
42
33
 
43
- ### 2. Use CSS variables in your styles
34
+ That's it! CSS variables are now available globally.
44
35
 
45
36
  ```css
46
37
  .card {
@@ -48,32 +39,66 @@ import '@transcodes/design-tokens/components.css';
48
39
  background: var(--paper-white);
49
40
  padding: var(--space-md);
50
41
  border-radius: var(--radius-md);
51
- box-shadow: var(--shadow-sm);
52
- transition: box-shadow var(--transition-smooth);
42
+ box-shadow: var(--shadow-card);
53
43
  }
44
+ ```
45
+
46
+ ### JavaScript Objects (Optional)
47
+
48
+ ```typescript
49
+ import { tokens, cssVars } from '@transcodes/design-tokens';
50
+
51
+ // camelCase keys
52
+ console.log(tokens.accentPrimary); // "#6b4fd9"
53
+ console.log(tokens.spaceMd); // "clamp(0.875rem, 0.77rem + 0.54vw, 1.25rem)"
54
54
 
55
- .card:hover {
56
- box-shadow: var(--shadow-md);
55
+ // CSS variable names as keys
56
+ console.log(cssVars['--accent-primary']); // "#6b4fd9"
57
+ console.log(cssVars['--space-md']); // "clamp(0.875rem, 0.77rem + 0.54vw, 1.25rem)"
58
+ ```
59
+
60
+ ### Dark Mode
61
+
62
+ **Automatic Detection (v0.3.1+)**
63
+
64
+ Dark mode is automatically applied based on system preferences:
65
+
66
+ ```css
67
+ /* Respects prefers-color-scheme: dark */
68
+ @media (prefers-color-scheme: dark) {
69
+ :root:not([data-theme="light"]) {
70
+ /* Dark theme variables */
71
+ }
57
72
  }
58
73
  ```
59
74
 
60
- ### 3. Enable dark mode
75
+ **Manual Override**
76
+
77
+ Force a specific theme:
61
78
 
62
79
  ```html
63
- <!-- Light theme (default) -->
80
+ <!-- Force light theme (ignores system preference) -->
64
81
  <html data-theme="light">
65
82
 
66
- <!-- Dark theme -->
83
+ <!-- Force dark theme (ignores system preference) -->
67
84
  <html data-theme="dark">
85
+
86
+ <!-- Auto (respect system preference) -->
87
+ <html> <!-- no data-theme attribute -->
68
88
  ```
69
89
 
70
90
  ```javascript
71
- // Toggle theme with JavaScript
91
+ // Toggle theme with manual override
72
92
  function toggleTheme() {
73
93
  const current = document.documentElement.getAttribute('data-theme');
74
94
  const next = current === 'dark' ? 'light' : 'dark';
75
95
  document.documentElement.setAttribute('data-theme', next);
76
96
  }
97
+
98
+ // Reset to system preference
99
+ function resetTheme() {
100
+ document.documentElement.removeAttribute('data-theme');
101
+ }
77
102
  ```
78
103
 
79
104
  ## Available Tokens
@@ -86,7 +111,6 @@ function toggleTheme() {
86
111
  | `--ink-dark` | #2d2d2d | #e5e5e5 | Secondary text |
87
112
  | `--ink-medium` | #5c5c5c | #a3a3a3 | Tertiary text |
88
113
  | `--ink-light` | #8a8a8a | #737373 | Placeholder text |
89
- | `--ink-faint` | #c4c4c4 | #525252 | Decorative elements |
90
114
  | `--paper-white` | #faf9fc | #1a1a1a | Primary background |
91
115
  | `--paper-cream` | #f5f4f8 | #2d2d2d | Secondary background |
92
116
  | `--paper-warm` | #ebe9f0 | #404040 | Tertiary background |
@@ -94,9 +118,21 @@ function toggleTheme() {
94
118
  | `--accent-success` | #357a46 | #4ade80 | Success state |
95
119
  | `--error-base` | #c0392b | #f87171 | Error state |
96
120
 
121
+ ### Semantic Tokens (v0.3.0+)
122
+
123
+ | Token | Description |
124
+ |-------|-------------|
125
+ | `--button-dark` | Dark button background |
126
+ | `--button-dark-hover` | Dark button hover state |
127
+ | `--button-light` | Light button background |
128
+ | `--button-light-hover` | Light button hover state |
129
+ | `--semantic-warning-bg` | Warning callout background |
130
+ | `--semantic-success-bg` | Success callout background |
131
+ | `--semantic-info-bg` | Info callout background |
132
+
97
133
  ### Spacing
98
134
 
99
- All spacing values are responsive and scale with viewport width.
135
+ Responsive values that scale with viewport width.
100
136
 
101
137
  | Token | Value Range |
102
138
  |-------|-------------|
@@ -130,12 +166,6 @@ All spacing values are responsive and scale with viewport width.
130
166
  ### Layout
131
167
 
132
168
  ```css
133
- /* Breakpoints */
134
- --breakpoint-sm: 640px;
135
- --breakpoint-md: 768px;
136
- --breakpoint-lg: 1024px;
137
- --breakpoint-xl: 1280px;
138
-
139
169
  /* Border radius */
140
170
  --radius-sm: 4px;
141
171
  --radius-md: 8px;
@@ -157,22 +187,29 @@ All spacing values are responsive and scale with viewport width.
157
187
  --transition-bounce: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
158
188
  ```
159
189
 
160
- ## TypeScript Support
161
-
162
- ```typescript
163
- import type { DesignTokens } from '@transcodes/design-tokens/types';
164
- ```
165
-
166
190
  ## Exports
167
191
 
168
192
  | Path | Description |
169
193
  |------|-------------|
170
- | `@transcodes/design-tokens` | Base CSS variables (light theme) |
171
- | `@transcodes/design-tokens/tokens-dark.css` | Dark theme overrides |
194
+ | `@transcodes/design-tokens` | **Recommended** - Auto-loads CSS + exports JS objects |
195
+ | `@transcodes/design-tokens/css` | CSS variables only (light theme) |
196
+ | `@transcodes/design-tokens/tokens-dark.css` | Dark theme CSS only |
172
197
  | `@transcodes/design-tokens/components.css` | Component utility classes |
198
+ | `@transcodes/design-tokens/components` | Component styles as JS |
173
199
  | `@transcodes/design-tokens/types` | TypeScript type definitions |
174
200
  | `@transcodes/design-tokens/json` | Raw token values as JSON |
175
201
 
202
+ ### Migration from v0.3.0
203
+
204
+ ```typescript
205
+ // v0.3.0 (manual CSS imports)
206
+ import '@transcodes/design-tokens/css';
207
+ import '@transcodes/design-tokens/tokens-dark.css';
208
+
209
+ // v0.3.1+ (automatic)
210
+ import '@transcodes/design-tokens';
211
+ ```
212
+
176
213
  ## Accessibility
177
214
 
178
215
  All primary color combinations meet WCAG AA standards (4.5:1 minimum contrast ratio):
@@ -186,7 +223,7 @@ All primary color combinations meet WCAG AA standards (4.5:1 minimum contrast ra
186
223
 
187
224
  ## Browser Support
188
225
 
189
- This package uses CSS custom properties (CSS variables) and `clamp()` for responsive values. Supported in all modern browsers:
226
+ Supports all modern browsers with CSS custom properties and `clamp()`:
190
227
 
191
228
  - Chrome 79+
192
229
  - Firefox 75+
@@ -197,6 +234,10 @@ This package uses CSS custom properties (CSS variables) and `clamp()` for respon
197
234
 
198
235
  - [@transcodes/ui-components](https://www.npmjs.com/package/@transcodes/ui-components) - Lit 3.x component library using these tokens
199
236
 
237
+ ## Changelog
238
+
239
+ See [CHANGELOG.md](./CHANGELOG.md) for release history.
240
+
200
241
  ## License
201
242
 
202
243
  [MIT](./LICENSE)