@nibin-org/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/README.md +195 -0
- package/dist/index.cjs +700 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +162 -0
- package/dist/index.d.ts +162 -0
- package/dist/index.js +662 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +605 -0
- package/package.json +83 -0
package/README.md
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# @nibin-org/tokens
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@nibin-org/tokens)
|
|
4
|
+
[](https://www.npmjs.com/package/@nibin-org/tokens)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://www.typescriptlang.org/)
|
|
7
|
+
|
|
8
|
+
> 🎨 Beautiful, interactive visual documentation for Figma design tokens — **the missing UI layer that Style Dictionary doesn't provide.**
|
|
9
|
+
|
|
10
|
+
## ✨ Features
|
|
11
|
+
|
|
12
|
+
- **🎨 Rich Color Visualization** — Base palettes with shade scales + semantic tokens (fill, stroke, text)
|
|
13
|
+
- **📏 Spacing & Size Scales** — Visual bar charts with proportional representation
|
|
14
|
+
- **⬜ Radius Showcase** — Actual rounded boxes demonstrating each radius value
|
|
15
|
+
- **🌙 Dark Mode** — Built-in light/dark theme toggle
|
|
16
|
+
- **📋 Copy-to-Clipboard** — Click any token to copy its value instantly
|
|
17
|
+
- **🔍 Search** — Filter tokens quickly (coming soon)
|
|
18
|
+
- **📱 Responsive** — Works beautifully on any screen size
|
|
19
|
+
- **🔌 Zero Config** — Just pass your tokens.json and go!
|
|
20
|
+
|
|
21
|
+
## 🚀 Quick Start
|
|
22
|
+
|
|
23
|
+
### Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install @nibin-org/tokens
|
|
27
|
+
# or
|
|
28
|
+
yarn add @nibin-org/tokens
|
|
29
|
+
# or
|
|
30
|
+
pnpm add @nibin-org/tokens
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Usage
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import { TokenDocumentation } from '@nibin-org/tokens';
|
|
37
|
+
import '@nibin-org/tokens/styles.css';
|
|
38
|
+
import tokens from './tokens.json';
|
|
39
|
+
|
|
40
|
+
export default function DesignTokensPage() {
|
|
41
|
+
return (
|
|
42
|
+
<TokenDocumentation
|
|
43
|
+
tokens={tokens}
|
|
44
|
+
title="My Design System"
|
|
45
|
+
subtitle="Design tokens synced from Figma"
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 📊 Token Structure
|
|
52
|
+
|
|
53
|
+
This library works with tokens exported from [Figma Tokens Studio](https://tokens.studio/). The expected structure is:
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"Colors/Value": {
|
|
58
|
+
"base": { "blue": { "50": { "value": "#1369e9", "type": "color" } } },
|
|
59
|
+
"fill": { "primary": { "value": "{base.blue.50}", "type": "color" } },
|
|
60
|
+
"stroke": { "default": { "value": "{base.gray.30}", "type": "color" } },
|
|
61
|
+
"text": { "default": { "value": "{base.gray.90}", "type": "color" } }
|
|
62
|
+
},
|
|
63
|
+
"Spacing/Mode 1": {
|
|
64
|
+
"space-sm": { "value": "8px", "type": "dimension" }
|
|
65
|
+
},
|
|
66
|
+
"Size/Mode 1": {
|
|
67
|
+
"size-lg": { "value": "16px", "type": "dimension" }
|
|
68
|
+
},
|
|
69
|
+
"Radius/Mode 1": {
|
|
70
|
+
"radius-md": { "value": "6px", "type": "dimension" }
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## 🔄 Figma-to-Code Workflow
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
|
|
79
|
+
│ │ │ │ │ │
|
|
80
|
+
│ Figma + │──────▶ tokens.json │──────▶ CSS + Docs │
|
|
81
|
+
│ Token Studio │ │ │ │ │
|
|
82
|
+
│ │ │ │ │ │
|
|
83
|
+
└─────────────────┘ └──────────────────┘ └─────────────────┘
|
|
84
|
+
│ │ │
|
|
85
|
+
Design tokens Export/sync Build script
|
|
86
|
+
in Figma via plugin generates CSS
|
|
87
|
+
+ visual docs
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Recommended Setup
|
|
91
|
+
|
|
92
|
+
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 this library to display beautiful token documentation
|
|
96
|
+
|
|
97
|
+
### Next.js Configuration
|
|
98
|
+
|
|
99
|
+
For Next.js projects (especially Next.js 15+), add the package to `transpilePackages` in your `next.config.ts`:
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
const nextConfig = {
|
|
103
|
+
transpilePackages: ['@nibin-org/tokens'],
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export default nextConfig;
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
> **Note**: If you experience module resolution issues with Next.js 16+ Turbopack during local development with linked packages, you can use `next dev --webpack` as a workaround.
|
|
110
|
+
|
|
111
|
+
## 📦 Components
|
|
112
|
+
|
|
113
|
+
### `<TokenDocumentation />` — Main Component
|
|
114
|
+
|
|
115
|
+
The all-in-one solution for displaying all your tokens.
|
|
116
|
+
|
|
117
|
+
| Prop | Type | Default | Description |
|
|
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 |
|
|
126
|
+
|
|
127
|
+
### Individual Components
|
|
128
|
+
|
|
129
|
+
For custom layouts, use components individually:
|
|
130
|
+
|
|
131
|
+
```tsx
|
|
132
|
+
import { ColorGrid, SpacingScale, RadiusShowcase, SizeScale } from '@nibin-org/tokens';
|
|
133
|
+
|
|
134
|
+
<ColorGrid
|
|
135
|
+
baseColors={tokens['Colors/Value'].base}
|
|
136
|
+
fillColors={tokens['Colors/Value'].fill}
|
|
137
|
+
/>
|
|
138
|
+
|
|
139
|
+
<SpacingScale tokens={tokens['Spacing/Mode 1']} />
|
|
140
|
+
|
|
141
|
+
<RadiusShowcase tokens={tokens['Radius/Mode 1']} />
|
|
142
|
+
|
|
143
|
+
<SizeScale tokens={tokens['Size/Mode 1']} />
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## 🎨 Theming
|
|
147
|
+
|
|
148
|
+
The styles use CSS custom properties, making it easy to customize:
|
|
149
|
+
|
|
150
|
+
```css
|
|
151
|
+
:root {
|
|
152
|
+
--ftd-accent: #6366f1; /* Primary accent color */
|
|
153
|
+
--ftd-bg-primary: #ffffff; /* Main background */
|
|
154
|
+
--ftd-text-primary: #0f172a; /* Main text color */
|
|
155
|
+
--ftd-radius-lg: 16px; /* Card border radius */
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## 🆚 Why Not Just Style Dictionary?
|
|
160
|
+
|
|
161
|
+
| Feature | Style Dictionary | @nibin-org/tokens |
|
|
162
|
+
|---------|-----------------|------------------|
|
|
163
|
+
| Token Transformation | ✅ Excellent | ❌ Not included |
|
|
164
|
+
| Multi-platform Output | ✅ Yes | ❌ No |
|
|
165
|
+
| **Visual Documentation** | ❌ None | ✅ Beautiful UI |
|
|
166
|
+
| **Interactive Exploration** | ❌ No | ✅ Yes |
|
|
167
|
+
| **Copy-to-Clipboard** | ❌ No | ✅ Yes |
|
|
168
|
+
| **Dark Mode** | ❌ No | ✅ Yes |
|
|
169
|
+
|
|
170
|
+
**Use both together!** Style Dictionary for transformation, @nibin-org/tokens for documentation.
|
|
171
|
+
|
|
172
|
+
## 🛠 Development
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
# Clone and install
|
|
176
|
+
git clone https://github.com/nibinlab99-dev/next-storybook.git
|
|
177
|
+
cd next-storybook
|
|
178
|
+
npm install
|
|
179
|
+
|
|
180
|
+
# Build tokens
|
|
181
|
+
npm run tokens:build
|
|
182
|
+
|
|
183
|
+
# Run dev server
|
|
184
|
+
npm run dev
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## 📄 License
|
|
188
|
+
|
|
189
|
+
MIT © [nibinlab99-dev](https://github.com/nibinlab99-dev)
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
<p align="center">
|
|
194
|
+
Made with ❤️ for design systems
|
|
195
|
+
</p>
|