@motion-proto/live-tokens 0.7.1 → 0.9.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-add-component/SKILL.md +488 -0
- package/README.md +34 -0
- package/dist-plugin/index.cjs +707 -90
- package/dist-plugin/index.d.cts +1 -0
- package/dist-plugin/index.d.ts +1 -0
- package/dist-plugin/index.js +707 -90
- package/package.json +6 -2
- package/src/app/site.css +1 -1
- package/src/editor/component-editor/CollapsibleSectionEditor.svelte +34 -27
- package/src/editor/component-editor/DialogEditor.svelte +4 -4
- package/src/editor/component-editor/NotificationEditor.svelte +3 -1
- package/src/editor/component-editor/SectionDividerEditor.svelte +439 -112
- package/src/editor/component-editor/StandardButtonsEditor.svelte +13 -1
- package/src/editor/component-editor/editors.d.ts +10 -0
- package/src/editor/component-editor/index.ts +16 -1
- package/src/editor/component-editor/registry.ts +103 -26
- package/src/editor/component-editor/scaffolding/AngleDial.svelte +52 -13
- package/src/editor/component-editor/scaffolding/ComponentFileManager.svelte +10 -11
- package/src/editor/component-editor/scaffolding/ComponentsTab.svelte +2 -2
- package/src/editor/component-editor/scaffolding/LinkedBlock.svelte +0 -1
- package/src/editor/component-editor/scaffolding/RadialShapePad.svelte +483 -0
- package/src/editor/component-editor/scaffolding/ShadowBackdrop.svelte +15 -2
- package/src/editor/component-editor/scaffolding/StateBlock.svelte +103 -15
- package/src/editor/component-editor/scaffolding/TokenLayout.svelte +9 -6
- package/src/editor/component-editor/scaffolding/TypeEditor.svelte +13 -1
- package/src/editor/component-editor/scaffolding/VariantGroup.svelte +239 -25
- package/src/editor/component-editor/scaffolding/buildTypeGroupTokens.ts +1 -0
- package/src/editor/component-editor/scaffolding/componentSources.ts +3 -3
- package/src/editor/component-editor/scaffolding/defaultSections.ts +15 -10
- package/src/editor/component-editor/scaffolding/types.ts +11 -0
- package/src/editor/core/components/componentConfigKeys.ts +22 -3
- package/src/editor/core/components/componentConfigService.ts +2 -2
- package/src/editor/core/components/componentPersist.ts +7 -5
- package/src/editor/core/manifests/manifestService.ts +58 -3
- package/src/editor/core/palettes/familySwap.ts +99 -0
- package/src/editor/core/palettes/paletteDerivation.ts +69 -0
- package/src/editor/core/palettes/tokenRegistry.ts +4 -1
- package/src/editor/core/store/editorStore.ts +206 -12
- package/src/editor/core/store/editorTypes.ts +55 -12
- package/src/editor/core/store/gradientSource.ts +192 -0
- package/src/editor/core/themes/migrations/2026-05-19-collapsiblesection-drop-frame-surface.ts +28 -0
- package/src/editor/core/themes/migrations/2026-05-19-sectiondivider-rich-gradient.ts +35 -0
- package/src/editor/core/themes/migrations/2026-05-20-sectiondivider-slim-variants.ts +82 -0
- package/src/editor/core/themes/migrations/2026-05-21-sectiondivider-spacing-to-padding.ts +24 -0
- package/src/editor/core/themes/migrations/2026-05-22-sectiondivider-intrinsics-to-css.ts +81 -0
- package/src/editor/core/themes/migrations/index.ts +10 -0
- package/src/editor/core/themes/slices/components.ts +27 -4
- package/src/editor/core/themes/slices/gradients.ts +88 -13
- package/src/editor/core/themes/themeInit.ts +2 -2
- package/src/editor/core/themes/themeTypes.ts +56 -1
- package/src/editor/index.ts +10 -1
- package/src/editor/overlay/ColumnsOverlay.svelte +0 -1
- package/src/editor/overlay/LiveEditorOverlay.svelte +1 -4
- package/src/editor/pages/ComponentEditorPage.svelte +53 -3
- package/src/editor/pages/EditorShell.svelte +53 -3
- package/src/editor/styles/ui-editor.css +1 -0
- package/src/editor/styles/ui-form-controls.css +19 -20
- package/src/editor/ui/BezierCurveEditor.svelte +114 -63
- package/src/editor/ui/EditorViewSwitcher.svelte +0 -1
- package/src/editor/ui/FileLoadList.svelte +22 -5
- package/src/editor/ui/FontStackEditor.svelte +214 -76
- package/src/editor/ui/GradientEditor.svelte +435 -215
- package/src/editor/ui/GradientStopPicker.svelte +11 -3
- package/src/editor/ui/ManifestFileManager.svelte +71 -4
- package/src/editor/ui/PaletteEditor.svelte +52 -79
- package/src/editor/ui/ProjectFontsSection.svelte +328 -293
- package/src/editor/ui/ThemeFileManager.svelte +0 -4
- package/src/editor/ui/UIFontFamilySelector.svelte +0 -1
- package/src/editor/ui/UIFontSizeSelector.svelte +3 -0
- package/src/editor/ui/UIInfoPopover.svelte +0 -1
- package/src/editor/ui/UILetterSpacingSelector.svelte +65 -0
- package/src/editor/ui/UIPaletteSelector.svelte +31 -4
- package/src/editor/ui/UIPillButton.svelte +33 -3
- package/src/editor/ui/UISegmentedControl.svelte +114 -0
- package/src/editor/ui/UITokenSelector.svelte +4 -1
- package/src/editor/ui/VariablesTab.svelte +41 -35
- package/src/editor/ui/palette/OverridesPanel.svelte +14 -37
- package/src/editor/ui/palette/PaletteBase.svelte +3 -3
- package/src/editor/ui/sections/ColumnsSection.svelte +1 -2
- package/src/editor/ui/sections/GradientsSection.svelte +1 -1
- package/src/editor/ui/sections/OverlaysSection.svelte +1 -1
- package/src/editor/ui/sections/ShadowsSection.svelte +1 -1
- package/src/system/components/Button.svelte +2 -2
- package/src/system/components/Card.svelte +29 -1
- package/src/system/components/CollapsibleSection.svelte +25 -2
- package/src/system/components/Dialog.svelte +24 -4
- package/src/system/components/FloatingTokenTags.css +43 -24
- package/src/system/components/FloatingTokenTags.svelte +88 -137
- package/src/system/components/Notification.svelte +8 -1
- package/src/system/components/SectionDivider.svelte +532 -381
- package/src/system/styles/CONVENTIONS.md +1 -1
- package/src/system/styles/fonts.css +3 -16
- package/src/system/styles/tokens.css +356 -1199
- package/src/system/styles/tokens.generated.css +544 -0
- package/src/editor/component-editor/scaffolding/DividerEditor.svelte +0 -94
- package/src/editor/component-editor/scaffolding/GradientCard.svelte +0 -296
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
/**
|
|
3
|
-
* Composite editor for a 3-stop linear gradient defined as flat per-variant
|
|
4
|
-
* tokens (angle + 3× color + 3× position). Renders:
|
|
5
|
-
* - a live gradient ribbon with diamond handles below each stop's position
|
|
6
|
-
* - a UIPaletteSelector for the currently-selected stop's color
|
|
7
|
-
* - an AngleDial bound to the angle token
|
|
8
|
-
*
|
|
9
|
-
* The component writes literals (`Ndeg`, `N%`) back through `setComponentAlias`
|
|
10
|
-
* when the user drags; the picker writes its own token/literal ref via
|
|
11
|
-
* UIPaletteSelector. Reads resolve through `tokenRegistry$` so values
|
|
12
|
-
* authored as `var(--gradient-angle-diagonal)` show their resolved degrees.
|
|
13
|
-
*/
|
|
14
|
-
import { setComponentAlias } from '../../core/store/editorStore';
|
|
15
|
-
import { tokenRegistry$ } from '../../core/palettes/tokenRegistry';
|
|
16
|
-
import UIPaletteSelector from '../../ui/UIPaletteSelector.svelte';
|
|
17
|
-
import AngleDial from './AngleDial.svelte';
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
interface Props {
|
|
21
|
-
component: string;
|
|
22
|
-
/** Prefix shared by all 7 token names — e.g. `--sectiondivider-canvas`. */
|
|
23
|
-
prefix: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
let { component, prefix }: Props = $props();
|
|
27
|
-
|
|
28
|
-
type StopIndex = 1 | 2 | 3;
|
|
29
|
-
const STOPS: readonly StopIndex[] = [1, 2, 3] as const;
|
|
30
|
-
|
|
31
|
-
let angleVar = $derived(`${prefix}-gradient-angle`);
|
|
32
|
-
function stopColorVar(i: StopIndex): string {
|
|
33
|
-
return `${prefix}-gradient-stop-${i}-color`;
|
|
34
|
-
}
|
|
35
|
-
function stopPositionVar(i: StopIndex): string {
|
|
36
|
-
return `${prefix}-gradient-stop-${i}-position`;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
type Registry = typeof $tokenRegistry$;
|
|
40
|
-
|
|
41
|
-
/** Walk the alias chain and read the terminal declared value as a literal.
|
|
42
|
-
* The registry is passed in explicitly so the reactive expressions below
|
|
43
|
-
* can see `$tokenRegistry$` as a dependency (Svelte's static analysis can't
|
|
44
|
-
* peek into function bodies). */
|
|
45
|
-
function resolveLiteralWith(reg: Registry, varName: string): string | null {
|
|
46
|
-
const chain = reg.resolveAliasChain(varName);
|
|
47
|
-
const terminal = chain[chain.length - 1];
|
|
48
|
-
const decl = reg.getDeclaredValue(terminal);
|
|
49
|
-
if (decl === null) return null;
|
|
50
|
-
const m = decl.match(/^var\((--[a-z0-9-]+)\)$/i);
|
|
51
|
-
return m ? reg.getDeclaredValue(m[1]) ?? null : decl.trim();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function parseNumberFromCss(raw: string | null, unit: 'deg' | '%'): number | null {
|
|
55
|
-
if (!raw) return null;
|
|
56
|
-
const m = raw.trim().match(new RegExp(`^(-?\\d+(?:\\.\\d+)?)\\s*${unit}$`));
|
|
57
|
-
return m ? parseFloat(m[1]) : null;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
let angleDeg = $derived(parseNumberFromCss(resolveLiteralWith($tokenRegistry$, angleVar), 'deg') ?? 135);
|
|
61
|
-
let positions = $derived([
|
|
62
|
-
parseNumberFromCss(resolveLiteralWith($tokenRegistry$, stopPositionVar(1)), '%') ?? 0,
|
|
63
|
-
parseNumberFromCss(resolveLiteralWith($tokenRegistry$, stopPositionVar(2)), '%') ?? 50,
|
|
64
|
-
parseNumberFromCss(resolveLiteralWith($tokenRegistry$, stopPositionVar(3)), '%') ?? 100,
|
|
65
|
-
] as [number, number, number]);
|
|
66
|
-
|
|
67
|
-
// Reference the per-stop CSS var directly so the cascade fills in the
|
|
68
|
-
// component's CSS defaults when the user hasn't overridden a stop. Reading
|
|
69
|
-
// `aliases[...]` alone would miss defaults (no override → `#888`) even
|
|
70
|
-
// though the component is rendering the color via its own `:root` block.
|
|
71
|
-
let stopColors = $derived(([1, 2, 3] as StopIndex[]).map((i) => `var(${stopColorVar(i)})`) as [string, string, string]);
|
|
72
|
-
|
|
73
|
-
// Build the live gradient string from current positions + colors so the
|
|
74
|
-
// ribbon reflects edits even mid-drag (before the component re-renders via
|
|
75
|
-
// its own CSS var consumption).
|
|
76
|
-
let ribbonBg = $derived(`linear-gradient(90deg, ${stopColors
|
|
77
|
-
.map((c, i) => `${c} ${positions[i]}%`)
|
|
78
|
-
.join(', ')})`);
|
|
79
|
-
|
|
80
|
-
let selected: StopIndex = $state(1);
|
|
81
|
-
|
|
82
|
-
function setAngle(deg: number) {
|
|
83
|
-
setComponentAlias(component, angleVar, { kind: 'literal', value: `${Math.round(deg)}deg` });
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function setPosition(i: StopIndex, pct: number) {
|
|
87
|
-
const clamped = Math.max(0, Math.min(100, Math.round(pct * 10) / 10));
|
|
88
|
-
setComponentAlias(component, stopPositionVar(i), { kind: 'literal', value: `${clamped}%` });
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// ── Position handle drag ────────────────────────────────────────────────
|
|
92
|
-
let barEl: HTMLDivElement | undefined = $state();
|
|
93
|
-
let dragIndex: StopIndex | null = $state(null);
|
|
94
|
-
|
|
95
|
-
function pctFromEvent(e: PointerEvent): number {
|
|
96
|
-
const rect = barEl!.getBoundingClientRect();
|
|
97
|
-
const x = e.clientX - rect.left;
|
|
98
|
-
return (x / rect.width) * 100;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function onHandleDown(e: PointerEvent, i: StopIndex) {
|
|
102
|
-
selected = i;
|
|
103
|
-
dragIndex = i;
|
|
104
|
-
(e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);
|
|
105
|
-
setPosition(i, pctFromEvent(e));
|
|
106
|
-
}
|
|
107
|
-
function onHandleMove(e: PointerEvent) {
|
|
108
|
-
if (dragIndex === null) return;
|
|
109
|
-
setPosition(dragIndex, pctFromEvent(e));
|
|
110
|
-
}
|
|
111
|
-
function onHandleUp(e: PointerEvent) {
|
|
112
|
-
if (dragIndex === null) return;
|
|
113
|
-
(e.currentTarget as HTMLElement).releasePointerCapture(e.pointerId);
|
|
114
|
-
dragIndex = null;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function onPositionInput(i: StopIndex, e: Event) {
|
|
118
|
-
const v = parseFloat((e.target as HTMLInputElement).value);
|
|
119
|
-
if (Number.isFinite(v)) setPosition(i, v);
|
|
120
|
-
}
|
|
121
|
-
</script>
|
|
122
|
-
|
|
123
|
-
<div class="gradient-card">
|
|
124
|
-
<div class="ribbon-wrap">
|
|
125
|
-
<div class="ribbon" bind:this={barEl} style="background: {ribbonBg};"></div>
|
|
126
|
-
<div class="handles">
|
|
127
|
-
{#each STOPS as i}
|
|
128
|
-
<button
|
|
129
|
-
type="button"
|
|
130
|
-
class="handle"
|
|
131
|
-
class:selected={selected === i}
|
|
132
|
-
class:dragging={dragIndex === i}
|
|
133
|
-
style="left: {positions[i - 1]}%; --stop-color: {stopColors[i - 1]};"
|
|
134
|
-
onpointerdown={(e) => onHandleDown(e, i)}
|
|
135
|
-
onpointermove={onHandleMove}
|
|
136
|
-
onpointerup={onHandleUp}
|
|
137
|
-
onpointercancel={onHandleUp}
|
|
138
|
-
title="Stop {i} ({positions[i - 1]}%)"
|
|
139
|
-
aria-label="Gradient stop {i}"
|
|
140
|
-
>
|
|
141
|
-
<span class="handle-diamond"></span>
|
|
142
|
-
</button>
|
|
143
|
-
{/each}
|
|
144
|
-
</div>
|
|
145
|
-
</div>
|
|
146
|
-
|
|
147
|
-
<div class="stop-edit-row">
|
|
148
|
-
<span class="row-label">Stop {selected}</span>
|
|
149
|
-
<label class="pos-input">
|
|
150
|
-
<input
|
|
151
|
-
type="number"
|
|
152
|
-
min="0"
|
|
153
|
-
max="100"
|
|
154
|
-
step="0.1"
|
|
155
|
-
value={positions[selected - 1]}
|
|
156
|
-
onchange={(e) => onPositionInput(selected, e)}
|
|
157
|
-
/>
|
|
158
|
-
<span class="suffix">%</span>
|
|
159
|
-
</label>
|
|
160
|
-
<div class="picker-slot">
|
|
161
|
-
<UIPaletteSelector variable={stopColorVar(selected)} {component} />
|
|
162
|
-
</div>
|
|
163
|
-
<div class="angle-slot">
|
|
164
|
-
<AngleDial value={angleDeg} onchange={(d) => setAngle(d.value)} />
|
|
165
|
-
</div>
|
|
166
|
-
</div>
|
|
167
|
-
</div>
|
|
168
|
-
|
|
169
|
-
<style>
|
|
170
|
-
.gradient-card {
|
|
171
|
-
display: flex;
|
|
172
|
-
flex-direction: column;
|
|
173
|
-
gap: var(--ui-space-12);
|
|
174
|
-
padding: var(--ui-space-12);
|
|
175
|
-
background: var(--ui-surface-lowest);
|
|
176
|
-
border: 1px solid var(--ui-border-low);
|
|
177
|
-
border-radius: var(--ui-radius-md);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
.ribbon-wrap {
|
|
181
|
-
display: flex;
|
|
182
|
-
flex-direction: column;
|
|
183
|
-
gap: var(--ui-space-8);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
.ribbon {
|
|
187
|
-
position: relative;
|
|
188
|
-
height: 2.25rem;
|
|
189
|
-
border-radius: var(--ui-radius-sm);
|
|
190
|
-
border: 1px solid var(--ui-border);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
.handles {
|
|
194
|
-
position: relative;
|
|
195
|
-
height: 1.25rem;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/* The button is a generous (1.25rem) transparent hit target so the diamond
|
|
199
|
-
can stay visually small while remaining easy to grab/drag. The visible
|
|
200
|
-
marker lives in `.handle-diamond` inside. */
|
|
201
|
-
.handle {
|
|
202
|
-
position: absolute;
|
|
203
|
-
top: 0;
|
|
204
|
-
width: 1.25rem;
|
|
205
|
-
height: 1.25rem;
|
|
206
|
-
margin-left: -0.625rem;
|
|
207
|
-
padding: 0;
|
|
208
|
-
background: transparent;
|
|
209
|
-
border: none;
|
|
210
|
-
cursor: ew-resize;
|
|
211
|
-
touch-action: none;
|
|
212
|
-
display: flex;
|
|
213
|
-
align-items: center;
|
|
214
|
-
justify-content: center;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
.handle-diamond {
|
|
218
|
-
width: 0.7rem;
|
|
219
|
-
height: 0.7rem;
|
|
220
|
-
background: var(--stop-color, var(--ui-surface-high));
|
|
221
|
-
border: 1px solid var(--ui-border);
|
|
222
|
-
transform: rotate(45deg);
|
|
223
|
-
border-radius: 1px;
|
|
224
|
-
transition: border-color var(--ui-transition-fast), box-shadow var(--ui-transition-fast);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
.handle:hover .handle-diamond {
|
|
228
|
-
border-color: var(--ui-text-secondary);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
.handle.selected .handle-diamond {
|
|
232
|
-
border-color: var(--ui-text-primary);
|
|
233
|
-
box-shadow: 0 0 0 1px var(--ui-text-primary);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
.handle.dragging {
|
|
237
|
-
z-index: 2;
|
|
238
|
-
}
|
|
239
|
-
.handle.dragging .handle-diamond {
|
|
240
|
-
border-color: var(--ui-text-primary);
|
|
241
|
-
box-shadow: 0 0 0 2px var(--ui-text-primary);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/* Selected-stop row: label, position readout, color picker, then angle dial
|
|
245
|
-
inline on the right. The selector width matches TokenLayout's
|
|
246
|
-
`--token-selector-w` so this row aligns with the property grid below. */
|
|
247
|
-
.stop-edit-row {
|
|
248
|
-
display: flex;
|
|
249
|
-
flex-wrap: wrap;
|
|
250
|
-
align-items: center;
|
|
251
|
-
gap: var(--ui-space-12);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
.row-label {
|
|
255
|
-
font-size: var(--ui-font-size-xs);
|
|
256
|
-
color: var(--ui-text-secondary);
|
|
257
|
-
white-space: nowrap;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
.picker-slot {
|
|
261
|
-
width: 8rem;
|
|
262
|
-
min-width: 0;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
.pos-input {
|
|
266
|
-
display: inline-flex;
|
|
267
|
-
align-items: center;
|
|
268
|
-
gap: var(--ui-space-4);
|
|
269
|
-
font-size: var(--ui-font-size-xs);
|
|
270
|
-
color: var(--ui-text-secondary);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
.pos-input input {
|
|
274
|
-
width: 4rem;
|
|
275
|
-
padding: var(--ui-space-2) var(--ui-space-6);
|
|
276
|
-
background: var(--ui-surface-low);
|
|
277
|
-
border: 1px solid var(--ui-border-low);
|
|
278
|
-
border-radius: var(--ui-radius-sm);
|
|
279
|
-
color: var(--ui-text-primary);
|
|
280
|
-
font-family: var(--ui-font-mono);
|
|
281
|
-
font-size: var(--ui-font-size-sm);
|
|
282
|
-
text-align: right;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
.pos-input input::-webkit-outer-spin-button,
|
|
286
|
-
.pos-input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
|
|
287
|
-
|
|
288
|
-
.suffix {
|
|
289
|
-
font-size: var(--ui-font-size-xs);
|
|
290
|
-
color: var(--ui-text-tertiary);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
.angle-slot {
|
|
294
|
-
margin-left: auto;
|
|
295
|
-
}
|
|
296
|
-
</style>
|