@bcc-code/design-tokens 3.0.9 → 3.0.12
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 +86 -5
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ Import auto-switching CSS variables with light/dark mode support:
|
|
|
18
18
|
@import '@bcc-code/design-tokens/css';
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
This automatically provides light theme by default and switches to dark theme when
|
|
21
|
+
This automatically provides light theme by default and switches to dark theme when the `.dark` class is applied to any parent element (typically `html` or `body`).
|
|
22
22
|
|
|
23
23
|
Use semantic tokens in your styles:
|
|
24
24
|
|
|
@@ -32,6 +32,16 @@ Use semantic tokens in your styles:
|
|
|
32
32
|
}
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
+
**Manual theme switching:**
|
|
36
|
+
```javascript
|
|
37
|
+
// Toggle dark mode
|
|
38
|
+
document.documentElement.classList.toggle('dark');
|
|
39
|
+
|
|
40
|
+
// Or set theme based on user preference
|
|
41
|
+
const isDark = localStorage.getItem('theme') === 'dark';
|
|
42
|
+
document.documentElement.classList.toggle('dark', isDark);
|
|
43
|
+
```
|
|
44
|
+
|
|
35
45
|
**Alternative theme-specific imports (optional):**
|
|
36
46
|
```css
|
|
37
47
|
@import '@bcc-code/design-tokens/css/light';
|
|
@@ -96,7 +106,13 @@ Enable dark mode by adding the `dark` class to your root element:
|
|
|
96
106
|
|
|
97
107
|
```javascript
|
|
98
108
|
// Toggle dark mode
|
|
99
|
-
document.documentElement.classList.toggle('
|
|
109
|
+
document.documentElement.classList.toggle('dark')
|
|
110
|
+
|
|
111
|
+
// Or with system preference fallback
|
|
112
|
+
function setTheme(isDark) {
|
|
113
|
+
document.documentElement.classList.toggle('dark', isDark);
|
|
114
|
+
document.documentElement.style.colorScheme = isDark ? 'dark' : 'light';
|
|
115
|
+
}
|
|
100
116
|
```
|
|
101
117
|
|
|
102
118
|
## Token Categories
|
|
@@ -110,11 +126,31 @@ document.documentElement.classList.toggle('.dark')
|
|
|
110
126
|
## CDN Usage
|
|
111
127
|
|
|
112
128
|
```html
|
|
113
|
-
<!-- Auto-switching CSS variables (recommended) -->
|
|
129
|
+
<!-- Auto-switching CSS variables with .dark class support (recommended) -->
|
|
114
130
|
<link rel="stylesheet" href="https://unpkg.com/@bcc-code/design-tokens@latest/build/bcc/css/auto.css">
|
|
115
131
|
|
|
116
132
|
<!-- Or Tailwind utilities with .dark class support -->
|
|
117
133
|
<link rel="stylesheet" href="https://unpkg.com/@bcc-code/design-tokens@latest/build/bcc/css/tailwind-auto.css">
|
|
134
|
+
|
|
135
|
+
<!-- Then add JavaScript for theme switching -->
|
|
136
|
+
<script>
|
|
137
|
+
// Basic theme toggle
|
|
138
|
+
function toggleTheme() {
|
|
139
|
+
document.documentElement.classList.toggle('dark');
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Theme with system preference detection
|
|
143
|
+
function initTheme() {
|
|
144
|
+
const savedTheme = localStorage.getItem('theme');
|
|
145
|
+
const systemDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
146
|
+
const isDark = savedTheme ? savedTheme === 'dark' : systemDark;
|
|
147
|
+
|
|
148
|
+
document.documentElement.classList.toggle('dark', isDark);
|
|
149
|
+
document.documentElement.style.colorScheme = isDark ? 'dark' : 'light';
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
initTheme();
|
|
153
|
+
</script>
|
|
118
154
|
```
|
|
119
155
|
|
|
120
156
|
## Contributing
|
|
@@ -141,6 +177,8 @@ We welcome contributions! Here's how to get started:
|
|
|
141
177
|
npm install
|
|
142
178
|
npm run dev
|
|
143
179
|
```
|
|
180
|
+
|
|
181
|
+
The demo application showcases all three integration methods (CSS variables, Tailwind utilities, and PrimeVue components) with a comprehensive dashboard featuring theme switching, real-world examples, and live token demonstrations.
|
|
144
182
|
|
|
145
183
|
### Token Structure
|
|
146
184
|
|
|
@@ -148,9 +186,44 @@ We welcome contributions! Here's how to get started:
|
|
|
148
186
|
- **Build configuration** is in `export-tokens/build.js` using Style Dictionary
|
|
149
187
|
- **Output files** are generated in `build/bcc/` with organized folders for `css/` and `js/`
|
|
150
188
|
|
|
189
|
+
### GitHub-Figma Workflow
|
|
190
|
+
|
|
191
|
+
The design token system integrates with Figma through Figma Token Studio, creating a streamlined workflow between design and development:
|
|
192
|
+
|
|
193
|
+
**1. Design in Figma**
|
|
194
|
+
- Design tokens are created and managed in Figma using the Token Studio plugin
|
|
195
|
+
- Tokens are organized into collections: primitives, semantic (light/dark), typeface, and PrimeVue
|
|
196
|
+
- Designers can make changes directly in Figma and preview them in real-time
|
|
197
|
+
|
|
198
|
+
**2. Export from Figma Token Studio**
|
|
199
|
+
- Use the Token Studio plugin to export tokens as JSON files
|
|
200
|
+
- Export collections separately or as a complete token set
|
|
201
|
+
- Tokens are exported in the Figma Token Studio format with proper references
|
|
202
|
+
|
|
203
|
+
**3. Sync to GitHub**
|
|
204
|
+
- Export token files from Figma Token Studio
|
|
205
|
+
- Update the corresponding files in the `tokens/` directory:
|
|
206
|
+
- `tokens/primitives/` - Base design tokens (colors, dimensions, typography)
|
|
207
|
+
- `tokens/semantic/light.json` - Light theme semantic tokens
|
|
208
|
+
- `tokens/semantic/dark.json` - Dark theme semantic tokens
|
|
209
|
+
- `tokens/typeface/` - Font definitions
|
|
210
|
+
- `tokens/primevue/aura-primitive.json` - PrimeVue Aura primitive tokens
|
|
211
|
+
- Commit changes to your feature branch
|
|
212
|
+
|
|
213
|
+
**4. Build and Deploy**
|
|
214
|
+
- Run `npm run build` to transform tokens into CSS, JS, and Tailwind formats
|
|
215
|
+
- The Style Dictionary build system processes tokens with custom transforms
|
|
216
|
+
- Generated files in `build/bcc/` are ready for distribution
|
|
217
|
+
|
|
218
|
+
**5. Version and Release**
|
|
219
|
+
- Create pull request with token changes
|
|
220
|
+
- Review generated output files and test with demo application
|
|
221
|
+
- Merge to main branch triggers automated release process
|
|
222
|
+
- New package version is published to npm with updated tokens
|
|
223
|
+
|
|
151
224
|
### Making Changes
|
|
152
225
|
|
|
153
|
-
1. **Token updates:**
|
|
226
|
+
1. **Token updates:** Export from Figma Token Studio and update files in `tokens/` directory
|
|
154
227
|
2. **Build system changes:** Update `export-tokens/build.js` for new formats or transformations
|
|
155
228
|
3. **PrimeVue preset:** Modify `config/primevue.config.js` for theme mapping changes
|
|
156
229
|
|
|
@@ -163,7 +236,15 @@ We welcome contributions! Here's how to get started:
|
|
|
163
236
|
|
|
164
237
|
## Development
|
|
165
238
|
|
|
166
|
-
A demo application is available in the `demo/` directory
|
|
239
|
+
A comprehensive demo application is available in the `demo/` directory featuring:
|
|
240
|
+
|
|
241
|
+
- **CSS Variables showcase**: Custom cards, newsletter forms, and status displays using pure CSS with BCC tokens
|
|
242
|
+
- **Tailwind Utilities showcase**: Project management dashboard with utility-first CSS classes
|
|
243
|
+
- **PrimeVue Components showcase**: User profiles, settings panels, and component galleries
|
|
244
|
+
- **Theme switching**: Manual dark/light mode toggle with system preference detection
|
|
245
|
+
- **Live token demonstrations**: Real-time examples of all token categories in action
|
|
246
|
+
|
|
247
|
+
Access the demo at `http://localhost:5173` after running `npm run dev` in the `demo/` directory.
|
|
167
248
|
|
|
168
249
|
## License
|
|
169
250
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bcc-code/design-tokens",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.12",
|
|
4
4
|
"description": "Design tokens build system",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -37,10 +37,13 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/bcc-code/bcc-tokens#readme",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@tokens-studio/sd-transforms": "^
|
|
41
|
-
"style-dictionary": "^5.0.
|
|
40
|
+
"@tokens-studio/sd-transforms": "^2.0.1",
|
|
41
|
+
"style-dictionary": "^5.0.1"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@primeuix/themes": "^1.1.1"
|
|
45
|
+
},
|
|
46
|
+
"overrides": {
|
|
47
|
+
"tmp": "^0.2.4"
|
|
45
48
|
}
|
|
46
49
|
}
|