tokvista 1.3.4 → 1.4.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 CHANGED
@@ -23,11 +23,10 @@ Design token documentation is often static and hard to scan. **Tokvista** gives
23
23
  - Beautiful visuals for colors, spacing, sizes, radius, and typography
24
24
  - **Global format selector** - Switch between CSS Variables, SCSS, and Tailwind formats
25
25
  - Instant search with `Cmd+K` / `Ctrl+K`
26
- - One-click copy with format-aware variable names
27
- - Semantic + component token views with aliases resolved
28
- - Generic **All Tokens** view for non-standard JSON structures
29
- - Interactive playground for previews
30
- - Two usage modes: zero-setup CLI and React component library
26
+ - One-click copy with format-aware variable names
27
+ - Semantic + component token views with aliases resolved
28
+ - Generic **All Tokens** view for non-standard JSON structures
29
+ - Two usage modes: zero-setup CLI and React component library
31
30
 
32
31
  ---
33
32
 
@@ -42,7 +41,37 @@ npx tokvista tokens.json
42
41
  Optional flags:
43
42
 
44
43
  ```bash
45
- 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
46
75
  ```
47
76
 
48
77
  ### Option B: React Component Library
@@ -63,9 +92,13 @@ export default function DesignSystem() {
63
92
 
64
93
  ### CLI Options
65
94
 
95
+ - `tokvista init` - Interactive setup for `tokvista.config.ts` + auto preview
66
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`)
67
99
  - `--port` / `-p` - Preferred port (default: `3000`)
68
100
  - `--no-open` - Do not auto-open browser
101
+ - `--no-preview` - Skip auto-start after `tokvista init`
69
102
  - `--help` / `-h` - Show help
70
103
  - `Ctrl+C` - Stop the local server
71
104
 
@@ -234,11 +267,13 @@ Need a full setup guide? See **[GUIDE.md](./GUIDE.md)**.
234
267
 
235
268
  | Prop | Type | Default | Description |
236
269
  |------|------|---------|-------------|
237
- | `tokens` | `FigmaTokens` | Required | Tokens object (W3C format or Token Studio) |
238
- | `title` | `string` | `"Design Tokens"` | Main header title |
239
- | `subtitle` | `string` | `"View and copy design tokens"` | Subtitle text |
240
- | `fontFamilySans` | `string` | `undefined` | Override the UI sans font-family (CSS value). Load the font in your app. |
241
- | `fontFamilyMono` | `string` | `undefined` | Override the UI mono font-family (CSS value). Load the font in your app. |
270
+ | `tokens` | `FigmaTokens` | Required | Tokens object (W3C format or Token Studio) |
271
+ | `title` | `string` | `"Design Tokens"` | Main header title |
272
+ | `subtitle` | `string` | `"View and copy design tokens"` | Subtitle text |
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 |
275
+ | `fontFamilySans` | `string` | `undefined` | Override the UI sans font-family (CSS value). Load the font in your app. |
276
+ | `fontFamilyMono` | `string` | `undefined` | Override the UI mono font-family (CSS value). Load the font in your app. |
242
277
  | `loadDefaultFonts` | `boolean` | `true` | When `true`, loads Inter + JetBrains Mono from Google Fonts. Set `false` to use only your app fonts. |
243
278
  | `onTokenClick` | `(token) => void` | `undefined` | Callback when a token is clicked |
244
279
  | `snapshotHistory` | `SnapshotHistoryOptions` | `undefined` | Enable built-in snapshot history panel. Use `accessMode: "preview"` for locked teaser mode and `"full"` for full access. |
@@ -268,36 +303,36 @@ Use these to build custom layouts:
268
303
 
269
304
  Each accepts `tokens` and optional `title`.
270
305
 
271
- ### Snapshot History
272
-
273
- ```tsx
274
- import { TokenDocumentation, createGitHubSnapshotHistory } from 'tokvista'
275
-
276
- <TokenDocumentation
277
- tokens={tokens}
278
- snapshotHistory={createGitHubSnapshotHistory({
279
- owner: 'org',
280
- repo: 'repo',
281
- branch: 'main',
282
- path: 'tokens.json',
283
- accessMode: 'full', // use "preview" for hosted teaser links
284
- })}
285
- />
286
- ```
287
-
288
- Generate share links for hosted preview:
289
-
290
- ```ts
291
- import { createGitHubPreviewUrl } from 'tokvista'
292
-
293
- const livePreview = createGitHubPreviewUrl({
294
- owner: 'org',
295
- repo: 'repo',
296
- branch: 'main',
297
- path: 'tokens.json',
298
- previewBaseUrl: 'https://tokvista-demo.vercel.app/',
299
- })
300
- ```
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
+ ```
301
336
 
302
337
  ---
303
338
 
@@ -325,19 +360,27 @@ const livePreview = createGitHubPreviewUrl({
325
360
  ## Local Development
326
361
 
327
362
  ```bash
328
- # root package
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
329
370
  npm install
330
371
  npm run build
331
- node dist/bin/tokvista.js ../tokens.json --port 4000
372
+ node dist/bin/tokvista.js init --no-preview
373
+ node dist/bin/tokvista.js --config ./tokvista.config.ts --port 4000
332
374
 
333
- # demo app
334
- cd demo
335
- npm install
336
- # optional: copy demo/.env.example to demo/.env.local and set NEXT_PUBLIC_DEMO_SOURCE
337
- npm run dev
338
- ```
375
+ # demo app
376
+ cd demo
377
+ npm install
378
+ # optional: copy demo/.env.example to demo/.env.local and set NEXT_PUBLIC_DEMO_SOURCE
379
+ npm run dev
380
+ ```
339
381
 
340
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.
341
384
  Note: production demo is served under `/tokvista/`.
342
385
 
343
386
  ---