tokvista 1.3.3 → 1.4.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 +180 -12
- package/dist/bin/tokvista.js +537 -67
- package/dist/cli/browser.js +16 -165
- package/dist/index.cjs +13 -162
- package/dist/index.d.cts +86 -23
- package/dist/index.d.ts +86 -23
- package/dist/index.js +13 -162
- package/dist/styles.css +3740 -3188
- package/package.json +10 -4
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
Visualize colors, spacing, typography, and component tokens with zero configuration.
|
|
12
12
|
|
|
13
|
-
[Live Demo](https://
|
|
13
|
+
[Live Demo](https://tokvista-demo.vercel.app/) · [Figma Setup Guide](./GUIDE.md) · [Report Issue](https://github.com/nibin-org/tokvista/issues)
|
|
14
14
|
|
|
15
15
|
</div>
|
|
16
16
|
|
|
@@ -21,11 +21,11 @@ Visualize colors, spacing, typography, and component tokens with zero configurat
|
|
|
21
21
|
Design token documentation is often static and hard to scan. **Tokvista** gives you:
|
|
22
22
|
|
|
23
23
|
- Beautiful visuals for colors, spacing, sizes, radius, and typography
|
|
24
|
+
- **Global format selector** - Switch between CSS Variables, SCSS, and Tailwind formats
|
|
24
25
|
- Instant search with `Cmd+K` / `Ctrl+K`
|
|
25
|
-
-
|
|
26
|
+
- One-click copy with format-aware variable names
|
|
26
27
|
- Semantic + component token views with aliases resolved
|
|
27
|
-
-
|
|
28
|
-
- Interactive playground for previews
|
|
28
|
+
- Generic **All Tokens** view for non-standard JSON structures
|
|
29
29
|
- Two usage modes: zero-setup CLI and React component library
|
|
30
30
|
|
|
31
31
|
---
|
|
@@ -41,7 +41,37 @@ npx tokvista tokens.json
|
|
|
41
41
|
Optional flags:
|
|
42
42
|
|
|
43
43
|
```bash
|
|
44
|
-
npx tokvista ./tokens.json --port 4000 --no-open
|
|
44
|
+
npx tokvista ./tokens.json --config ./tokvista.config.ts --port 4000 --no-open
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Create a starter config (recommended for branding/customization):
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npx tokvista init
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
`init` asks for title/subtitle/logo/theme/brand color/categories, writes `tokvista.config.ts`, and starts a live preview automatically.
|
|
54
|
+
|
|
55
|
+
### Tokvista Config (Recommended)
|
|
56
|
+
|
|
57
|
+
`tokvista init` creates `tokvista.config.ts` in your project root. You can customize it like this:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
export default {
|
|
61
|
+
title: 'Acme Design System',
|
|
62
|
+
subtitle: 'Interactive design tokens documentation',
|
|
63
|
+
logo: './logo.svg',
|
|
64
|
+
tokens: './tokens.json',
|
|
65
|
+
theme: 'system',
|
|
66
|
+
brandColor: '#6366f1',
|
|
67
|
+
categories: ['foundation', 'semantic', 'components'],
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Then run:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npx tokvista
|
|
45
75
|
```
|
|
46
76
|
|
|
47
77
|
### Option B: React Component Library
|
|
@@ -62,17 +92,108 @@ export default function DesignSystem() {
|
|
|
62
92
|
|
|
63
93
|
### CLI Options
|
|
64
94
|
|
|
95
|
+
- `tokvista init` - Interactive setup for `tokvista.config.ts` + auto preview
|
|
65
96
|
- `tokvista [tokens.json]` - Token file path (default: `./tokens.json`)
|
|
97
|
+
- `--config` / `-c` - Config file path (default auto-detect: `tokvista.config.ts|js|mjs|cjs|json`)
|
|
98
|
+
- `--force` / `-f` - Overwrite existing `tokvista.config.ts` (with `tokvista init`)
|
|
66
99
|
- `--port` / `-p` - Preferred port (default: `3000`)
|
|
67
100
|
- `--no-open` - Do not auto-open browser
|
|
101
|
+
- `--no-preview` - Skip auto-start after `tokvista init`
|
|
68
102
|
- `--help` / `-h` - Show help
|
|
69
103
|
- `Ctrl+C` - Stop the local server
|
|
70
104
|
|
|
105
|
+
### Try with a Sample `tokens.json`
|
|
106
|
+
|
|
107
|
+
You can copy this into a local `tokens.json` file and run Tokvista immediately:
|
|
108
|
+
|
|
109
|
+
```json
|
|
110
|
+
{
|
|
111
|
+
"Foundation/Value": {
|
|
112
|
+
"base": {
|
|
113
|
+
"color": {
|
|
114
|
+
"blue": {
|
|
115
|
+
"500": { "value": "#2563EB", "type": "color" },
|
|
116
|
+
"600": { "value": "#1D4ED8", "type": "color" }
|
|
117
|
+
},
|
|
118
|
+
"gray": {
|
|
119
|
+
"100": { "value": "#F3F4F6", "type": "color" },
|
|
120
|
+
"900": { "value": "#111827", "type": "color" }
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"space": {
|
|
124
|
+
"xs": { "value": "4px", "type": "spacing" },
|
|
125
|
+
"sm": { "value": "8px", "type": "spacing" },
|
|
126
|
+
"md": { "value": "16px", "type": "spacing" }
|
|
127
|
+
},
|
|
128
|
+
"size": {
|
|
129
|
+
"md": { "value": "40px", "type": "sizing" },
|
|
130
|
+
"lg": { "value": "48px", "type": "sizing" }
|
|
131
|
+
},
|
|
132
|
+
"radius": {
|
|
133
|
+
"sm": { "value": "6px", "type": "borderRadius" },
|
|
134
|
+
"md": { "value": "10px", "type": "borderRadius" }
|
|
135
|
+
},
|
|
136
|
+
"font-size": {
|
|
137
|
+
"sm": { "value": "12px", "type": "fontSize" },
|
|
138
|
+
"md": { "value": "14px", "type": "fontSize" }
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
"Semantic/Value": {
|
|
143
|
+
"fill": {
|
|
144
|
+
"primary": { "value": "{base.color.blue.500}", "type": "color" },
|
|
145
|
+
"surface": { "value": "{base.color.gray.100}", "type": "color" }
|
|
146
|
+
},
|
|
147
|
+
"stroke": {
|
|
148
|
+
"primary": { "value": "{base.color.blue.600}", "type": "color" }
|
|
149
|
+
},
|
|
150
|
+
"text": {
|
|
151
|
+
"primary": { "value": "{base.color.gray.900}", "type": "color" },
|
|
152
|
+
"inverse": { "value": "#FFFFFF", "type": "color" }
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
"Components/Mode 1": {
|
|
156
|
+
"button": {
|
|
157
|
+
"Primary": {
|
|
158
|
+
"fill": { "value": "#2563EB", "type": "color" },
|
|
159
|
+
"text": { "value": "#FFFFFF", "type": "color" },
|
|
160
|
+
"stroke": { "value": "#1D4ED8", "type": "color" }
|
|
161
|
+
},
|
|
162
|
+
"height": {
|
|
163
|
+
"md": { "value": "40px", "type": "dimension" }
|
|
164
|
+
},
|
|
165
|
+
"padding-x": {
|
|
166
|
+
"md": { "value": "16px", "type": "dimension" }
|
|
167
|
+
},
|
|
168
|
+
"padding-y": {
|
|
169
|
+
"md": { "value": "10px", "type": "dimension" }
|
|
170
|
+
},
|
|
171
|
+
"radius": {
|
|
172
|
+
"md": { "value": "10px", "type": "dimension" }
|
|
173
|
+
},
|
|
174
|
+
"font-size": {
|
|
175
|
+
"md": { "value": "14px", "type": "dimension" }
|
|
176
|
+
},
|
|
177
|
+
"line-height": {
|
|
178
|
+
"md": { "value": "20px", "type": "dimension" }
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
If you're contributing in this repository, a larger real-world sample is available at `tokens.json`.
|
|
187
|
+
For package users, run Tokvista with your own exported `tokens.json` file.
|
|
188
|
+
|
|
71
189
|
|
|
72
190
|
---
|
|
73
191
|
|
|
74
192
|
## What You Get
|
|
75
193
|
|
|
194
|
+
### Global Format Selector
|
|
195
|
+
Switch between CSS Variables (`var(--token)`), SCSS Variables (`$token`), and Tailwind Classes (`token`) with a single click. Your preference is saved and applied across all token displays and copy operations.
|
|
196
|
+
|
|
76
197
|
### Foundation Tokens
|
|
77
198
|
Visualize base tokens like colors, spacing, sizes, radius, and typography.
|
|
78
199
|
|
|
@@ -88,11 +209,14 @@ Export CSS, SCSS, JavaScript, or Tailwind config with high‑contrast syntax hig
|
|
|
88
209
|
### Playground
|
|
89
210
|
Preview components using your tokens and custom class names.
|
|
90
211
|
|
|
212
|
+
### All Tokens (Any JSON Shape)
|
|
213
|
+
Even when your file does not follow `Foundation/Value` or `Semantic/Value`, Tokvista now shows every token path/value/type in the **All Tokens** tab.
|
|
214
|
+
|
|
91
215
|
---
|
|
92
216
|
|
|
93
217
|
## Demo
|
|
94
218
|
|
|
95
|
-
Live demo: https://
|
|
219
|
+
Live demo: https://tokvista-demo.vercel.app/
|
|
96
220
|
|
|
97
221
|
Run it locally: see Local Development below.
|
|
98
222
|
|
|
@@ -146,11 +270,13 @@ Need a full setup guide? See **[GUIDE.md](./GUIDE.md)**.
|
|
|
146
270
|
| `tokens` | `FigmaTokens` | Required | Tokens object (W3C format or Token Studio) |
|
|
147
271
|
| `title` | `string` | `"Design Tokens"` | Main header title |
|
|
148
272
|
| `subtitle` | `string` | `"View and copy design tokens"` | Subtitle text |
|
|
149
|
-
| `
|
|
273
|
+
| `logo` | `string` | `undefined` | Optional logo URL (or data URL) rendered in the header |
|
|
274
|
+
| `categories` | `("foundation" \| "semantic" \| "components")[]` | `undefined` | Restrict which top-level tabs are shown |
|
|
150
275
|
| `fontFamilySans` | `string` | `undefined` | Override the UI sans font-family (CSS value). Load the font in your app. |
|
|
151
276
|
| `fontFamilyMono` | `string` | `undefined` | Override the UI mono font-family (CSS value). Load the font in your app. |
|
|
152
277
|
| `loadDefaultFonts` | `boolean` | `true` | When `true`, loads Inter + JetBrains Mono from Google Fonts. Set `false` to use only your app fonts. |
|
|
153
278
|
| `onTokenClick` | `(token) => void` | `undefined` | Callback when a token is clicked |
|
|
279
|
+
| `snapshotHistory` | `SnapshotHistoryOptions` | `undefined` | Enable built-in snapshot history panel. Use `accessMode: "preview"` for locked teaser mode and `"full"` for full access. |
|
|
154
280
|
|
|
155
281
|
### Custom Fonts
|
|
156
282
|
|
|
@@ -177,13 +303,46 @@ Use these to build custom layouts:
|
|
|
177
303
|
|
|
178
304
|
Each accepts `tokens` and optional `title`.
|
|
179
305
|
|
|
306
|
+
### Snapshot History
|
|
307
|
+
|
|
308
|
+
```tsx
|
|
309
|
+
import { TokenDocumentation, createGitHubSnapshotHistory } from 'tokvista'
|
|
310
|
+
|
|
311
|
+
<TokenDocumentation
|
|
312
|
+
tokens={tokens}
|
|
313
|
+
snapshotHistory={createGitHubSnapshotHistory({
|
|
314
|
+
owner: 'org',
|
|
315
|
+
repo: 'repo',
|
|
316
|
+
branch: 'main',
|
|
317
|
+
path: 'tokens.json',
|
|
318
|
+
accessMode: 'full', // use "preview" for hosted teaser links
|
|
319
|
+
})}
|
|
320
|
+
/>
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
Generate share links for hosted preview:
|
|
324
|
+
|
|
325
|
+
```ts
|
|
326
|
+
import { createGitHubPreviewUrl } from 'tokvista'
|
|
327
|
+
|
|
328
|
+
const livePreview = createGitHubPreviewUrl({
|
|
329
|
+
owner: 'org',
|
|
330
|
+
repo: 'repo',
|
|
331
|
+
branch: 'main',
|
|
332
|
+
path: 'tokens.json',
|
|
333
|
+
previewBaseUrl: 'https://tokvista-demo.vercel.app/',
|
|
334
|
+
})
|
|
335
|
+
```
|
|
336
|
+
|
|
180
337
|
---
|
|
181
338
|
|
|
182
339
|
## Search and Copy
|
|
183
340
|
|
|
184
|
-
- Search across token names and values
|
|
341
|
+
- Search across token names and values with `Cmd+K` / `Ctrl+K`
|
|
185
342
|
- Keyboard navigation with Enter to focus
|
|
186
|
-
-
|
|
343
|
+
- **Format-aware copying** - Choose between CSS Variables, SCSS, or Tailwind
|
|
344
|
+
- Variable names display in your selected format
|
|
345
|
+
- Preference persists across sessions
|
|
187
346
|
|
|
188
347
|
---
|
|
189
348
|
|
|
@@ -201,25 +360,34 @@ Each accepts `tokens` and optional `title`.
|
|
|
201
360
|
## Local Development
|
|
202
361
|
|
|
203
362
|
```bash
|
|
204
|
-
#
|
|
363
|
+
# package users (published npm package)
|
|
364
|
+
npx tokvista init
|
|
365
|
+
npx tokvista
|
|
366
|
+
|
|
367
|
+
# contributors testing local unpublished changes (this repo)
|
|
368
|
+
source ~/.nvm/nvm.sh
|
|
369
|
+
nvm use 20
|
|
205
370
|
npm install
|
|
206
371
|
npm run build
|
|
207
|
-
node dist/bin/tokvista.js
|
|
372
|
+
node dist/bin/tokvista.js init --no-preview
|
|
373
|
+
node dist/bin/tokvista.js --config ./tokvista.config.ts --port 4000
|
|
208
374
|
|
|
209
375
|
# demo app
|
|
210
376
|
cd demo
|
|
211
377
|
npm install
|
|
378
|
+
# optional: copy demo/.env.example to demo/.env.local and set NEXT_PUBLIC_DEMO_SOURCE
|
|
212
379
|
npm run dev
|
|
213
380
|
```
|
|
214
381
|
|
|
215
382
|
CLI defaults to `http://localhost:3000` and demo dev runs at `http://localhost:3000/`, so use a custom CLI port (for example `4000`) when running both.
|
|
383
|
+
Package users should use `npx tokvista ...`. `node dist/bin/tokvista.js ...` is only for local testing before publish.
|
|
216
384
|
Note: production demo is served under `/tokvista/`.
|
|
217
385
|
|
|
218
386
|
---
|
|
219
387
|
|
|
220
388
|
## Resources
|
|
221
389
|
|
|
222
|
-
- [Live Demo](https://
|
|
390
|
+
- [Live Demo](https://tokvista-demo.vercel.app/)
|
|
223
391
|
- [Figma Setup Guide](./GUIDE.md)
|
|
224
392
|
- [GitHub Repository](https://github.com/nibin-org/tokvista)
|
|
225
393
|
- [Issue Tracker](https://github.com/nibin-org/tokvista/issues)
|