@motion-proto/live-tokens 0.62.0 → 0.64.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/.claude/skills/live-tokens-adjust-geometry/SKILL.md +4 -4
- package/.claude/skills/live-tokens-build-page/SKILL.md +21 -3
- package/.claude/skills/live-tokens-create-component/SKILL.md +16 -48
- package/.claude/skills/live-tokens-create-component/references/fixed-overlays.md +10 -1
- package/.claude/skills/live-tokens-create-component/references/intrinsics.md +7 -5
- package/.claude/skills/live-tokens-create-component/references/sketch-mode.md +1 -1
- package/.claude/skills/live-tokens-create-component/references/token-naming.md +50 -0
- package/.claude/skills/live-tokens-generate-theme/SKILL.md +16 -9
- package/.claude/skills/live-tokens-pair-fonts/SKILL.md +8 -6
- package/.claude/skills/live-tokens-pick-component/SKILL.md +19 -5
- package/CHANGELOG.md +100 -0
- package/bin/migrate.mjs +6 -2
- package/dist-plugin/adjust/index.cjs +1 -1
- package/dist-plugin/adjust/index.d.cts +1 -1
- package/dist-plugin/adjust/index.d.ts +1 -1
- package/dist-plugin/adjust/index.js +1 -1
- package/dist-plugin/{chunk-232GZGQU.js → chunk-NDJJORKJ.js} +342 -5
- package/dist-plugin/{chunk-Y5CNFSSV.js → chunk-RVE3MNKM.js} +1 -1
- package/dist-plugin/{chunk-OPYOK2CA.js → chunk-ZHPX7ZYQ.js} +39 -1
- package/dist-plugin/{dataPaths-CRfD1LdA.d.ts → dataPaths-DZUzVv8H.d.cts} +3 -3
- package/dist-plugin/{dataPaths-CRfD1LdA.d.cts → dataPaths-DZUzVv8H.d.ts} +3 -3
- package/dist-plugin/fontPairing/index.cjs +32 -8
- package/dist-plugin/fontPairing/index.d.cts +1 -1
- package/dist-plugin/fontPairing/index.d.ts +1 -1
- package/dist-plugin/fontPairing/index.js +32 -8
- package/dist-plugin/generateColorsAndType/index.cjs +1 -1
- package/dist-plugin/generateColorsAndType/index.d.cts +1 -1
- package/dist-plugin/generateColorsAndType/index.d.ts +1 -1
- package/dist-plugin/generateColorsAndType/index.js +1 -1
- package/dist-plugin/index.cjs +417 -34
- package/dist-plugin/index.d.cts +1 -1
- package/dist-plugin/index.d.ts +1 -1
- package/dist-plugin/index.js +31 -23
- package/dist-plugin/migrateData/index.cjs +350 -9
- package/dist-plugin/migrateData/index.d.cts +1 -1
- package/dist-plugin/migrateData/index.d.ts +1 -1
- package/dist-plugin/migrateData/index.js +9 -5
- package/dist-plugin/tokensCssMigrations/index.cjs +39 -1
- package/dist-plugin/tokensCssMigrations/index.d.cts +1 -1
- package/dist-plugin/tokensCssMigrations/index.d.ts +1 -1
- package/dist-plugin/tokensCssMigrations/index.js +2 -2
- package/package.json +9 -2
- package/src/app/site.css +16 -0
- package/src/editor/core/fonts/googleFontsUrl.ts +44 -8
- package/src/editor/core/preview/lookPreview.ts +46 -5
- package/src/editor/core/productionPulse.ts +6 -2
- package/src/editor/core/sketch/index.ts +60 -0
- package/src/editor/core/sketch/maskField.ts +5 -5
- package/src/editor/core/sketch/sketchLayer.ts +19 -8
- package/src/editor/core/sketch/sketchStore.ts +238 -85
- package/src/editor/core/sketch/{sketchPresetService.ts → sketchStyleService.ts} +14 -14
- package/src/editor/core/sketch/{sketchPresets.ts → sketchStyles.ts} +17 -17
- package/src/editor/core/themes/themeDocumentSync.ts +2 -0
- package/src/editor/core/themes/themeInit.ts +19 -1
- package/src/editor/core/themes/themeService.ts +7 -2
- package/src/editor/core/themes/themeTypes.ts +5 -0
- package/src/editor/docs/content/editing-tokens.md +1 -1
- package/src/editor/docs/content/sketch-mode.md +27 -16
- package/src/editor/docs/content/themes-workflow.md +30 -21
- package/src/editor/docs/content/where-themes-live.md +9 -5
- package/src/editor/docs/content.generated.ts +4 -4
- package/src/editor/overlay/LiveTokensRouter.svelte +1 -1
- package/src/editor/ui/EditorViewSwitcher.svelte +3 -3
- package/src/editor/ui/FontStackEditor.svelte +49 -11
- package/src/editor/ui/ProjectFontsSection.svelte +6 -0
- package/src/editor/ui/ThemePanel.svelte +47 -1
- package/src/editor/ui/sections/textStyles.ts +15 -1
- package/src/editor/ui/sketch/SketchPreview.svelte +3 -3
- package/src/editor/ui/sketch/SketchTab.svelte +87 -53
- package/src/system/components/FloatingTokenTags.css +10 -8
- package/src/system/styles/tokens.css +17 -2
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { AliasDiskValue, ColorsAndType } from './themeTypes';
|
|
1
|
+
import type { AliasDiskValue, ColorsAndType, Theme } from './themeTypes';
|
|
2
2
|
import { openThemeSlug } from '../store/editorConfigStore';
|
|
3
3
|
import { migrateColorsAndTypeFonts } from '../fonts/fontMigration';
|
|
4
4
|
import { loadFromFile, seedComponentsFromApi } from '../store/editorStore';
|
|
5
5
|
import { getActiveComponentConfig, type ComponentSummary } from '../components/componentConfigService';
|
|
6
6
|
import { safeFetch } from '../storage/storage';
|
|
7
7
|
import { API_BASE } from '../storage/apiBase';
|
|
8
|
+
import { hasPersistedSketchState, openThemeSketchStyle, themeSketchStyle } from '../sketch/sketchStore';
|
|
8
9
|
|
|
9
10
|
interface ListComponentsDto {
|
|
10
11
|
components: ComponentSummary[];
|
|
@@ -61,4 +62,21 @@ export async function initializeTheme(): Promise<void> {
|
|
|
61
62
|
// and CSS defaults because one request happened to fail during boot.
|
|
62
63
|
if (!componentReadFailed) seedComponentsFromApi(configs);
|
|
63
64
|
}
|
|
65
|
+
|
|
66
|
+
const active = await safeFetch<Theme>(`${API_BASE}/themes/active`);
|
|
67
|
+
// A failed fetch is not "the theme carries no sketchstyle": treating null as
|
|
68
|
+
// absent would tell the panel the look is off the theme, or hand a fresh
|
|
69
|
+
// browser a blank buffer, over a fetch that will likely succeed next time.
|
|
70
|
+
if (active) {
|
|
71
|
+
if (hasPersistedSketchState()) {
|
|
72
|
+
// The buffer already painted on the first frame; boot only learns what
|
|
73
|
+
// the theme holds so unsaved dial work reads as unsaved rather than
|
|
74
|
+
// getting silently overwritten (that overwrite is what Apply is for).
|
|
75
|
+
themeSketchStyle.set(active.sketchStyle);
|
|
76
|
+
} else {
|
|
77
|
+
// Nothing was ever recorded in this browser: the theme's value becomes
|
|
78
|
+
// the live value, the same reconciliation opening a theme performs.
|
|
79
|
+
openThemeSketchStyle(active.sketchStyle);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
64
82
|
}
|
|
@@ -7,6 +7,7 @@ import { getActiveColorsAndType } from './colorsAndTypeService';
|
|
|
7
7
|
import { broadcastAppliedTheme, hydrateAppliedTheme } from './themeDocumentSync';
|
|
8
8
|
import { CURRENT_COMPONENT_SCHEMA_VERSION } from './migrations';
|
|
9
9
|
import { THEME_SCHEMA_VERSION } from './themeTypes';
|
|
10
|
+
import { liveSketchStyle, themeSketchStyle } from '../sketch/sketchStore';
|
|
10
11
|
|
|
11
12
|
export type { ThemeFillReport };
|
|
12
13
|
|
|
@@ -144,7 +145,7 @@ function withoutLiveMarkers<T extends { _fileName?: string; _source?: unknown }>
|
|
|
144
145
|
* way out of `GET /colors-and-type/active`, which matters: the server trusts an
|
|
145
146
|
* already-embedded copy and runs no migrations over it on write.
|
|
146
147
|
*/
|
|
147
|
-
async function captureLook(): Promise<Pick<Theme, 'colorsAndType' | 'componentConfigs'>> {
|
|
148
|
+
async function captureLook(): Promise<Pick<Theme, 'colorsAndType' | 'componentConfigs' | 'sketchStyle'>> {
|
|
148
149
|
const liveColorsAndType = await getActiveColorsAndType();
|
|
149
150
|
if (!liveColorsAndType) {
|
|
150
151
|
throw new Error('No live colors and type to capture');
|
|
@@ -156,7 +157,9 @@ async function captureLook(): Promise<Pick<Theme, 'colorsAndType' | 'componentCo
|
|
|
156
157
|
const config = configs[i];
|
|
157
158
|
if (config) componentConfigs[c.name] = withoutLiveMarkers(config);
|
|
158
159
|
});
|
|
159
|
-
|
|
160
|
+
// Sketchstyle has no server door of its own (RJC 8): the live buffer, not a
|
|
161
|
+
// fetch, is the source of truth for what the dials currently say.
|
|
162
|
+
return { colorsAndType: withoutLiveMarkers(liveColorsAndType), componentConfigs, sketchStyle: liveSketchStyle() };
|
|
160
163
|
}
|
|
161
164
|
|
|
162
165
|
/**
|
|
@@ -178,6 +181,7 @@ export async function saveAsTheme(
|
|
|
178
181
|
componentSchemaVersion: CURRENT_COMPONENT_SCHEMA_VERSION,
|
|
179
182
|
...look,
|
|
180
183
|
});
|
|
184
|
+
themeSketchStyle.set(look.sketchStyle);
|
|
181
185
|
liveMovedSinceBake.set(true);
|
|
182
186
|
await setActiveTheme(fileName);
|
|
183
187
|
}
|
|
@@ -201,6 +205,7 @@ export async function saveActiveTheme(displayName?: string): Promise<void> {
|
|
|
201
205
|
componentSchemaVersion: CURRENT_COMPONENT_SCHEMA_VERSION,
|
|
202
206
|
...look,
|
|
203
207
|
});
|
|
208
|
+
themeSketchStyle.set(look.sketchStyle);
|
|
204
209
|
liveMovedSinceBake.set(true);
|
|
205
210
|
}
|
|
206
211
|
|
|
@@ -2,6 +2,7 @@ import type { CurveAnchor } from '../../ui/curveEngine';
|
|
|
2
2
|
import type { GradientValue } from './parsers/gradient';
|
|
3
3
|
import type { Oklch } from '../palettes/oklch';
|
|
4
4
|
import type { HarmonyAxis } from '../palettes/colorHarmony';
|
|
5
|
+
import type { SketchStyle } from '../sketch/sketchStyles';
|
|
5
6
|
/** Single source of truth for the theme schema version
|
|
6
7
|
* (docs/plans/theme-completeness.md, Wave 2 step 5). It lives here, on the
|
|
7
8
|
* shipped side: `vite-plugin/` is build tooling and is not in the tarball, so
|
|
@@ -279,6 +280,10 @@ export interface Theme {
|
|
|
279
280
|
* buy no isolation. `normalizeTheme` sets this on every read; an embedded
|
|
280
281
|
* config's own `schemaVersion` (if hand-authored) is ignored and stripped. */
|
|
281
282
|
componentSchemaVersion: number;
|
|
283
|
+
/** The sketchstyle this look paints, by value. Absent means the look is
|
|
284
|
+
* crisp: presence is the on state, so there is no separate flag that can
|
|
285
|
+
* disagree with the dials beside it (RJC 1). */
|
|
286
|
+
sketchStyle?: SketchStyle;
|
|
282
287
|
/** Server-attached file-name marker. Same role as `ColorsAndType._fileName`. */
|
|
283
288
|
_fileName?: string;
|
|
284
289
|
}
|
|
@@ -11,7 +11,7 @@ The editor has four views:
|
|
|
11
11
|
tell across a page.
|
|
12
12
|
- **Components**: per-component editors. Re-Assign what tokens a component uses
|
|
13
13
|
without changing the underlying system.
|
|
14
|
-
- **
|
|
14
|
+
- **Sketchstyle**: an effect layer that redraws the page by hand. See
|
|
15
15
|
[Sketch mode](sketch-mode.md).
|
|
16
16
|
|
|
17
17
|
This page covers **Tokens**. For components, see
|
|
@@ -4,12 +4,11 @@ Sketch mode redraws your whole page as if it had been drawn by hand. Every
|
|
|
4
4
|
component keeps its own colours, spacing and corners; what changes is the line
|
|
5
5
|
they are drawn with.
|
|
6
6
|
|
|
7
|
-
It is an effect layer, not a set of token values. It
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
it goes.
|
|
7
|
+
It is an effect layer, not a set of token values. It never touches a token
|
|
8
|
+
itself, so turning it off returns every component to exactly what its tokens
|
|
9
|
+
already say. A production build never carries the drawing.
|
|
11
10
|
|
|
12
|
-
Open the **
|
|
11
|
+
Open the **Sketchstyle** view in the editor and switch **Sketch mode** on. The effect
|
|
13
12
|
applies to the page behind the editor as well as to the preview, so what you see
|
|
14
13
|
in context is what it does.
|
|
15
14
|
|
|
@@ -21,10 +20,10 @@ are pushed around one shared field of noise. Because every component samples the
|
|
|
21
20
|
same field, the whole page reads as one drawing rather than as a set of
|
|
22
21
|
separately wobbled boxes.
|
|
23
22
|
|
|
24
|
-
## The
|
|
23
|
+
## The sketchstyles
|
|
25
24
|
|
|
26
25
|
Seven looks ship with the package, and each is a complete set of dials rather
|
|
27
|
-
than a
|
|
26
|
+
than just a name:
|
|
28
27
|
|
|
29
28
|
- **Pencil.** Two graphite passes on their own seeds, so the outline disagrees
|
|
30
29
|
with itself the way a hand coming back round does.
|
|
@@ -39,9 +38,10 @@ than a style name:
|
|
|
39
38
|
- **Napkin.** Ballpoint in a hurry. Everything loose at once.
|
|
40
39
|
- **Dry marker.** Ink that ran out. One scratchy pass over a mostly eaten fill.
|
|
41
40
|
|
|
42
|
-
Pick one, then move whatever you like. **Save
|
|
43
|
-
your own, alongside the shipped seven, as a file under
|
|
44
|
-
`src/live-tokens/data/sketch-
|
|
41
|
+
Pick one, then move whatever you like. **Save as sketchstyle…** keeps your
|
|
42
|
+
dials under a name of your own, alongside the shipped seven, as a file under
|
|
43
|
+
`src/live-tokens/data/sketch-styles/`. That is a different gesture from
|
|
44
|
+
saving a theme; see "Where the settings live" below.
|
|
45
45
|
|
|
46
46
|
## The dials
|
|
47
47
|
|
|
@@ -70,14 +70,25 @@ your own, alongside the shipped seven, as a file under
|
|
|
70
70
|
|
|
71
71
|
## Where the settings live
|
|
72
72
|
|
|
73
|
-
The
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
The sketch layer is part of the theme, the same way colors and type are.
|
|
74
|
+
**Save** in the Theme panel folds your dials into the open theme; **Load**
|
|
75
|
+
applies whatever a theme carries, and turns the effect off for a theme that
|
|
76
|
+
carries none.
|
|
77
|
+
|
|
78
|
+
Until you save, the dials sit in your browser only. The Theme panel calls
|
|
79
|
+
that state off the theme, the same word it uses for an unsaved component
|
|
80
|
+
change. The built-in **Motion Proto** theme is read-only, so Save
|
|
81
|
+
is disabled there; use **Save As** to fold the dials into a theme of your
|
|
82
|
+
own.
|
|
83
|
+
|
|
84
|
+
**Save as sketchstyle…** in the **Sketchstyle** view is a different gesture. It
|
|
85
|
+
writes a named sketchstyle to `src/live-tokens/data/sketch-styles/`, a look you
|
|
86
|
+
can pick from any theme. It never touches the open theme, and it never marks
|
|
87
|
+
the look off the theme.
|
|
77
88
|
|
|
78
89
|
Sketch mode is a tool for looking at the page, not a layer the page can ship.
|
|
79
|
-
|
|
80
|
-
production build has no sketch layer in it at all.
|
|
90
|
+
The theme records the dials, but nothing bakes them: `tokens.generated.css`
|
|
91
|
+
never sees them, and a production build has no sketch layer in it at all.
|
|
81
92
|
|
|
82
93
|
## Drawing your own elements
|
|
83
94
|
|
|
@@ -5,14 +5,19 @@ Save your work, switch between looks, and ship one to production.
|
|
|
5
5
|
## The Theme panel
|
|
6
6
|
|
|
7
7
|
The **Theme** panel at the foot of the editor sidebar holds the whole look:
|
|
8
|
-
colors, type,
|
|
9
|
-
name the look ships under, whether production is running
|
|
10
|
-
|
|
8
|
+
colors, type, a setting for every component, and the sketch layer, in one
|
|
9
|
+
file. It carries the name the look ships under, whether production is running
|
|
10
|
+
it, and **Adopt**. Three parts sit under it, each a read-out rather than a
|
|
11
|
+
file to manage.
|
|
11
12
|
|
|
12
13
|
- **Colors & Type** holds the design tokens. Components read those tokens to
|
|
13
14
|
define their appearance. It names the two faces the page is showing.
|
|
14
15
|
- **Components** counts how many components have an unsaved edit that has not
|
|
15
16
|
been saved into the theme, and opens the component editors.
|
|
17
|
+
- **Sketchstyle** names the look the theme's sketch layer carries: its label, or
|
|
18
|
+
off the theme when what's on screen no longer matches what was saved, or
|
|
19
|
+
none when the theme carries no sketch layer. It travels with the theme
|
|
20
|
+
like colors and type do, but never reaches a production build.
|
|
16
21
|
|
|
17
22
|
A theme holds its own copy of every part, so one theme can never break another.
|
|
18
23
|
|
|
@@ -21,13 +26,15 @@ A theme holds its own copy of every part, so one theme can never break another.
|
|
|
21
26
|
A theme is a document, and the editor works the way any editor does.
|
|
22
27
|
|
|
23
28
|
- **A theme** is a named JSON file in `src/live-tokens/data/themes/`. It carries
|
|
24
|
-
the whole look: the colors and type
|
|
29
|
+
the whole look: the colors and type, a setting for every component, and the
|
|
30
|
+
sketch layer.
|
|
25
31
|
- **The open theme** is the one the editor is working on, named in
|
|
26
32
|
`themes/_active.json`. One at a time.
|
|
27
33
|
- **Your unsaved edits** are what the page shows right now. The editor keeps
|
|
28
|
-
them in your browser as you work
|
|
29
|
-
one slot
|
|
30
|
-
|
|
34
|
+
them in your browser as you work, writing most parts to a buffer,
|
|
35
|
+
`_working.json`, one slot each; the sketch layer has no buffer and stays
|
|
36
|
+
live in the browser until you save. **Save** captures all of it into the
|
|
37
|
+
open theme.
|
|
31
38
|
- **The production theme** is the one your site ships, named in
|
|
32
39
|
`themes/_production.json`. **Adopt** changes it; saving a preset in the Theme
|
|
33
40
|
Picker performs that Adopt for you.
|
|
@@ -96,29 +103,31 @@ to it, and the editor never overwrites it, so start your own with **Save As**.
|
|
|
96
103
|
## Switching
|
|
97
104
|
|
|
98
105
|
**Load**—or clicking the active theme's name—opens the Theme Picker. Picking a
|
|
99
|
-
theme shows it on the page as a preview with nothing written to disk,
|
|
100
|
-
try each look and compare. **Save** in that window
|
|
101
|
-
theme in one step: the active pointer changes,
|
|
102
|
-
works on it, and production ships it. **Cancel**
|
|
103
|
-
|
|
106
|
+
theme shows it on the page as a preview with nothing written to disk, sketch
|
|
107
|
+
layer included, so you can try each look and compare. **Save** in that window
|
|
108
|
+
opens and adopts the previewed theme in one step: the active pointer changes,
|
|
109
|
+
the buffers clear, the editor works on it, and production ships it. **Cancel**
|
|
110
|
+
returns you to where you were, unsaved sketch dials included. Previewing alone
|
|
111
|
+
never changes what your site ships.
|
|
104
112
|
|
|
105
113
|
**Colors and type only. Keep my shapes.** narrows the load to the palette and
|
|
106
|
-
the fonts: your component settings stay as they are and
|
|
107
|
-
stays open. Saved colors and type files are listed
|
|
108
|
-
type*, and picking one is always that narrower
|
|
114
|
+
the fonts: your component settings and your sketch layer stay as they are, and
|
|
115
|
+
the theme you have open stays open. Saved colors and type files are listed
|
|
116
|
+
there too, marked *colors & type*, and picking one is always that narrower
|
|
117
|
+
load.
|
|
109
118
|
|
|
110
119
|
## Shipping
|
|
111
120
|
|
|
112
|
-
**Adopt**, in the Theme panel, is the "ship it" step
|
|
113
|
-
|
|
121
|
+
**Adopt**, in the Theme panel, is the "ship it" step. It saves the open theme,
|
|
122
|
+
then bakes the colors and type plus every component the theme carries into
|
|
114
123
|
`src/live-tokens/data/tokens.generated.css`, which your build bundles alongside
|
|
115
|
-
`tokens.css
|
|
116
|
-
regenerate to match. The line under the theme name
|
|
117
|
-
running this theme.
|
|
124
|
+
`tokens.css`. The sketch layer is the one part of the theme Adopt never bakes:
|
|
125
|
+
it stays a preview. Fonts regenerate to match. The line under the theme name
|
|
126
|
+
says whether production is running this theme.
|
|
118
127
|
|
|
119
128
|
Production is one saved theme, so nothing else publishes. Trying a look, moving
|
|
120
129
|
a token, saving a theme: all of it leaves the generated CSS alone until you
|
|
121
|
-
Adopt. A component editor's Adopt runs the same
|
|
130
|
+
Adopt. A component editor's Adopt runs the same save-then-bake step, because a
|
|
122
131
|
component never ships alone. Adopting while Motion Proto is open saves your look
|
|
123
132
|
as a theme of your own first, since the built-in one is read-only.
|
|
124
133
|
|
|
@@ -20,15 +20,17 @@ src/live-tokens/data/
|
|
|
20
20
|
default.json Button's shipped settings, derived at boot
|
|
21
21
|
_working.json unsaved Button edits
|
|
22
22
|
my-button.json a preset you saved from the Button editor
|
|
23
|
+
sketch-styles/
|
|
24
|
+
my-look.json a sketchstyle saved from the Sketchstyle view
|
|
23
25
|
tokens.generated.css the baked CSS your production build ships
|
|
24
26
|
src/system/styles/
|
|
25
27
|
tokens.css your token vocabulary, hand-authored, never written
|
|
26
28
|
fonts.css font imports, rewritten when you Adopt
|
|
27
29
|
```
|
|
28
30
|
|
|
29
|
-
A saved theme carries the whole look by value: the colors and type
|
|
30
|
-
setting for every component. It depends on no other
|
|
31
|
-
anything else never breaks it.
|
|
31
|
+
A saved theme carries the whole look by value: the colors and type, a
|
|
32
|
+
setting for every component, and the sketch layer. It depends on no other
|
|
33
|
+
file, so deleting anything else never breaks it.
|
|
32
34
|
|
|
33
35
|
## What writes when
|
|
34
36
|
|
|
@@ -36,8 +38,10 @@ anything else never breaks it.
|
|
|
36
38
|
edits in the browser as you work and writes them to the `_working.json`
|
|
37
39
|
buffers when you save a component. When the Theme panel finds several dirty
|
|
38
40
|
components, **Save all** writes those buffers together.
|
|
39
|
-
- **Save** captures the buffers into the open theme's file
|
|
40
|
-
|
|
41
|
+
- **Save** captures the buffers into the open theme's file, along with the
|
|
42
|
+
sketch layer, which has no buffer of its own and lives only in the browser
|
|
43
|
+
until Save writes it. That file is the durable copy of your look; matching
|
|
44
|
+
buffers are then removed.
|
|
41
45
|
- **Load** clears the buffers and points `themes/_active.json` at the theme you
|
|
42
46
|
picked. Live reads fall through to that file. Nothing else changes, so trying
|
|
43
47
|
looks is free and ordinary switching changes only the pointer.
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
export const docContent: Record<string, string> = {
|
|
5
5
|
"01-overview": "# Overview\n\nLiveTokens is a design system for building Svelte microsites quickly. You\nstyle your site by editing tokens and components in a live editor. When it looks right, you save the theme and ship it.\n\n## How it works\n\n- The editor runs in your dev server, on top of your real pages. You style in\n context, not in a separate sandbox.\n- Every change updates a CSS variable, so the page repaints instantly. No\n reload, no build step.\n- Saving writes a small JSON file into your project. Shipping bakes your chosen\n theme into a plain CSS file that the build bundles.\n- The editor is dev-only. Production ships plain CSS variables and the\n components you used, nothing else.\n\n## What you can edit\n\n- **Tokens**: the design-system primitives, colour palettes, type, spacing,\n radius, shadow, and gradients, that apply across your whole site.\n- **Components**: the package ships about 25 editable components (Button,\n IconButton, Card, Dialog, Table, and more). You style components by changing\n the tokens assigned to each property.\n\n## Where to go next\n\n- **[Getting started](getting-started.md)**: scaffold a project and make your\n first edit.\n- **[Editing tokens](editing-tokens.md)**: a tour of the editor.\n- **[Sketch mode](sketch-mode.md)**: redraw the page by hand.\n- **[Themes](themes-workflow.md)**: save, switch, and ship.\n- **[Creating components](creating-components.md)**: make your own components\n editable.\n",
|
|
6
6
|
"creating-components": "# Creating components\n\nThe package ships about 25 editable components. When you need one it doesn't\nhave, you can make your own Svelte component editable, so anyone using the\neditor can re-point its colours, type, and spacing without touching code.\n\nThe simplest way is to ask Claude. The package bundles a Claude Code skill that\nknows the conventions, writes the files, and checks the result for you.\n\n## Install the skills\n\n```bash\nnpx @motion-proto/live-tokens setup-claude\n```\n\nThis copies the bundled skills into your project's `.claude/skills/`. Once\nthey're there, Claude Code picks them up automatically.\n\n## Ask for a component\n\nDescribe what you want in plain English. Phrases like these trigger the skill:\n\n- \"Add a Toggle component to live-tokens\"\n- \"Make this Svelte component editable in the live-tokens editor\"\n- \"Create a Stat component with a value and a label\"\n\nClaude asks any clarifying questions it needs (which variants, which states,\nwhich parts), then writes the component, registers it with the editor, and runs\nits verification checklist. When it finishes, open `/live-tokens/components` to see your new\ncomponent in the editor and confirm everything works.\n\n## What you get\n\n- A runtime component whose editable properties default to your theme tokens.\n- An editor entry that appears under **Custom** in the `/live-tokens/components` view.\n- The naming and wiring handled for you, so the component fits the system.\n\nAdvanced authors who want to write a component by hand can read the naming and\nstate-model conventions shipped in the package\n(`src/system/styles/CONVENTIONS.md` and the skill's own `SKILL.md`).\n",
|
|
7
|
-
"editing-tokens": "# Editing tokens\n\nA tour of the editor. The page behind it repaints on every change; saving\nwrites a theme file you can reload later.\n\nThe editor has four views:\n\n- **Tokens**: the design-system primitives (colour, type, spacing, and so on).\n They apply everywhere your site uses them.\n- **Color Wheel**: the harmony wheel, the palette curves, and the story your colours\n tell across a page.\n- **Components**: per-component editors. Re-Assign what tokens a component uses\n without changing the underlying system.\n- **
|
|
7
|
+
"editing-tokens": "# Editing tokens\n\nA tour of the editor. The page behind it repaints on every change; saving\nwrites a theme file you can reload later.\n\nThe editor has four views:\n\n- **Tokens**: the design-system primitives (colour, type, spacing, and so on).\n They apply everywhere your site uses them.\n- **Color Wheel**: the harmony wheel, the palette curves, and the story your colours\n tell across a page.\n- **Components**: per-component editors. Re-Assign what tokens a component uses\n without changing the underlying system.\n- **Sketchstyle**: an effect layer that redraws the page by hand. See\n [Sketch mode](sketch-mode.md).\n\nThis page covers **Tokens**. For components, see\n[Creating components](creating-components.md).\n\n## Palettes\n\nMost colour work happens here. Each palette (Brand, Accent, Neutral, Canvas,\nSuccess, Warning, Info, Danger, and a few more) has:\n\n- **Base colour.** Pick a hex; the palette derives an 11-step ramp (100 to 950)\n from it.\n- **Curves.** Three curves shape the ramp, in stack order: Hue, Saturation,\n Lightness. Drag the handles to bias it warmer or cooler, more or less\n saturated, darker or lighter. Hue drifts the ramp's temperature without\n moving contrast, because OKLCH hue rotation is close to lightness-preserving.\n It holds ±45 degrees; a bigger shift belongs on the base colour or the\n harmony axis.\n- **Overrides.** Lock a single step to a hand-picked hex when the curve doesn't\n land where you want.\n\nEditing a palette base ripples through every colour that depends on it, in real\ntime. Colours use OKLCH, so the ramp stays perceptually even across hues\nwithout muddy mid-tones.\n\n## Type\n\n- **Fonts.** Add sources from Google Fonts, Adobe (Typekit), a CSS URL, or an\n inline `@font-face`. The font loads in the page as soon as you add it.\n- **Stacks.** Named font cascades you reference by token, such as a display\n stack and a body stack.\n- **Sizes and weights.** A t-shirt scale (xs, sm, md, lg, xl, 2xl…) for size and\n a numeric scale (100 to 900) for weight.\n\n## Spacing, radius, shadow\n\nNumeric scales with a slider per step.\n\n- **Spacing**: the padding, gap, and margin scale.\n- **Radius**: none through full.\n- **Shadow**: colour, offset, blur, spread, and opacity per step, with stacked\n shadows supported.\n\nChange a step and every element using it repaints.\n\n## Overlays and gradients\n\n- **Overlays** are translucent tints layered over surfaces, like the subtle\n tint a card gets on hover. Set a colour and opacity per state.\n- **Gradients** are reusable gradient tokens with a stop list and direction, for\n hero panels and accent backgrounds.\n\n## Columns\n\nThe page-grid overlay. Set column count, gutter, and outer margin, and toggle\nthe visual guide with `Cmd/Ctrl+G`. Pages built on the column system reflow\nlive.\n\n## Saving\n\nThe editor saves to your browser continuously, so work survives a reload\nmid-edit. Writing a file is a separate step: the **Theme** panel at the foot of\nthe sidebar has **Save**, **Save As**, and **Load**, and each theme is one JSON\nfile under `src/live-tokens/data/themes/`.\n\nThe header gives you undo/redo (`Cmd/Ctrl+Z`, `Cmd/Ctrl+Shift+Z`). You can keep\nmany themes side by side; one is open at a time, and only **Adopt** publishes\none. See [Themes](themes-workflow.md) for the full lifecycle.\n",
|
|
8
8
|
"getting-started": "# Getting started\n\nScaffold a live token site in a moments. You need Node 20 or later, a\npackage manager (npm, pnpm, or yarn), and a browser. Open claude code in your repo and start building.\n\n## Scaffold a new app\n\n```bash\nnpm create @motion-proto/live-tokens@latest my-app\ncd my-app\nnpm install\nnpm run dev\n```\n\nOpen the URL Vite prints (usually `http://localhost:5173`). You get a\none-page Svelte + Vite app that depends on the published package, with the\neditor wired up and the full component set ready to import.\n\n`npx @motion-proto/live-tokens create my-app` runs the same scaffold without\nthe initialiser package.\n\n### What the scaffold gives you\n\nEvery editable file lives under `src/` and is committed, so `npm install` and\nversion upgrades never touch your styles. The package code stays in\n`node_modules`.\n\n| Path | What it is |\n|------|------------|\n| `src/pages/Home.svelte` | The starter page. Replace it with your own content. |\n| `src/App.svelte` | Your routes. `<LiveTokensRouter>` adds dev-only routes under a reserved `/live-tokens/*` namespace: `/live-tokens/editor`, `/live-tokens/components`, and `/live-tokens/docs`. |\n| `src/system/styles/tokens.css` | Your base token vocabulary, hand-authored. |\n| `src/styles/site.css` | Themed page typography, yours to edit. |\n\n## Your first edit\n\n1. Run `npm run dev` and open the home page.\n2. Click **Open Token Editor**, or visit `/live-tokens/editor`. The editor opens beside\n the page.\n3. Open **Palettes**, pick **Brand**, and change the base hex. The page\n repaints as you type.\n4. In the **Theme** panel at the foot of the sidebar, choose **Save As**. Your\n theme appears as JSON under `src/live-tokens/data/themes/`.\n5. Reload. The editor reopens on your theme, so the page returns as you left\n it.\n\n## What you just changed\n\nEvery edit sets a CSS custom property on `:root`. Your components read those\nproperties through `var(--...)`. There is no token build step and no\npreprocessor rewriting your code: the page renders against plain CSS variables\nthe editor swaps live.\n\nTo ship, click **Adopt** in the Theme panel. That saves the open theme and bakes\nit into `src/live-tokens/data/tokens.generated.css`, which your build bundles\nalongside `tokens.css`. Adopt is the only action that changes what your site\nships, so try any look you like first. The editor itself never reaches\nproduction.\n\nAlready have a Svelte 5 + Vite app? The\n[README](https://github.com/motionproto/live-tokens#readme) covers installing\ninto an existing project.\n\n## Where to go next\n\n- **[Editing tokens](editing-tokens.md)**: a tour of the editor.\n- **[Themes](themes-workflow.md)**: save, switch, and ship.\n- **[Creating components](creating-components.md)**: make your own component\n editable.\n",
|
|
9
9
|
"light-and-dark": "# Light and dark\n\nSome things on a page cannot be written as a token. A wordmark drawn in white\ndisappears on a pale theme. Ink that multiplies onto paper vanishes on a dark\none. A photograph behind a headline is dark no matter what the palette says.\n\nEach of those needs the same fact first: which way does the surface behind this\nthing lean? One attribute carries it.\n\n## The attribute\n\n`data-backdrop` is either `light` or `dark`, and it does two things at once: it\nselects, so a rule can key on it, and it sets `color-scheme`, so every\n`light-dark()` under it resolves the half that reads.\n\n```css\n.title {\n color: light-dark(var(--color-black), var(--color-white));\n}\n```\n\nThat line is right on both sides of the theme, and it is right inside a dark\nband on a pale page, because the nearest `color-scheme` wins.\n\n## Stating it\n\nPut it in the markup when the surface knows its own tone — a hero over a\nphotograph, a plate that stays pale in every theme:\n\n```svelte\n<div class=\"hero-panel\" data-backdrop=\"dark\">\n```\n\nA stated tone beats any measurement, and it inherits, so everything inside the\npanel resolves against it.\n\n## Measuring it\n\nWhere the tone is a property of the theme rather than of the markup, let it be\nmeasured:\n\n```svelte\n<script>\n import { backdrop } from '@motion-proto/live-tokens/backdrop';\n</script>\n\n<section use:backdrop>\n```\n\nThe action reads whatever actually paints behind the element — the nearest\nancestor with an opaque fill, averaged across its gradient stops, falling back\nto the theme's `--page-bg` — and stamps the answer. It re-reads when the theme\nchanges, which the editor does by rewriting custom properties with no reload,\nso the stamp follows a live edit.\n\nThe page itself is stamped for you: the build bakes the production theme's\npolarity into `tokens.generated.css`, so the first paint is already right, and\n`syncDocumentBackdrop()` keeps `<html>` current as themes switch.\n\n```ts\nimport { syncDocumentBackdrop } from '@motion-proto/live-tokens/backdrop';\n\nsyncDocumentBackdrop();\n```\n\n## Reading it from JavaScript\n\nAnything that paints outside CSS — a canvas, a WebGL uniform, an `<img>` that\ncomes in two versions — asks the same question through the same module:\n\n```ts\nimport { isLightBackdrop, watchBackdrop, cssColorToHex } from '@motion-proto/live-tokens/backdrop';\n\nconst stop = watchBackdrop(logoEl, {\n stamp: false,\n onChange: (polarity) => (src = polarity === 'light' ? darkMark : lightMark),\n});\n```\n\n`isLightBackdrop(el)` answers once. `watchBackdrop` keeps answering and returns\na stop function. `cssColorToHex` resolves any CSS colour — including the\n`oklch()` a token holds — to a hex a non-CSS consumer can take.\n\n## What it does not do\n\nPolarity is a property of a surface, not of a component, so nothing is stamped\nfor you below `<html>`: a section that needs an answer either states one or asks\nfor one. And a measurement reads the paint at the moment it runs — an element\nthat scrolls from a pale band onto a dark one keeps the answer it was given.\nState the tone on each band instead.\n",
|
|
10
|
-
"sketch-mode": "# Sketch mode\n\nSketch mode redraws your whole page as if it had been drawn by hand. Every\ncomponent keeps its own colours, spacing and corners; what changes is the line\nthey are drawn with.\n\nIt is an effect layer, not a set of token values. It
|
|
11
|
-
"themes-workflow": "# Themes\n\nSave your work, switch between looks, and ship one to production.\n\n## The Theme panel\n\nThe **Theme** panel at the foot of the editor sidebar holds the whole look:\ncolors, type,
|
|
12
|
-
"where-themes-live": "# Where themes live\n\nEverything the editor writes is plain JSON and CSS inside your project. There\nis no database and no hidden state: the files are the storage, and git is the\nhistory.\n\n## The data tree\n\n```\nsrc/live-tokens/data/\n themes/\n _active.json names the theme the editor has open\n _production.json names the theme your site ships\n default.json Motion Proto, the built-in look, rewritten at boot\n my-brand.json a saved theme: the whole look in one file\n colors-and-type/\n _working.json unsaved colors and type edits\n component-configs/\n button/\n default.json Button's shipped settings, derived at boot\n _working.json unsaved Button edits\n my-button.json a preset you saved from the Button editor\n tokens.generated.css the baked CSS your production build ships\nsrc/system/styles/\n tokens.css your token vocabulary, hand-authored, never written\n fonts.css font imports, rewritten when you Adopt\n```\n\nA saved theme carries the whole look by value: the colors and type
|
|
10
|
+
"sketch-mode": "# Sketch mode\n\nSketch mode redraws your whole page as if it had been drawn by hand. Every\ncomponent keeps its own colours, spacing and corners; what changes is the line\nthey are drawn with.\n\nIt is an effect layer, not a set of token values. It never touches a token\nitself, so turning it off returns every component to exactly what its tokens\nalready say. A production build never carries the drawing.\n\nOpen the **Sketchstyle** view in the editor and switch **Sketch mode** on. The effect\napplies to the page behind the editor as well as to the preview, so what you see\nin context is what it does.\n\n## What it draws\n\nEach component's fill and outline are repainted from the tokens that component\nalready owns. The real background and border are hidden behind them, then both\nare pushed around one shared field of noise. Because every component samples the\nsame field, the whole page reads as one drawing rather than as a set of\nseparately wobbled boxes.\n\n## The sketchstyles\n\nSeven looks ship with the package, and each is a complete set of dials rather\nthan just a name:\n\n- **Pencil.** Two graphite passes on their own seeds, so the outline disagrees\n with itself the way a hand coming back round does.\n- **Marker.** A broad translucent nib gone round twice on the same line, so the\n overlap darkens and the ink pools where it slows.\n- **Whiteboard.** The fattest nib on glass, with a mask that streaks the fill\n like a half-wiped board.\n- **Hatched.** An etching. The fill is angled shading and the outline a single\n hard-edged scratch.\n- **Dashed.** A drafting outline: one slow drift along the ruler, broken into\n strokes. The clean pole.\n- **Napkin.** Ballpoint in a hurry. Everything loose at once.\n- **Dry marker.** Ink that ran out. One scratchy pass over a mostly eaten fill.\n\nPick one, then move whatever you like. **Save as sketchstyle…** keeps your\ndials under a name of your own, alongside the shipped seven, as a file under\n`src/live-tokens/data/sketch-styles/`. That is a different gesture from\nsaving a theme; see \"Where the settings live\" below.\n\n## The dials\n\n- **Border.** How far the outline travels and how long its wave is, then its\n width, ink, pressure and pooling. A second pass either copies the first line a\n few pixels off or runs it through the pen again on its own seed.\n- **Fill.** Solid or hatched, how far the fill's edge travels, and how far each\n instance is offset, rotated and scaled from its neighbours. **Ink coverage**\n thins the fill with a field of blotches: set their size and how many levels of\n detail, then work the field as a levels control. The field always runs black\n to white whatever the noise underneath. Steps flattens it into tones, and\n Output squeezes the whole of it into the range the ink covers, from how pale\n it gets at its thinnest to how dense at its fullest. Menus and tooltips are\n drawn solid whatever the coverage dials say: they float over the page, and a\n fill worn through in patches lets the page show through them.\n- **Shape.** **Corner spread** rounds each corner by its own share of the dial,\n so no two match. **Corner travel** leans the drawn box into a quadrilateral\n with no two sides parallel. This is the dial that stops a component reading as\n a rectangle.\n- **Icons and SVG.** Glyph travel and wavelength on their own scale. A glyph is\n all curves already, so it needs more travel than a card's long straight edge\n before the wobble reads at all.\n- **Noise.** The shared field itself: its wavelength, how many layers of detail\n sit on it, and the shape of its wave. A square wave sends nearly every edge to\n full travel, which is what makes the effect stronger rather than bigger.\n\n## Where the settings live\n\nThe sketch layer is part of the theme, the same way colors and type are.\n**Save** in the Theme panel folds your dials into the open theme; **Load**\napplies whatever a theme carries, and turns the effect off for a theme that\ncarries none.\n\nUntil you save, the dials sit in your browser only. The Theme panel calls\nthat state off the theme, the same word it uses for an unsaved component\nchange. The built-in **Motion Proto** theme is read-only, so Save\nis disabled there; use **Save As** to fold the dials into a theme of your\nown.\n\n**Save as sketchstyle…** in the **Sketchstyle** view is a different gesture. It\nwrites a named sketchstyle to `src/live-tokens/data/sketch-styles/`, a look you\ncan pick from any theme. It never touches the open theme, and it never marks\nthe look off the theme.\n\nSketch mode is a tool for looking at the page, not a layer the page can ship.\nThe theme records the dials, but nothing bakes them: `tokens.generated.css`\nnever sees them, and a production build has no sketch layer in it at all.\n\n## Drawing your own elements\n\nThe layer draws a fixed set of parts: the shipped components, and four classes\nit reserves for you. Nothing else is touched, so a page element or a\nconsumer-authored component is left crisp until it carries one of them.\n\n| Class | For |\n|---------------------|-----------------------------------------------------------|\n| `sketch-surface` | A box. The default treatment. |\n| `sketch-container` | A large box. Tilts less, so the type inside stays readable. |\n| `sketch-chip` | A small box. Finer fill mask, more rotation, less travel. |\n| `sketch-rule` | A line rather than a box. No rotation, no rounded ends. |\n\nPick by size, not by kind: a card and a modal both take `sketch-container`, a\nbadge and a pill both take `sketch-chip`.\n\nThe class opts the element in; it names no colours, so the element states its\nown. `--sketch-fill`, `--sketch-stroke`, `--sketch-hatch-color`,\n`--sketch-radius` and `--sketch-shadow` name the fill, the outline, the hatching\nink, the corners and the shadow for one element and everything inside it. The\nlayer blanks the real background and border, so an element whose fill matters\nunder Sketch mode has to name it here as well as paint it.\n\nThe layer also paints on the element's `::before` and `::after`, forces its\n`overflow` visible, and gives it a stacking context of its own. Keep the class\noff anything that owns a pseudo-element, clips its content, or is positioned\nabsolutely, and put it on a wrapper instead.\n\n```css\n.my-callout {\n background: var(--surface-brand-lowest);\n border: var(--border-width-1) solid var(--border-brand);\n border-radius: var(--radius-xl);\n\n --sketch-fill: var(--surface-brand-lowest);\n --sketch-stroke: var(--border-brand);\n --sketch-radius: var(--radius-xl);\n}\n```\n\nA gradient is a valid fill: the shorthand's last layer takes a colour or an\nimage, so `--sketch-fill` accepts either. States work the same way, since\nnothing is competing with you for the value:\n\n```css\n.my-callout:hover { --sketch-stroke: var(--border-brand-strong); }\n```\n\n## Images inside a drawn part\n\nA drawn part's `overflow` is forced visible, because the fill and outline are\npainted on pseudo-elements that travel past the box and would otherwise be cut\noff at its edge. A background that bleeds is the effect working. An image that\nbleeds is not: it keeps its square corners while the card around it turns.\n\nMedia that runs to a part's edge therefore has to carry that part's corners\nitself. `--sketch-radius` is the radius the layer drew, and it inherits, so a\nchild can read it and fall back to its own value when Sketch mode is off:\n\n```css\n.cover {\n overflow: hidden;\n border-top-left-radius: var(--sketch-radius, var(--card-default-radius));\n border-top-right-radius: var(--sketch-radius, var(--card-default-radius));\n}\n```\n\nCorner spread is per-corner and per-instance, so at high spread the crop is the\nmean rather than an exact trace of the drawn edge.\n\nA rule made from a `border` is not a box and cannot be displaced. Make it an\nelement, give it `sketch-rule`, and name its ink:\n\n```html\n<div class=\"rule sketch-rule\"></div>\n```\n```css\n.rule {\n height: var(--border-width-2);\n background: var(--border-brand);\n --sketch-fill: var(--border-brand);\n}\n```\n\nIcons and inline SVG take the wobble directly, since a glyph has no box to\nredraw. Body type is left alone: an icon is a shape and survives a wobble, a\nparagraph is not.\n\n`--sketch-icon-off` names what a subtree's glyphs are drawn with instead. It\ninherits, so one declaration covers everything under it, and it takes the ink\nmask off as well as the wobble:\n\n```css\n/* Crisp. Chrome, a logo, anything that has to stay exact. */\n.app-bar { --sketch-icon-off: none; }\n\n/* Drawn back rather than off, at a third of the travel. Small artwork, and\n type set as an SVG, which the layer reads as one large glyph. */\n.wordmark { --sketch-icon-off: var(--sketch-icon-soft); }\n```\n\nThe **Blotch size** dial under Icons and SVG is a share of the glyph rather than\na px size, because no px size is right for both a 16px icon and a page-wide\ndrawing. At 100% every glyph gets one period of the field across it whatever its\nsize. Below that the field repeats inside the glyph and the blotches get finer.\nAbove it a glyph reads part of one blotch, so the mask thins the whole glyph\nunevenly instead of breaking it up. The fill's blotches stay in px, since a\ncomponent does have a size to state one against.\n",
|
|
11
|
+
"themes-workflow": "# Themes\n\nSave your work, switch between looks, and ship one to production.\n\n## The Theme panel\n\nThe **Theme** panel at the foot of the editor sidebar holds the whole look:\ncolors, type, a setting for every component, and the sketch layer, in one\nfile. It carries the name the look ships under, whether production is running\nit, and **Adopt**. Three parts sit under it, each a read-out rather than a\nfile to manage.\n\n- **Colors & Type** holds the design tokens. Components read those tokens to\n define their appearance. It names the two faces the page is showing.\n- **Components** counts how many components have an unsaved edit that has not\n been saved into the theme, and opens the component editors.\n- **Sketchstyle** names the look the theme's sketch layer carries: its label, or\n off the theme when what's on screen no longer matches what was saved, or\n none when the theme carries no sketch layer. It travels with the theme\n like colors and type do, but never reaches a production build.\n\nA theme holds its own copy of every part, so one theme can never break another.\n\n## How themes work\n\nA theme is a document, and the editor works the way any editor does.\n\n- **A theme** is a named JSON file in `src/live-tokens/data/themes/`. It carries\n the whole look: the colors and type, a setting for every component, and the\n sketch layer.\n- **The open theme** is the one the editor is working on, named in\n `themes/_active.json`. One at a time.\n- **Your unsaved edits** are what the page shows right now. The editor keeps\n them in your browser as you work, writing most parts to a buffer,\n `_working.json`, one slot each; the sketch layer has no buffer and stays\n live in the browser until you save. **Save** captures all of it into the\n open theme.\n- **The production theme** is the one your site ships, named in\n `themes/_production.json`. **Adopt** changes it; saving a preset in the Theme\n Picker performs that Adopt for you.\n\nAbsence is the answer for anything untouched: a buffer exists only where the\nlive look diverges from the active theme, so a newly opened theme has none.\n\n## Fonts\n\nType is part of the look, so it saves, loads and ships with the theme rather\nthan on its own. Four named stacks carry it:\n\n| Stack | Used by |\n|---|---|\n| `--font-display` | headings |\n| `--font-sans` | body text and most UI |\n| `--font-serif` | anywhere you ask for it |\n| `--font-mono` | code |\n\nEach stack is a family followed by its fallbacks, so a page still reads while a\nweb font loads, and still reads if it never does. **Project fonts**, in the\nColors and type editor, is where families come from: type a Google Fonts family\nname and the editor checks it, or paste a fonts URL, an embed tag, or your own\n`@font-face` rules. Removing a family puts the stack back on its fallbacks.\n\nYou can also set both faces at once from the command line:\n\n```bash\nnpx live-tokens set-fonts fonts.json\n```\n\nwith a brief naming the families:\n\n```json\n{ \"display\": \"Fraunces\", \"body\": \"Nunito Sans\" }\n```\n\nIt checks each family against Google Fonts, works out the weights that family\nactually has, and binds it to its stack. Like every other edit, the result lands\nin the buffer, so **Save** keeps it. In Claude Code, asking for a font pairing in\nplain English runs the same command.\n\nA font is only requested by the browser once something on the page uses it, so\ncarrying a family you no longer reference costs nothing at load. Adopting is\nwhat writes the font imports your site ships, into `fonts.css`.\n\n## Saving\n\nIn the Theme panel:\n\n- **Save** captures the look on screen into the open theme. Your colors and type\n go in as part of it, so there is nothing to save first.\n- **Save As** names a new theme. Use it for your first save and for forking.\n\nComponent editors keep their own unsaved state. If one or more components are\nwaiting when you use **Save**, **Save As**, or **Adopt**, the Theme panel offers\nto save all of them before continuing. You can accept once instead of visiting\neach component, or cancel to review them individually. A component editor's\n**Save As** creates a reusable component preset.\n\nNames are tidied to lowercase with hyphens, so \"My Brand!\" becomes `my-brand`,\nand a leading underscore is dropped: those names are reserved for the buffer.\n**Motion Proto** is the built-in theme and is read-only. You can always return\nto it, and the editor never overwrites it, so start your own with **Save As**.\n\n## Switching\n\n**Load**—or clicking the active theme's name—opens the Theme Picker. Picking a\ntheme shows it on the page as a preview with nothing written to disk, sketch\nlayer included, so you can try each look and compare. **Save** in that window\nopens and adopts the previewed theme in one step: the active pointer changes,\nthe buffers clear, the editor works on it, and production ships it. **Cancel**\nreturns you to where you were, unsaved sketch dials included. Previewing alone\nnever changes what your site ships.\n\n**Colors and type only. Keep my shapes.** narrows the load to the palette and\nthe fonts: your component settings and your sketch layer stay as they are, and\nthe theme you have open stays open. Saved colors and type files are listed\nthere too, marked *colors & type*, and picking one is always that narrower\nload.\n\n## Shipping\n\n**Adopt**, in the Theme panel, is the \"ship it\" step. It saves the open theme,\nthen bakes the colors and type plus every component the theme carries into\n`src/live-tokens/data/tokens.generated.css`, which your build bundles alongside\n`tokens.css`. The sketch layer is the one part of the theme Adopt never bakes:\nit stays a preview. Fonts regenerate to match. The line under the theme name\nsays whether production is running this theme.\n\nProduction is one saved theme, so nothing else publishes. Trying a look, moving\na token, saving a theme: all of it leaves the generated CSS alone until you\nAdopt. A component editor's Adopt runs the same save-then-bake step, because a\ncomponent never ships alone. Adopting while Motion Proto is open saves your look\nas a theme of your own first, since the built-in one is read-only.\n\nProduction builds (`npm run build`) ship only that plain CSS and your\ncomponents. No editor, no JSON loading, no runtime indirection.\n\n## Keeping your work safe\n\nEverything under `src/live-tokens/data/` is plain JSON, so commit it. Themes show\nup as readable diffs you can review per branch, and the buffer shows up as the\nwork you have not saved into a theme yet. Nothing is backed up anywhere else:\ngit is your safety net. To experiment freely, **Save As** a new name first, then\nedit.\n\n## Where to go next\n\n- **[Where themes live](where-themes-live.md)**: the files behind all of this,\n and what writes each one.\n- **[Creating components](creating-components.md)**: make your own components\n editable in the same editor.\n",
|
|
12
|
+
"where-themes-live": "# Where themes live\n\nEverything the editor writes is plain JSON and CSS inside your project. There\nis no database and no hidden state: the files are the storage, and git is the\nhistory.\n\n## The data tree\n\n```\nsrc/live-tokens/data/\n themes/\n _active.json names the theme the editor has open\n _production.json names the theme your site ships\n default.json Motion Proto, the built-in look, rewritten at boot\n my-brand.json a saved theme: the whole look in one file\n colors-and-type/\n _working.json unsaved colors and type edits\n component-configs/\n button/\n default.json Button's shipped settings, derived at boot\n _working.json unsaved Button edits\n my-button.json a preset you saved from the Button editor\n sketch-styles/\n my-look.json a sketchstyle saved from the Sketchstyle view\n tokens.generated.css the baked CSS your production build ships\nsrc/system/styles/\n tokens.css your token vocabulary, hand-authored, never written\n fonts.css font imports, rewritten when you Adopt\n```\n\nA saved theme carries the whole look by value: the colors and type, a\nsetting for every component, and the sketch layer. It depends on no other\nfile, so deleting anything else never breaks it.\n\n## What writes when\n\n- **Editing** changes the page through CSS variables. The editor keeps your\n edits in the browser as you work and writes them to the `_working.json`\n buffers when you save a component. When the Theme panel finds several dirty\n components, **Save all** writes those buffers together.\n- **Save** captures the buffers into the open theme's file, along with the\n sketch layer, which has no buffer of its own and lives only in the browser\n until Save writes it. That file is the durable copy of your look; matching\n buffers are then removed.\n- **Load** clears the buffers and points `themes/_active.json` at the theme you\n picked. Live reads fall through to that file. Nothing else changes, so trying\n looks is free and ordinary switching changes only the pointer.\n- **Adopt** points `themes/_production.json` at the open theme, bakes it into\n `tokens.generated.css`, and rewrites `fonts.css` to match. It is the only\n action that changes what your site ships.\n\nThe `default.json` files are the shipped baseline. The editor derives them at\nboot and refreshes them when the package updates; it never saves your work\nover them.\n\nProjects upgraded from 0.48 may initially contain working files copied from the\nactive theme. On the first dev-server boot, exact copies are removed\nautomatically. Any file that differs is kept as unsaved work, so no migration\ncommand is required.\n\n## What to commit\n\nAll of it. The data tree is designed to live in git: themes diff readably, the\ntwo pointers say what is open and what ships, and a `_working.json` in a diff\nis exactly the work you have not yet saved into a theme. Nothing is backed up\nanywhere else.\n\n## Where to go next\n\n- **[Themes](themes-workflow.md)**: the workflow built on these files: saving,\n loading, and shipping.\n",
|
|
13
13
|
};
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
let isColors = $derived(isDev && colorsEnabled && $route === colorsPath);
|
|
103
103
|
let isDocs = $derived(isDev && docsEnabled && $route === docsPath);
|
|
104
104
|
|
|
105
|
-
// A
|
|
105
|
+
// A sketchstyle paints the page and never the editor's own chrome. Which
|
|
106
106
|
// routes are chrome is this component's knowledge alone, since a consumer can
|
|
107
107
|
// relocate them, so it hands the sketch layer the root to paint.
|
|
108
108
|
$effect(() => {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
let componentsDisabled = $derived($parentRoute === DEFAULT_COMPONENTS_PATH);
|
|
19
19
|
let colorsDisabled = $derived($parentRoute === DEFAULT_COLORS_PATH);
|
|
20
20
|
|
|
21
|
-
// Editing flow order: Tokens → Components →
|
|
21
|
+
// Editing flow order: Tokens → Components → Sketchstyle → Color Wheel. The condensed
|
|
22
22
|
// rail cycles through these; a view is skipped while it's disabled (already
|
|
23
23
|
// on that page) so the cycle never lands on a dead view.
|
|
24
24
|
const CYCLE: readonly EditorView[] = ['tokens', 'components', 'sketch', 'colors'];
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
tokens: 'Tokens',
|
|
33
33
|
colors: 'Color Wheel',
|
|
34
34
|
components: 'Components',
|
|
35
|
-
sketch: '
|
|
35
|
+
sketch: 'Sketchstyle',
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
function set(v: EditorView) {
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
onclick={() => set('sketch')}
|
|
102
102
|
>
|
|
103
103
|
<span class="radio" aria-hidden="true"></span>
|
|
104
|
-
<span>
|
|
104
|
+
<span>Sketchstyle</span>
|
|
105
105
|
</button>
|
|
106
106
|
<button
|
|
107
107
|
type="button"
|
|
@@ -136,17 +136,34 @@
|
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
/** Fallbacks offered by "+ add fallback", best match for the variable first.
|
|
140
|
+
* Every stack already ships with its preferred generic *and* its preferred
|
|
141
|
+
* preset, so both leading candidates are usually taken; the ladder gives the
|
|
142
|
+
* button something unused to reach for. */
|
|
143
|
+
function addCandidates(variable: FontStackVariable): FontStackSlot[] {
|
|
141
144
|
const generic: GenericFamily =
|
|
142
145
|
variable === '--font-mono' ? 'monospace' : variable === '--font-serif' ? 'serif' : 'sans-serif';
|
|
146
|
+
const preset: SystemCascadePreset =
|
|
147
|
+
variable === '--font-mono' ? 'system-ui-mono' : variable === '--font-serif' ? 'system-ui-serif' : 'system-ui-sans';
|
|
148
|
+
return [
|
|
149
|
+
{ kind: 'generic', value: generic },
|
|
150
|
+
{ kind: 'system', preset },
|
|
151
|
+
...SYSTEM_PRESETS.map((p) => ({ kind: 'system' as const, preset: p })),
|
|
152
|
+
...GENERIC_VALUES.map((g) => ({ kind: 'generic' as const, value: g })),
|
|
153
|
+
];
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** A slot duplicated within a stack collides with itself in the keyed each,
|
|
157
|
+
* so only one the stack doesn't already hold may be added. */
|
|
158
|
+
function nextAddableSlot(variable: FontStackVariable): FontStackSlot | null {
|
|
159
|
+
const stack = stacks.find((s) => s.variable === variable);
|
|
143
160
|
const existing = new Set((stack?.slots ?? []).map(slotKey));
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
161
|
+
return addCandidates(variable).find((c) => !existing.has(slotKey(c))) ?? null;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function addSlot(variable: FontStackVariable) {
|
|
165
|
+
const newSlot = nextAddableSlot(variable);
|
|
166
|
+
if (!newSlot) return;
|
|
150
167
|
updateStack(variable, (slots) => {
|
|
151
168
|
// Insert above the terminal fallback (always the last slot) so the
|
|
152
169
|
// terminal stays at the bottom.
|
|
@@ -156,6 +173,20 @@
|
|
|
156
173
|
});
|
|
157
174
|
}
|
|
158
175
|
|
|
176
|
+
/** Two identical slots in one stack would collide in the keyed each and throw
|
|
177
|
+
* `each_key_duplicate`, taking the whole tab down — and the bad stack is
|
|
178
|
+
* already persisted by then, so the crash repeats on every reload. Suffix
|
|
179
|
+
* repeats so such a stack renders and can be edited back into shape. */
|
|
180
|
+
function keyedSlots(slots: FontStackSlot[]): { slot: FontStackSlot; key: string }[] {
|
|
181
|
+
const seen = new Map<string, number>();
|
|
182
|
+
return slots.map((slot) => {
|
|
183
|
+
const base = slotKey(slot);
|
|
184
|
+
const n = seen.get(base) ?? 0;
|
|
185
|
+
seen.set(base, n + 1);
|
|
186
|
+
return { slot, key: n === 0 ? base : `${base}#${n}` };
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
159
190
|
/* Drag UX: the source row lifts (opacity, shadow); a white insertion bar
|
|
160
191
|
sits in the gap between rows at the projected drop position. The array
|
|
161
192
|
is only mutated on drop. animate:flip then slides every row to its new
|
|
@@ -232,7 +263,7 @@
|
|
|
232
263
|
<span class="stack-variable">{variableLabel(stack.variable)}</span>
|
|
233
264
|
</div>
|
|
234
265
|
<div class="font-stack-list">
|
|
235
|
-
{#each stack.slots as slot, i (
|
|
266
|
+
{#each keyedSlots(stack.slots) as { slot, key }, i (key)}
|
|
236
267
|
{@const isTerminal = i === stack.slots.length - 1}
|
|
237
268
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
238
269
|
<div
|
|
@@ -308,7 +339,13 @@
|
|
|
308
339
|
</div>
|
|
309
340
|
{/each}
|
|
310
341
|
</div>
|
|
311
|
-
<button
|
|
342
|
+
<button
|
|
343
|
+
type="button"
|
|
344
|
+
class="add-fallback"
|
|
345
|
+
disabled={nextAddableSlot(stack.variable) === null}
|
|
346
|
+
title={nextAddableSlot(stack.variable) === null ? 'Every system and generic fallback is already in this stack' : undefined}
|
|
347
|
+
onclick={() => addSlot(stack.variable)}
|
|
348
|
+
>
|
|
312
349
|
+ add fallback
|
|
313
350
|
</button>
|
|
314
351
|
</div>
|
|
@@ -493,8 +530,9 @@
|
|
|
493
530
|
border-radius: var(--ui-radius-sm);
|
|
494
531
|
cursor: pointer;
|
|
495
532
|
}
|
|
496
|
-
.add-fallback:hover {
|
|
533
|
+
.add-fallback:hover:not(:disabled) {
|
|
497
534
|
color: var(--ui-text-primary);
|
|
498
535
|
border-color: var(--ui-border);
|
|
499
536
|
}
|
|
537
|
+
.add-fallback:disabled { opacity: 0.35; cursor: not-allowed; }
|
|
500
538
|
</style>
|
|
@@ -118,6 +118,12 @@
|
|
|
118
118
|
nameError = 'Enter a family name';
|
|
119
119
|
return;
|
|
120
120
|
}
|
|
121
|
+
// Pasting the whole embed snippet here would otherwise be sent to Google as
|
|
122
|
+
// a family name, and the 400 comes back as an opaque CORS failure.
|
|
123
|
+
if (extractFontsUrl(nameInput) || /@font-face/i.test(nameInput)) {
|
|
124
|
+
nameError = 'That looks like an embed — use Paste instead of a family name';
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
121
127
|
nameDiscovering = true;
|
|
122
128
|
try {
|
|
123
129
|
nameResolved = await resolveGoogleFont(nameInput, (url) => fetch(url));
|