@motion-proto/live-tokens 0.9.0 → 0.10.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 +50 -29
- package/dist-plugin/index.cjs +177 -125
- package/dist-plugin/index.d.cts +3 -2
- package/dist-plugin/index.d.ts +3 -2
- package/dist-plugin/index.js +177 -125
- package/package.json +4 -1
- package/src/editor/component-editor/BadgeEditor.svelte +44 -42
- package/src/editor/component-editor/ButtonEditor.svelte +224 -0
- package/src/editor/component-editor/CollapsibleSectionEditor.svelte +1 -7
- package/src/editor/component-editor/CornerBadgeEditor.svelte +44 -34
- package/src/editor/component-editor/ImageLightboxEditor.svelte +58 -0
- package/src/editor/component-editor/InputEditor.svelte +272 -0
- package/src/editor/component-editor/NotificationEditor.svelte +44 -65
- package/src/editor/component-editor/ProgressBarEditor.svelte +71 -87
- package/src/editor/component-editor/SegmentedControlEditor.svelte +98 -37
- package/src/editor/component-editor/SideNavigationEditor.svelte +342 -0
- package/src/editor/component-editor/registry.ts +35 -2
- package/src/editor/component-editor/scaffolding/ComponentFileManager.svelte +3 -2
- package/src/editor/component-editor/scaffolding/StateBlock.svelte +9 -10
- package/src/editor/component-editor/scaffolding/TokenLayout.svelte +60 -36
- package/src/editor/component-editor/scaffolding/VariantGroup.svelte +38 -1
- package/src/editor/component-editor/scaffolding/buildTypeGroupTokens.ts +1 -1
- package/src/editor/component-editor/scaffolding/siblings.ts +2 -2
- package/src/editor/component-editor/scaffolding/types.ts +2 -1
- package/src/editor/core/components/componentConfigService.ts +7 -6
- package/src/editor/core/manifests/manifestService.ts +5 -4
- package/src/editor/core/storage/apiBase.ts +15 -0
- package/src/editor/core/storage/files/versionedFileResourceClient.ts +1 -1
- package/src/editor/core/themes/migrations/2026-05-24-collapsiblesection-drop-active-state.ts +28 -0
- package/src/editor/core/themes/migrations/2026-05-24-progressbar-collapse-variants.ts +41 -0
- package/src/editor/core/themes/migrations/2026-05-24-promote-state-shared-tokens.ts +59 -0
- package/src/editor/core/themes/migrations/2026-05-24-segmentedcontrol-divider-inset.ts +29 -0
- package/src/editor/core/themes/migrations/2026-05-25-cornerbadge-flatten-variants.ts +46 -0
- package/src/editor/core/themes/migrations/index.ts +10 -0
- package/src/editor/core/themes/themeInit.ts +3 -2
- package/src/editor/core/themes/themeService.ts +3 -2
- package/src/editor/ui/UIEasingSelector.svelte +240 -0
- package/src/editor/ui/variantScales.ts +34 -0
- package/src/system/components/Button.svelte +34 -85
- package/src/system/components/CollapsibleSection.svelte +1 -48
- package/src/system/components/CornerBadge.svelte +72 -138
- package/src/system/components/ImageLightbox.svelte +578 -0
- package/src/system/components/Input.svelte +387 -0
- package/src/system/components/ProgressBar.svelte +62 -258
- package/src/system/components/SegmentedControl.svelte +81 -15
- package/src/system/components/SideNavigation.svelte +777 -0
- package/src/system/styles/tokens.css +43 -0
- package/src/system/styles/tokens.generated.css +4 -183
- package/src/editor/component-editor/StandardButtonsEditor.svelte +0 -190
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ A foundational design system for quickly styling and building Svelte + Vite micr
|
|
|
12
12
|
- **Per-component editor** (`/components` route, dev-only) — the home of real-time component-alias editing. Pick token aliases per component without writing CSS.
|
|
13
13
|
- **Live editor overlay** — pins to the top-right of every dev page. Opens the editor in a side panel or floating window so you edit *on the page you're styling*, not in a separate tab. Includes a "Page Source" button that opens the current page's `.svelte` file in VS Code.
|
|
14
14
|
- **Preset bundles** — capture a whole site configuration (active theme + every component's active config) as a single portable artifact. Drop a preset into a new project to restore the full styling in one step.
|
|
15
|
-
- **Vite plugin** — hosts the `/api/themes
|
|
15
|
+
- **Vite plugin** — hosts the `/api/live-tokens/{themes,component-configs,manifests}/*` routes that persist your edits to disk as you make them. The single namespace keeps live-tokens' routes from colliding with anything your app serves under `/api`.
|
|
16
16
|
|
|
17
17
|
## Quick install
|
|
18
18
|
|
|
@@ -32,21 +32,42 @@ export default defineConfig({
|
|
|
32
32
|
plugins: [
|
|
33
33
|
svelte(),
|
|
34
34
|
themeFileApi({
|
|
35
|
-
themesDir: 'themes',
|
|
36
35
|
tokensCssPath: 'src/system/styles/tokens.css',
|
|
37
36
|
}),
|
|
38
37
|
],
|
|
39
|
-
optimizeDeps: {
|
|
40
|
-
exclude: ['@motion-proto/live-tokens'],
|
|
41
|
-
},
|
|
42
38
|
});
|
|
43
39
|
```
|
|
44
40
|
|
|
45
41
|
The `themeFileApi` plugin:
|
|
46
|
-
- Seeds `themes/` with a default theme on first dev-server start.
|
|
47
|
-
- Discovers components at `src/system/components/*.svelte` and seeds `component-configs/{comp}/default.json` from each component's `:global(:root)` block.
|
|
48
|
-
- Hosts the `/api/*` routes the editor uses to save and load themes + per-component configs.
|
|
49
|
-
- Auto-injects `__PROJECT_ROOT__` for the overlay's "Page Source" link.
|
|
42
|
+
- Seeds `src/live-tokens/data/themes/` with a default theme on first dev-server start.
|
|
43
|
+
- Discovers components at `src/system/components/*.svelte` and seeds `src/live-tokens/data/component-configs/{comp}/default.json` from each component's `:global(:root)` block.
|
|
44
|
+
- Hosts the `/api/live-tokens/*` routes the editor uses to save and load themes + per-component configs.
|
|
45
|
+
- Auto-injects `__PROJECT_ROOT__` for the overlay's "Page Source" link and `__LIVE_TOKENS_API_BASE__` so the client uses whatever `apiBase` you configured.
|
|
46
|
+
|
|
47
|
+
### Where data lands — and how to move it
|
|
48
|
+
|
|
49
|
+
By default, the plugin reads and writes under one folder: `src/live-tokens/data/`. Inside that folder live three subdirectories — `themes/`, `manifests/`, `component-configs/` — each owned by the plugin.
|
|
50
|
+
|
|
51
|
+
To move them, create a `live-tokens.config.json` at your project root:
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"dataDir": "src/live-tokens/data"
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
All four keys are optional. `dataDir` is the headline knob — it relocates all three subfolders at once. The per-folder overrides exist for unusual layouts (e.g. a monorepo where themes are shared across packages but component-configs aren't):
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"dataDir": "src/live-tokens/data",
|
|
64
|
+
"themesDir": "../shared/themes",
|
|
65
|
+
"componentConfigsDir": "src/live-tokens/data/component-configs",
|
|
66
|
+
"manifestsDir": "src/live-tokens/data/manifests"
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Resolution order, per folder: explicit `themeFileApi(opts)` argument > matching key in `live-tokens.config.json` > `<dataDir>/<sub>`. The dev server reads the file once at startup — restart vite to pick up changes.
|
|
50
71
|
|
|
51
72
|
### Bootstrap in `main.ts`
|
|
52
73
|
|
|
@@ -228,38 +249,38 @@ Once linked, asking Claude to "add a Stat component to my live-tokens project" t
|
|
|
228
249
|
|
|
229
250
|
## How the editor ships changes to prod
|
|
230
251
|
|
|
231
|
-
1. Edit in `/editor` or `/components`. Saves write to
|
|
232
|
-
2. Promote a theme to "production." Its variables are written into `
|
|
233
|
-
3. `npm run build` bundles
|
|
252
|
+
1. Edit in `/editor` or `/components`. Saves write to `<dataDir>/themes/{name}.json` and `<dataDir>/component-configs/{comp}/{name}.json`.
|
|
253
|
+
2. Promote a theme to "production." Its variables are written into `tokens.generated.css` next to your authored `tokens.css`.
|
|
254
|
+
3. `npm run build` bundles both as plain CSS. No editor code, no JSON lookups, no dev surfaces ship to prod.
|
|
234
255
|
|
|
235
256
|
## File ownership — what the plugin writes
|
|
236
257
|
|
|
237
258
|
Knowing which files the plugin touches matters when upgrading the package or working in a repo you don't want overwritten.
|
|
238
259
|
|
|
239
|
-
**On `npm install` or `npm update`: nothing outside `node_modules/`.** No install hooks. Upgrading versions never touches your `
|
|
260
|
+
**On `npm install` or `npm update`: nothing outside `node_modules/`.** No install hooks. Upgrading versions never touches your `src/live-tokens/data/`, or any file in `src/` outside it.
|
|
240
261
|
|
|
241
|
-
**
|
|
262
|
+
**The plugin only writes inside two locations on disk:**
|
|
242
263
|
|
|
243
|
-
- `
|
|
244
|
-
- `
|
|
245
|
-
- `component-configs/{comp}/_active.json` and `_production.json` — same: only if missing.
|
|
246
|
-
- `component-configs/{comp}/default.json` — regenerated from the component's `:global(:root)` block **only when the `.svelte` source is newer than the existing default**. This file is a build artifact of the source; don't hand-edit it.
|
|
264
|
+
- `src/live-tokens/data/` (configurable via `live-tokens.config.json` — see "Where data lands").
|
|
265
|
+
- The CSS sidecars next to your `tokensCssPath` (`tokens.generated.css`, `fonts.css`).
|
|
247
266
|
|
|
248
|
-
|
|
267
|
+
It never writes to your project root, your `src/` outside the data folder, or anywhere else.
|
|
268
|
+
|
|
269
|
+
**At dev-server startup, the plugin only fills gaps — it never overwrites authored files:**
|
|
249
270
|
|
|
250
|
-
-
|
|
251
|
-
-
|
|
252
|
-
-
|
|
253
|
-
-
|
|
271
|
+
- `<dataDir>/themes/default.json` — written **only if missing**.
|
|
272
|
+
- `<dataDir>/themes/_active.json` and `_production.json` — written **only if missing**.
|
|
273
|
+
- `<dataDir>/component-configs/{comp}/_active.json` and `_production.json` — same: only if missing.
|
|
274
|
+
- `<dataDir>/component-configs/{comp}/default.json` — regenerated from the component's `:global(:root)` block **only when the `.svelte` source is newer than the existing default**. This file is a build artifact of the source; don't hand-edit it.
|
|
254
275
|
|
|
255
|
-
|
|
276
|
+
**At dev-time editor actions, these files get rewritten by your explicit save/promote:**
|
|
256
277
|
|
|
257
|
-
|
|
278
|
+
- `<dataDir>/themes/{name}.json` — every save in the editor.
|
|
279
|
+
- `<tokensCssPath sibling>/tokens.generated.css` — fully regenerated when you save or promote the production theme.
|
|
280
|
+
- `<tokensCssPath sibling>/fonts.css` — same rule: regenerated from the theme's font sources.
|
|
281
|
+
- `<dataDir>/component-configs/{comp}/{name}.json` — every save of a per-component config.
|
|
258
282
|
|
|
259
|
-
|
|
260
|
-
2. Verify tarball contents: `npm pack --dry-run`.
|
|
261
|
-
3. `npm publish`. `prepublishOnly` rebuilds `dist-plugin/`.
|
|
262
|
-
4. Tag and push: `git tag vX.Y.Z && git push origin main vX.Y.Z`.
|
|
283
|
+
The developer-authored `tokens.css` itself is **never written** by the plugin — it holds defaults you're free to hand-edit. The editor's overrides land in the sidecar `tokens.generated.css`, which the package imports immediately after `tokens.css`.
|
|
263
284
|
|
|
264
285
|
## License
|
|
265
286
|
|