@nibin-org/tokens 1.0.0 โ 1.0.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/README.md +472 -85
- package/dist/styles.css +766 -230
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,22 +1,79 @@
|
|
|
1
1
|
# @nibin-org/tokens
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[](https://www.npmjs.com/package/@nibin-org/tokens)
|
|
5
|
-
[](https://opensource.org/licenses/MIT)
|
|
6
|
-
[](https://www.typescriptlang.org/)
|
|
3
|
+
<div align="center">
|
|
7
4
|
|
|
8
|
-
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
### ๐จ Beautiful, Interactive Visual Documentation for Design Tokens
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
**The missing UI layer that Style Dictionary doesn't provide**
|
|
13
|
+
|
|
14
|
+
[View Demo](https://your-demo-url.com) ยท [Report Bug](https://github.com/nibinlab99-dev/next-storybook/issues) ยท [Request Feature](https://github.com/nibinlab99-dev/next-storybook/issues)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## โจ Why @nibin-org/tokens?
|
|
21
|
+
|
|
22
|
+
Transform your static design tokens into **living, interactive documentation** that designers and developers will actually love using.
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { TokenDocumentation } from '@nibin-org/tokens';
|
|
26
|
+
import '@nibin-org/tokens/styles.css';
|
|
27
|
+
|
|
28
|
+
<TokenDocumentation tokens={yourTokens} />
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
That's it. Beautiful documentation in one line.
|
|
32
|
+
|
|
33
|
+
## ๐ฏ Features
|
|
34
|
+
|
|
35
|
+
<table>
|
|
36
|
+
<tr>
|
|
37
|
+
<td width="50%">
|
|
38
|
+
<h3>๐จ Rich Color Visualization</h3>
|
|
39
|
+
<p>Base palettes with shade scales + semantic tokens (fill, stroke, text) displayed with contrast ratios</p>
|
|
40
|
+
</td>
|
|
41
|
+
<td width="50%">
|
|
42
|
+
<h3>๐ Spacing & Size Scales</h3>
|
|
43
|
+
<p>Visual bar charts with proportional representation and real measurements</p>
|
|
44
|
+
</td>
|
|
45
|
+
</tr>
|
|
46
|
+
<tr>
|
|
47
|
+
<td width="50%">
|
|
48
|
+
<h3>โฌ Radius Showcase</h3>
|
|
49
|
+
<p>Actual rounded boxes demonstrating each radius value in action</p>
|
|
50
|
+
</td>
|
|
51
|
+
<td width="50%">
|
|
52
|
+
<h3>๐ Dark Mode</h3>
|
|
53
|
+
<p>Built-in light/dark theme toggle with smooth transitions</p>
|
|
54
|
+
</td>
|
|
55
|
+
</tr>
|
|
56
|
+
<tr>
|
|
57
|
+
<td width="50%">
|
|
58
|
+
<h3>๐ Copy-to-Clipboard</h3>
|
|
59
|
+
<p>Click any token to copy its value instantly with visual feedback</p>
|
|
60
|
+
</td>
|
|
61
|
+
<td width="50%">
|
|
62
|
+
<h3>๐ Search & Filter</h3>
|
|
63
|
+
<p>Quickly find tokens with real-time search</p>
|
|
64
|
+
</td>
|
|
65
|
+
</tr>
|
|
66
|
+
<tr>
|
|
67
|
+
<td width="50%">
|
|
68
|
+
<h3>๐ฑ Fully Responsive</h3>
|
|
69
|
+
<p>Works beautifully on any screen size, from mobile to 4K displays</p>
|
|
70
|
+
</td>
|
|
71
|
+
<td width="50%">
|
|
72
|
+
<h3>๐ Zero Config</h3>
|
|
73
|
+
<p>Just pass your tokens.json and go - no complex setup required</p>
|
|
74
|
+
</td>
|
|
75
|
+
</tr>
|
|
76
|
+
</table>
|
|
20
77
|
|
|
21
78
|
## ๐ Quick Start
|
|
22
79
|
|
|
@@ -30,7 +87,7 @@ yarn add @nibin-org/tokens
|
|
|
30
87
|
pnpm add @nibin-org/tokens
|
|
31
88
|
```
|
|
32
89
|
|
|
33
|
-
### Usage
|
|
90
|
+
### Basic Usage
|
|
34
91
|
|
|
35
92
|
```tsx
|
|
36
93
|
import { TokenDocumentation } from '@nibin-org/tokens';
|
|
@@ -48,36 +105,212 @@ export default function DesignTokensPage() {
|
|
|
48
105
|
}
|
|
49
106
|
```
|
|
50
107
|
|
|
51
|
-
|
|
108
|
+
### Next.js Setup (Required)
|
|
109
|
+
|
|
110
|
+
For Next.js projects, add the package to `transpilePackages` in `next.config.js`:
|
|
111
|
+
|
|
112
|
+
```js
|
|
113
|
+
/** @type {import('next').NextConfig} */
|
|
114
|
+
const nextConfig = {
|
|
115
|
+
transpilePackages: ['@nibin-org/tokens'],
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export default nextConfig;
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
> **๐ก Tip**: If you experience issues with Next.js 16+ Turbopack during local development with linked packages, use `next dev --webpack` as a workaround.
|
|
52
122
|
|
|
53
|
-
|
|
123
|
+
## ๐ Complete Guide
|
|
124
|
+
|
|
125
|
+
### Token Structure
|
|
126
|
+
|
|
127
|
+
This library works seamlessly with tokens exported from [Figma Tokens Studio](https://tokens.studio/). Here's the expected structure:
|
|
54
128
|
|
|
55
129
|
```json
|
|
56
130
|
{
|
|
57
131
|
"Colors/Value": {
|
|
58
|
-
"base": {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
132
|
+
"base": {
|
|
133
|
+
"blue": {
|
|
134
|
+
"50": { "value": "#e6f0ff", "type": "color" },
|
|
135
|
+
"100": { "value": "#cce1ff", "type": "color" },
|
|
136
|
+
"500": { "value": "#1369e9", "type": "color" }
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
"fill": {
|
|
140
|
+
"primary": { "value": "{base.blue.500}", "type": "color" }
|
|
141
|
+
},
|
|
142
|
+
"stroke": {
|
|
143
|
+
"default": { "value": "{base.gray.30}", "type": "color" }
|
|
144
|
+
},
|
|
145
|
+
"text": {
|
|
146
|
+
"default": { "value": "{base.gray.90}", "type": "color" }
|
|
147
|
+
}
|
|
62
148
|
},
|
|
63
149
|
"Spacing/Mode 1": {
|
|
150
|
+
"space-xs": { "value": "4px", "type": "dimension" },
|
|
64
151
|
"space-sm": { "value": "8px", "type": "dimension" }
|
|
65
152
|
},
|
|
66
153
|
"Size/Mode 1": {
|
|
154
|
+
"size-sm": { "value": "12px", "type": "dimension" },
|
|
67
155
|
"size-lg": { "value": "16px", "type": "dimension" }
|
|
68
156
|
},
|
|
69
157
|
"Radius/Mode 1": {
|
|
158
|
+
"radius-sm": { "value": "4px", "type": "dimension" },
|
|
70
159
|
"radius-md": { "value": "6px", "type": "dimension" }
|
|
71
160
|
}
|
|
72
161
|
}
|
|
73
162
|
```
|
|
74
163
|
|
|
75
|
-
|
|
164
|
+
### Full API Reference
|
|
165
|
+
|
|
166
|
+
#### `<TokenDocumentation />` - Main Component
|
|
167
|
+
|
|
168
|
+
The all-in-one solution for displaying all your tokens.
|
|
169
|
+
|
|
170
|
+
```tsx
|
|
171
|
+
<TokenDocumentation
|
|
172
|
+
tokens={tokens} // Required: Your tokens.json content
|
|
173
|
+
title="Design Tokens" // Optional: Page title
|
|
174
|
+
subtitle="v1.0.0" // Optional: Subtitle text
|
|
175
|
+
defaultTab="colors" // Optional: Initial tab
|
|
176
|
+
showSearch={true} // Optional: Show search input
|
|
177
|
+
darkMode={false} // Optional: Start in dark mode
|
|
178
|
+
onTokenClick={(token) => { // Optional: Callback when token clicked
|
|
179
|
+
console.log('Clicked:', token);
|
|
180
|
+
}}
|
|
181
|
+
/>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Props:**
|
|
185
|
+
|
|
186
|
+
| Prop | Type | Default | Description |
|
|
187
|
+
|------|------|---------|-------------|
|
|
188
|
+
| `tokens` | `FigmaTokens` | **required** | Your tokens.json content |
|
|
189
|
+
| `title` | `string` | `"Design Tokens"` | Page title |
|
|
190
|
+
| `subtitle` | `string` | `"View and copy design tokens"` | Subtitle text |
|
|
191
|
+
| `defaultTab` | `'colors' \| 'spacing' \| 'sizes' \| 'radius'` | `'colors'` | Initial active tab |
|
|
192
|
+
| `showSearch` | `boolean` | `true` | Show/hide search input |
|
|
193
|
+
| `darkMode` | `boolean` | `false` | Start in dark mode |
|
|
194
|
+
| `onTokenClick` | `(token) => void` | `undefined` | Callback when token is clicked |
|
|
195
|
+
|
|
196
|
+
### Individual Components
|
|
197
|
+
|
|
198
|
+
For custom layouts, use components individually:
|
|
199
|
+
|
|
200
|
+
#### ColorGrid
|
|
201
|
+
|
|
202
|
+
```tsx
|
|
203
|
+
import { ColorGrid } from '@nibin-org/tokens';
|
|
204
|
+
|
|
205
|
+
<ColorGrid
|
|
206
|
+
baseColors={tokens['Colors/Value'].base}
|
|
207
|
+
fillColors={tokens['Colors/Value'].fill}
|
|
208
|
+
strokeColors={tokens['Colors/Value'].stroke}
|
|
209
|
+
textColors={tokens['Colors/Value'].text}
|
|
210
|
+
onColorClick={(color) => console.log(color)}
|
|
211
|
+
/>
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
#### SpacingScale
|
|
215
|
+
|
|
216
|
+
```tsx
|
|
217
|
+
import { SpacingScale } from '@nibin-org/tokens';
|
|
218
|
+
|
|
219
|
+
<SpacingScale
|
|
220
|
+
tokens={tokens['Spacing/Mode 1']}
|
|
221
|
+
onTokenClick={(token) => console.log(token)}
|
|
222
|
+
/>
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
#### RadiusShowcase
|
|
226
|
+
|
|
227
|
+
```tsx
|
|
228
|
+
import { RadiusShowcase } from '@nibin-org/tokens';
|
|
229
|
+
|
|
230
|
+
<RadiusShowcase
|
|
231
|
+
tokens={tokens['Radius/Mode 1']}
|
|
232
|
+
onTokenClick={(token) => console.log(token)}
|
|
233
|
+
/>
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
#### SizeScale
|
|
237
|
+
|
|
238
|
+
```tsx
|
|
239
|
+
import { SizeScale } from '@nibin-org/tokens';
|
|
240
|
+
|
|
241
|
+
<SizeScale
|
|
242
|
+
tokens={tokens['Size/Mode 1']}
|
|
243
|
+
onTokenClick={(token) => console.log(token)}
|
|
244
|
+
/>
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## ๐จ Theming & Customization
|
|
248
|
+
|
|
249
|
+
The styles use CSS custom properties, making customization simple:
|
|
250
|
+
|
|
251
|
+
```css
|
|
252
|
+
:root {
|
|
253
|
+
/* Primary accent color */
|
|
254
|
+
--ftd-accent-primary: #6366f1;
|
|
255
|
+
--ftd-accent-primary-hover: #4f46e5;
|
|
256
|
+
|
|
257
|
+
/* Background colors */
|
|
258
|
+
--ftd-bg-canvas: #fafbfc;
|
|
259
|
+
--ftd-bg-primary: #ffffff;
|
|
260
|
+
--ftd-bg-secondary: #f6f8fa;
|
|
261
|
+
|
|
262
|
+
/* Text colors */
|
|
263
|
+
--ftd-text-primary: #0d1117;
|
|
264
|
+
--ftd-text-secondary: #57606a;
|
|
265
|
+
|
|
266
|
+
/* Border radius */
|
|
267
|
+
--ftd-radius-lg: 16px;
|
|
268
|
+
--ftd-radius-xl: 24px;
|
|
269
|
+
|
|
270
|
+
/* Shadows */
|
|
271
|
+
--ftd-shadow-md: 0 4px 8px rgba(0, 0, 0, 0.08);
|
|
272
|
+
--ftd-shadow-glow: 0 0 24px rgba(91, 71, 251, 0.2);
|
|
273
|
+
|
|
274
|
+
/* Transitions */
|
|
275
|
+
--ftd-transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/* Dark theme */
|
|
279
|
+
[data-theme="dark"] {
|
|
280
|
+
--ftd-bg-canvas: #0d1117;
|
|
281
|
+
--ftd-bg-primary: #161b22;
|
|
282
|
+
--ftd-text-primary: #e6edf3;
|
|
283
|
+
/* ... customize more */
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Advanced Customization Example
|
|
288
|
+
|
|
289
|
+
```css
|
|
290
|
+
/* Custom gradient for your brand */
|
|
291
|
+
:root {
|
|
292
|
+
--ftd-gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/* Custom card hover effect */
|
|
296
|
+
.ftd-token-card:hover {
|
|
297
|
+
transform: translateY(-8px) rotate(2deg);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/* Custom color scale height */
|
|
301
|
+
.ftd-color-shade {
|
|
302
|
+
height: 150px;
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## ๐ Workflow Integration
|
|
307
|
+
|
|
308
|
+
### Figma-to-Code Pipeline
|
|
76
309
|
|
|
77
310
|
```
|
|
78
311
|
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
|
|
79
312
|
โ โ โ โ โ โ
|
|
80
|
-
โ Figma +
|
|
313
|
+
โ Figma + โโโโโโโถโ tokens.json โโโโโโโถโ CSS + Docs โ
|
|
81
314
|
โ Token Studio โ โ โ โ โ
|
|
82
315
|
โ โ โ โ โ โ
|
|
83
316
|
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
|
|
@@ -90,106 +323,260 @@ This library works with tokens exported from [Figma Tokens Studio](https://token
|
|
|
90
323
|
### Recommended Setup
|
|
91
324
|
|
|
92
325
|
1. **Design Phase**: Use [Figma Tokens Studio](https://tokens.studio/) to manage tokens in Figma
|
|
93
|
-
2. **Sync Phase**: Export tokens.json to your repo (manual or GitHub sync)
|
|
94
|
-
3. **Build Phase**: Run your token build script to generate CSS
|
|
95
|
-
4. **Document Phase**: Use
|
|
326
|
+
2. **Sync Phase**: Export `tokens.json` to your repo (manual or automated via GitHub sync)
|
|
327
|
+
3. **Build Phase**: Run your token build script to generate CSS variables
|
|
328
|
+
4. **Document Phase**: Use `@nibin-org/tokens` to display beautiful, interactive documentation
|
|
96
329
|
|
|
97
|
-
###
|
|
330
|
+
### Example Build Script
|
|
98
331
|
|
|
99
|
-
|
|
332
|
+
```js
|
|
333
|
+
// scripts/build-tokens.js
|
|
334
|
+
const fs = require('fs');
|
|
335
|
+
const tokens = require('./tokens.json');
|
|
100
336
|
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
};
|
|
337
|
+
// Generate CSS variables
|
|
338
|
+
const css = generateCSSVariables(tokens);
|
|
339
|
+
fs.writeFileSync('src/styles/tokens.css', css);
|
|
105
340
|
|
|
106
|
-
|
|
107
|
-
|
|
341
|
+
// Generate documentation page
|
|
342
|
+
const docs = `
|
|
343
|
+
import { TokenDocumentation } from '@nibin-org/tokens';
|
|
344
|
+
import tokens from '../tokens.json';
|
|
108
345
|
|
|
109
|
-
|
|
346
|
+
export default function TokensPage() {
|
|
347
|
+
return <TokenDocumentation tokens={tokens} />;
|
|
348
|
+
}
|
|
349
|
+
`;
|
|
350
|
+
fs.writeFileSync('src/pages/tokens.tsx', docs);
|
|
351
|
+
```
|
|
110
352
|
|
|
111
|
-
##
|
|
353
|
+
## ๐ Comparison with Style Dictionary
|
|
112
354
|
|
|
113
|
-
|
|
355
|
+
| Feature | Style Dictionary | @nibin-org/tokens |
|
|
356
|
+
|---------|-----------------|------------------|
|
|
357
|
+
| **Token Transformation** | โ
Excellent | โ Not included |
|
|
358
|
+
| **Multi-platform Output** (iOS, Android, Web) | โ
Yes | โ No |
|
|
359
|
+
| **Visual Documentation** | โ None | โ
Beautiful interactive UI |
|
|
360
|
+
| **Interactive Exploration** | โ No | โ
Click, search, copy |
|
|
361
|
+
| **Copy-to-Clipboard** | โ No | โ
Yes |
|
|
362
|
+
| **Dark Mode Support** | โ No | โ
Yes |
|
|
363
|
+
| **Real-time Search** | โ No | โ
Yes |
|
|
114
364
|
|
|
115
|
-
|
|
365
|
+
### Use Both Together! ๐ค
|
|
116
366
|
|
|
117
|
-
|
|
118
|
-
|------|------|---------|-------------|
|
|
119
|
-
| `tokens` | `FigmaTokens` | required | Your tokens.json content |
|
|
120
|
-
| `title` | `string` | `"Design Tokens"` | Page title |
|
|
121
|
-
| `subtitle` | `string` | `"..."` | Subtitle text |
|
|
122
|
-
| `defaultTab` | `'colors' \| 'spacing' \| 'sizes' \| 'radius'` | `'colors'` | Initial tab |
|
|
123
|
-
| `showSearch` | `boolean` | `true` | Show search input |
|
|
124
|
-
| `darkMode` | `boolean` | `false` | Start in dark mode |
|
|
125
|
-
| `onTokenClick` | `(token) => void` | - | Callback when token is clicked |
|
|
367
|
+
**Best Practice**: Use **Style Dictionary** for token transformation and multi-platform output, and **@nibin-org/tokens** for beautiful documentation.
|
|
126
368
|
|
|
127
|
-
|
|
369
|
+
```bash
|
|
370
|
+
# 1. Transform tokens with Style Dictionary
|
|
371
|
+
npx style-dictionary build
|
|
128
372
|
|
|
129
|
-
|
|
373
|
+
# 2. Document tokens with @nibin-org/tokens
|
|
374
|
+
# Import in your docs site
|
|
375
|
+
```
|
|
130
376
|
|
|
131
|
-
|
|
132
|
-
import { ColorGrid, SpacingScale, RadiusShowcase, SizeScale } from '@nibin-org/tokens';
|
|
377
|
+
## ๐ฏ Real-World Examples
|
|
133
378
|
|
|
134
|
-
|
|
135
|
-
baseColors={tokens['Colors/Value'].base}
|
|
136
|
-
fillColors={tokens['Colors/Value'].fill}
|
|
137
|
-
/>
|
|
379
|
+
### Storybook Integration
|
|
138
380
|
|
|
139
|
-
|
|
381
|
+
```tsx
|
|
382
|
+
// .storybook/preview.tsx
|
|
383
|
+
import { TokenDocumentation } from '@nibin-org/tokens';
|
|
384
|
+
import '@nibin-org/tokens/styles.css';
|
|
385
|
+
import tokens from '../design-tokens/tokens.json';
|
|
140
386
|
|
|
141
|
-
|
|
387
|
+
export default {
|
|
388
|
+
title: 'Design System/Tokens',
|
|
389
|
+
component: TokenDocumentation,
|
|
390
|
+
};
|
|
142
391
|
|
|
143
|
-
|
|
392
|
+
export const AllTokens = () => (
|
|
393
|
+
<TokenDocumentation
|
|
394
|
+
tokens={tokens}
|
|
395
|
+
title="Design System Tokens"
|
|
396
|
+
subtitle="Version 2.0 - Updated Jan 2025"
|
|
397
|
+
/>
|
|
398
|
+
);
|
|
144
399
|
```
|
|
145
400
|
|
|
146
|
-
|
|
401
|
+
### Documentation Site (Docusaurus, VitePress, etc.)
|
|
147
402
|
|
|
148
|
-
|
|
403
|
+
```tsx
|
|
404
|
+
// docs/design-tokens.tsx
|
|
405
|
+
import { TokenDocumentation } from '@nibin-org/tokens';
|
|
406
|
+
import '@nibin-org/tokens/styles.css';
|
|
407
|
+
import tokens from './tokens.json';
|
|
149
408
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
409
|
+
export default function DesignTokensPage() {
|
|
410
|
+
return (
|
|
411
|
+
<div className="container">
|
|
412
|
+
<TokenDocumentation
|
|
413
|
+
tokens={tokens}
|
|
414
|
+
defaultTab="colors"
|
|
415
|
+
onTokenClick={(token) => {
|
|
416
|
+
// Track analytics
|
|
417
|
+
analytics.track('token_copied', { name: token.name });
|
|
418
|
+
}}
|
|
419
|
+
/>
|
|
420
|
+
</div>
|
|
421
|
+
);
|
|
156
422
|
}
|
|
157
423
|
```
|
|
158
424
|
|
|
159
|
-
|
|
425
|
+
### Custom Integration
|
|
160
426
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
427
|
+
```tsx
|
|
428
|
+
import {
|
|
429
|
+
ColorGrid,
|
|
430
|
+
SpacingScale,
|
|
431
|
+
parseBaseColors,
|
|
432
|
+
copyToClipboard
|
|
433
|
+
} from '@nibin-org/tokens';
|
|
434
|
+
import '@nibin-org/tokens/styles.css';
|
|
169
435
|
|
|
170
|
-
|
|
436
|
+
function CustomTokenDocs() {
|
|
437
|
+
const colorFamilies = parseBaseColors(tokens['Colors/Value'].base);
|
|
438
|
+
|
|
439
|
+
return (
|
|
440
|
+
<div>
|
|
441
|
+
<h1>Our Brand Colors</h1>
|
|
442
|
+
<ColorGrid
|
|
443
|
+
baseColors={tokens['Colors/Value'].base}
|
|
444
|
+
onColorClick={(color) => {
|
|
445
|
+
copyToClipboard(color.value);
|
|
446
|
+
toast.success(`Copied ${color.value}`);
|
|
447
|
+
}}
|
|
448
|
+
/>
|
|
449
|
+
|
|
450
|
+
<h2>Spacing System</h2>
|
|
451
|
+
<SpacingScale tokens={tokens['Spacing/Mode 1']} />
|
|
452
|
+
</div>
|
|
453
|
+
);
|
|
454
|
+
}
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
## ๐ ๏ธ Development
|
|
171
458
|
|
|
172
|
-
|
|
459
|
+
### Local Development
|
|
173
460
|
|
|
174
461
|
```bash
|
|
175
|
-
# Clone
|
|
462
|
+
# Clone the repository
|
|
176
463
|
git clone https://github.com/nibinlab99-dev/next-storybook.git
|
|
177
|
-
cd next-storybook
|
|
464
|
+
cd next-storybook/packages/tokens
|
|
465
|
+
|
|
466
|
+
# Install dependencies
|
|
178
467
|
npm install
|
|
179
468
|
|
|
180
|
-
# Build
|
|
181
|
-
npm run
|
|
469
|
+
# Build the package
|
|
470
|
+
npm run build
|
|
182
471
|
|
|
183
|
-
# Run
|
|
472
|
+
# Run in watch mode
|
|
184
473
|
npm run dev
|
|
474
|
+
|
|
475
|
+
# Type checking
|
|
476
|
+
npm run typecheck
|
|
477
|
+
|
|
478
|
+
# Linting
|
|
479
|
+
npm run lint
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
### Project Structure
|
|
483
|
+
|
|
484
|
+
```
|
|
485
|
+
@nibin-org/tokens/
|
|
486
|
+
โโโ src/
|
|
487
|
+
โ โโโ components/
|
|
488
|
+
โ โ โโโ TokenDocumentation.tsx
|
|
489
|
+
โ โ โโโ ColorGrid.tsx
|
|
490
|
+
โ โ โโโ SpacingScale.tsx
|
|
491
|
+
โ โ โโโ RadiusShowcase.tsx
|
|
492
|
+
โ โ โโโ SizeScale.tsx
|
|
493
|
+
โ โโโ types.ts
|
|
494
|
+
โ โโโ utils.ts
|
|
495
|
+
โ โโโ index.ts
|
|
496
|
+
โ โโโ styles.css
|
|
497
|
+
โโโ dist/ # Built files (generated)
|
|
498
|
+
โโโ package.json
|
|
499
|
+
โโโ tsconfig.json
|
|
500
|
+
โโโ tsup.config.ts
|
|
501
|
+
โโโ README.md
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
### Building
|
|
505
|
+
|
|
506
|
+
The package uses [tsup](https://tsup.egoist.dev/) for fast, zero-config bundling:
|
|
507
|
+
|
|
508
|
+
```bash
|
|
509
|
+
npm run build
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
This generates:
|
|
513
|
+
- `dist/index.js` - ESM bundle
|
|
514
|
+
- `dist/index.cjs` - CommonJS bundle
|
|
515
|
+
- `dist/index.d.ts` - TypeScript definitions
|
|
516
|
+
- `dist/styles.css` - Compiled styles
|
|
517
|
+
|
|
518
|
+
## ๐ TypeScript Support
|
|
519
|
+
|
|
520
|
+
Full TypeScript support with comprehensive type definitions:
|
|
521
|
+
|
|
522
|
+
```tsx
|
|
523
|
+
import type {
|
|
524
|
+
TokenDocumentationProps,
|
|
525
|
+
FigmaTokens,
|
|
526
|
+
ParsedColorToken,
|
|
527
|
+
ParsedSpacingToken,
|
|
528
|
+
ColorFamily
|
|
529
|
+
} from '@nibin-org/tokens';
|
|
530
|
+
|
|
531
|
+
const tokens: FigmaTokens = {
|
|
532
|
+
'Colors/Value': {
|
|
533
|
+
base: { /* ... */ }
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
const handleTokenClick = (token: ParsedColorToken) => {
|
|
538
|
+
console.log(token.cssVariable); // Type-safe!
|
|
539
|
+
};
|
|
185
540
|
```
|
|
186
541
|
|
|
542
|
+
## ๐ค Contributing
|
|
543
|
+
|
|
544
|
+
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
545
|
+
|
|
546
|
+
### Development Workflow
|
|
547
|
+
|
|
548
|
+
1. Fork the repository
|
|
549
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
550
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
551
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
552
|
+
5. Open a Pull Request
|
|
553
|
+
|
|
187
554
|
## ๐ License
|
|
188
555
|
|
|
189
556
|
MIT ยฉ [nibinlab99-dev](https://github.com/nibinlab99-dev)
|
|
190
557
|
|
|
558
|
+
See [LICENSE](LICENSE) for more information.
|
|
559
|
+
|
|
560
|
+
## ๐ Acknowledgments
|
|
561
|
+
|
|
562
|
+
- Built with โค๏ธ for design systems teams
|
|
563
|
+
- Inspired by [Figma Tokens Studio](https://tokens.studio/)
|
|
564
|
+
- Compatible with [Style Dictionary](https://amzn.github.io/style-dictionary/)
|
|
565
|
+
- Typography powered by [DM Sans](https://fonts.google.com/specimen/DM+Sans) and [Fraunces](https://fonts.google.com/specimen/Fraunces)
|
|
566
|
+
|
|
567
|
+
## ๐ฌ Support
|
|
568
|
+
|
|
569
|
+
- ๐ง Email: support@nibin.org
|
|
570
|
+
- ๐ฌ [GitHub Discussions](https://github.com/nibinlab99-dev/next-storybook/discussions)
|
|
571
|
+
- ๐ [Issue Tracker](https://github.com/nibinlab99-dev/next-storybook/issues)
|
|
572
|
+
- ๐ [Documentation](https://docs.nibin.org)
|
|
573
|
+
|
|
191
574
|
---
|
|
192
575
|
|
|
193
|
-
<
|
|
194
|
-
|
|
195
|
-
|
|
576
|
+
<div align="center">
|
|
577
|
+
|
|
578
|
+
**[โฌ back to top](#nibin-orgtokens)**
|
|
579
|
+
|
|
580
|
+
Made with โค๏ธ for design systems
|
|
581
|
+
|
|
582
|
+
</div>
|