@motion-proto/live-tokens 0.50.0 → 0.53.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.
Files changed (91) hide show
  1. package/.claude/skills/live-tokens-adjust-shape-space/SKILL.md +7 -1
  2. package/CHANGELOG.md +108 -0
  3. package/bin/adjust.mjs +16 -39
  4. package/bin/generate-theme.mjs +20 -6
  5. package/dist-plugin/adjust/index.cjs +781 -21
  6. package/dist-plugin/adjust/index.d.cts +2 -1
  7. package/dist-plugin/adjust/index.d.ts +2 -1
  8. package/dist-plugin/adjust/index.js +43 -21
  9. package/dist-plugin/{chunk-6OZFXIQI.js → chunk-232GZGQU.js} +207 -12
  10. package/dist-plugin/chunk-NE6N66EE.js +753 -0
  11. package/dist-plugin/{chunk-76TFDTJO.js → chunk-PB2JTK2H.js} +179 -128
  12. package/dist-plugin/{chunk-44RSTAII.js → chunk-TKZBVIW5.js} +33 -5
  13. package/dist-plugin/chunk-YR6GPXW2.js +129 -0
  14. package/dist-plugin/generateColorsAndType/index.cjs +135 -63
  15. package/dist-plugin/generateColorsAndType/index.d.cts +2 -1
  16. package/dist-plugin/generateColorsAndType/index.d.ts +2 -1
  17. package/dist-plugin/generateColorsAndType/index.js +28 -784
  18. package/dist-plugin/{themeTypes-DSwKq-bj.d.ts → index-DpTIRZ2H.d.cts} +67 -26
  19. package/dist-plugin/{themeTypes-DSwKq-bj.d.cts → index-DpTIRZ2H.d.ts} +67 -26
  20. package/dist-plugin/index.cjs +1254 -140
  21. package/dist-plugin/index.js +106 -82
  22. package/dist-plugin/migrateData/index.cjs +956 -14
  23. package/dist-plugin/migrateData/index.js +10 -3
  24. package/dist-plugin/tokensCssMigrations/index.cjs +71 -5
  25. package/dist-plugin/tokensCssMigrations/index.d.cts +20 -9
  26. package/dist-plugin/tokensCssMigrations/index.d.ts +20 -9
  27. package/dist-plugin/tokensCssMigrations/index.js +4 -1
  28. package/package.json +8 -4
  29. package/src/editor/component-editor/NotificationEditor.svelte +6 -0
  30. package/src/editor/component-editor/scaffolding/ComponentFileManager.svelte +9 -23
  31. package/src/editor/component-editor/scaffolding/LinkedBlock.svelte +8 -8
  32. package/src/editor/core/components/adjustAliases.ts +49 -22
  33. package/src/editor/core/components/aliasKinds.ts +7 -2
  34. package/src/editor/core/components/componentConfigService.ts +1 -1
  35. package/src/editor/core/palettes/oklch.ts +3 -137
  36. package/src/editor/core/palettes/paletteDerivation.ts +79 -37
  37. package/src/editor/core/store/editorStore.ts +7 -197
  38. package/src/editor/core/store/editorTypes.ts +9 -30
  39. package/src/editor/core/themes/generateColorsAndType.ts +18 -8
  40. package/src/editor/core/themes/lookSummary.ts +3 -25
  41. package/src/editor/core/themes/migrateComponentConfig.ts +205 -0
  42. package/src/editor/core/themes/migrations/2026-05-19-sectiondivider-rich-gradient.ts +1 -1
  43. package/src/editor/core/themes/migrations/2026-05-20-sectiondivider-slim-variants.ts +1 -1
  44. package/src/editor/core/themes/migrations/2026-05-22-sectiondivider-intrinsics-to-css.ts +1 -1
  45. package/src/editor/core/themes/parsers/gradient.ts +211 -0
  46. package/src/editor/core/themes/slices/gradients.ts +5 -58
  47. package/src/editor/core/themes/themeService.ts +22 -9
  48. package/src/editor/core/themes/themeTypes.ts +89 -27
  49. package/src/editor/docs/content/editing-tokens.md +6 -2
  50. package/src/editor/docs/content/themes-workflow.md +9 -11
  51. package/src/editor/docs/content/where-themes-live.md +2 -2
  52. package/src/editor/docs/content.generated.ts +3 -3
  53. package/src/editor/index.ts +1 -0
  54. package/src/editor/styles/ui-editor.css +5 -2
  55. package/src/editor/ui/BezierCurveEditor.svelte +90 -67
  56. package/src/editor/ui/PaletteEditor.svelte +180 -59
  57. package/src/editor/ui/ThemePanel.svelte +24 -15
  58. package/src/editor/ui/Toggle.svelte +36 -24
  59. package/src/editor/ui/UIPillButton.svelte +1 -1
  60. package/src/editor/ui/UIReveal.svelte +47 -0
  61. package/src/editor/ui/UISquareButton.svelte +1 -1
  62. package/src/editor/ui/colors/ColorStory.svelte +12 -8
  63. package/src/editor/ui/colors/ColorsTab.svelte +4 -5
  64. package/src/editor/ui/curveEngine.ts +101 -21
  65. package/src/editor/ui/palette/OverridesPanel.svelte +23 -8
  66. package/src/editor/ui/palette/PaletteBase.svelte +17 -78
  67. package/src/editor/ui/palette/PaletteJumpButton.svelte +3 -3
  68. package/src/editor/ui/palette/ScaleCurveEditor.svelte +110 -20
  69. package/src/editor/ui/palette/curveSummary.ts +20 -0
  70. package/src/editor/ui/palette/dockMagnify.ts +5 -13
  71. package/src/editor/ui/palette/paletteMath.ts +7 -4
  72. package/src/live-tokens/data/colors-and-type/autumn.json +528 -528
  73. package/src/live-tokens/data/colors-and-type/default.json +247 -247
  74. package/src/live-tokens/data/colors-and-type/halloween.json +532 -532
  75. package/src/live-tokens/data/colors-and-type/midnight-study.json +538 -538
  76. package/src/live-tokens/data/colors-and-type/ocean.json +521 -521
  77. package/src/live-tokens/data/colors-and-type/royal-velvet.json +532 -532
  78. package/src/live-tokens/data/colors-and-type/spring-meadow.json +504 -504
  79. package/src/live-tokens/data/colors-and-type/sunset.json +531 -531
  80. package/src/live-tokens/data/themes/autumn.json +604 -568
  81. package/src/live-tokens/data/themes/halloween.json +584 -583
  82. package/src/live-tokens/data/themes/midnight-study.json +673 -605
  83. package/src/live-tokens/data/themes/ocean.json +597 -561
  84. package/src/live-tokens/data/themes/royal-velvet.json +574 -573
  85. package/src/live-tokens/data/themes/spring-meadow.json +590 -556
  86. package/src/live-tokens/data/themes/sunset.json +632 -571
  87. package/src/live-tokens/data/tokens.generated.css +282 -282
  88. package/src/system/components/FloatingTokenTags.css +0 -1
  89. package/src/system/internal/backgroundContrast.ts +7 -0
  90. package/src/system/internal/oklch.ts +189 -0
  91. package/src/system/styles/tokens.css +283 -283
@@ -1,20 +1,21 @@
1
1
  <script lang="ts">
2
2
  import { onMount, onDestroy, tick } from 'svelte';
3
3
  import { oklchToHexClamped, type Oklch } from '../core/palettes/oklch';
4
- import { type CurveAnchor, lightnessCurveConfig, saturationCurveConfig } from './curveEngine';
4
+ import { type CurveAnchor, lightnessCurveConfig, saturationCurveConfig, hueCurveConfig } from './curveEngine';
5
5
  import ColorEditPanel from './ColorEditPanel.svelte';
6
6
  import OverridesPanel from './palette/OverridesPanel.svelte';
7
7
  import UIPillButton from './UIPillButton.svelte';
8
+ import UIReveal from './UIReveal.svelte';
8
9
  import GradientStopEditor from './palette/GradientStopEditor.svelte';
9
10
  import ScaleCurveEditor from './palette/ScaleCurveEditor.svelte';
10
11
  import PaletteBase from './palette/PaletteBase.svelte';
11
12
  import PaletteJumpButton from './palette/PaletteJumpButton.svelte';
13
+ import Toggle from './Toggle.svelte';
12
14
  import { type EditingState, idleState, BASE_KEY, isEditingBase as isBaseEdit } from './palette/paletteEditorState';
13
- import { dockTrackTemplate } from './palette/dockMagnify';
14
15
  import {
15
16
  type Step, type Scale,
16
17
  GRAY_FALLBACK,
17
- DEFAULT_PALETTE_LIGHTNESS, DEFAULT_PALETTE_SATURATION,
18
+ DEFAULT_PALETTE_LIGHTNESS, DEFAULT_PALETTE_SATURATION, DEFAULT_PALETTE_HUE,
18
19
  defaultScaleCurves, defaultScaleCurvesObject, defaultPaletteConfig,
19
20
  paletteStepLightness, scales,
20
21
  paletteStepKey, stepKey, scaleCurveKey as getScaleCurveKey,
@@ -32,6 +33,12 @@
32
33
  import { pendingPaletteFocus } from '../core/store/paletteFocus';
33
34
  import { showCopyPopover } from './copyPopover';
34
35
 
36
+ // Full sRGB chroma range (gamutClamp trims per hue/lightness). Neutrals default
37
+ // low but are not capped; their calm character comes from defaults, not a ceiling.
38
+ const BASE_CHROMA_MAX = 0.4;
39
+ // Where a typical neutral's chroma sits, marked on the slider as a soft nudge.
40
+ const NEUTRAL_CALM_CHROMA = 0.05;
41
+
35
42
  interface Props {
36
43
  label: string;
37
44
  displayLabel?: string | null;
@@ -80,6 +87,14 @@
80
87
  const idx = saturationCurve.findIndex(a => Math.abs(a.x - x) < 0.5);
81
88
  return idx >= 0 ? idx : null;
82
89
  });
90
+ // Unlike lightness/saturation, hue has no always-present curve to search: it stays
91
+ // undefined until the first edit (RJC 5), and there is nothing to lock before then.
92
+ let lockedHueIdx: number | null = $derived.by(() => {
93
+ if (!anchorToBase || anchorPlacement === undefined || hueCurve === undefined) return null;
94
+ const x = stepIndexToX(anchorPlacement.step);
95
+ const idx = hueCurve.findIndex(a => Math.abs(a.x - x) < 0.5);
96
+ return idx >= 0 ? idx : null;
97
+ });
83
98
 
84
99
  // Held at component scope so inline header-swatch handlers and the function
85
100
  // handlers share one handle for commit/cancel.
@@ -114,14 +129,36 @@
114
129
  function setLightnessCurve(a: CurveAnchor[]) { edit('lightnessCurve', a); }
115
130
  function setSaturationCurve(a: CurveAnchor[]) { edit('saturationCurve', a); }
116
131
 
132
+ // First edit materializes the field (RJC 5) with `a` — the curve the UI
133
+ // actually rendered and edited — written in BEFORE syncBaseAnchor runs, not
134
+ // after: syncBaseAnchor pins the anchor by inserting a y=0 point into
135
+ // whatever `cfg.hueCurve` currently holds, so calling it against the
136
+ // about-to-be-discarded flat default and then overwriting with `a` would
137
+ // throw the pin away. Wave 3's idempotency guarantee is what makes
138
+ // re-running syncBaseAnchor here safe without disturbing the
139
+ // lightness/saturation anchors it already placed.
140
+ function setHueCurve(a: CurveAnchor[]) {
141
+ mutate(`${label}: hueCurve`, (s) => {
142
+ if (!s.palettes[label]) s.palettes[label] = seedConfig();
143
+ const cfg = s.palettes[label];
144
+ const materializing = cfg.hueCurve === undefined;
145
+ cfg.hueCurve = a;
146
+ if (materializing) syncBaseAnchor(cfg);
147
+ });
148
+ }
149
+
117
150
  function handleOffset(key: string, value: number) {
118
151
  edit('curveOffset', { ...curveOffset, [key]: value });
119
152
  }
120
153
 
154
+ function handleAutoSmooth(key: string, value: boolean) {
155
+ edit('curveAutoSmooth', { ...curveAutoSmooth, [key]: value });
156
+ }
157
+
121
158
  let editing: EditingState = $state(idleState);
122
159
 
123
160
  function computePaletteOklch(index: number, base: Oklch): Oklch {
124
- return computePaletteOklchPure(index, base, lightnessCurve, saturationCurve, curveOffset);
161
+ return computePaletteOklchPure(index, base, lightnessCurve, saturationCurve, curveOffset, hueCurve);
125
162
  }
126
163
 
127
164
  function computeDerivedOklch(step: Step, base: Oklch, scaleTitle: string): Oklch {
@@ -176,7 +213,17 @@
176
213
  scaleEditorOpen = scaleEditorOpen;
177
214
  }
178
215
 
179
- function setScaleCurve(title: string, channel: 'lightness' | 'saturation', a: CurveAnchor[]) {
216
+ // Session-scoped (RJC 9): viewport state, never written to theme JSON.
217
+ // Keyed by the same curveKey strings that already key curveOffset, so a
218
+ // hue key ("hue" or "<scale>-hue") defaults closed and the rest open.
219
+ let curveSectionOpen: Record<string, boolean> = $state({});
220
+ const sectionOpen = (key: string) => curveSectionOpen[key] ?? !key.endsWith('hue');
221
+ function toggleCurveSection(key: string) {
222
+ curveSectionOpen[key] = !sectionOpen(key);
223
+ curveSectionOpen = curveSectionOpen;
224
+ }
225
+
226
+ function setScaleCurve(title: string, channel: 'lightness' | 'saturation' | 'hue', a: CurveAnchor[]) {
180
227
  const cur = scaleCurves[title] ?? { lightness: defaultScaleCurves[title].lightness(), saturation: defaultScaleCurves[title].saturation() };
181
228
  edit('scaleCurves', { ...scaleCurves, [title]: { ...cur, [channel]: a } });
182
229
  }
@@ -389,22 +436,16 @@
389
436
  let baseColor = $derived($editorState.palettes[label]?.baseColor ?? initialColor);
390
437
  let lightnessCurve = $derived($editorState.palettes[label]?.lightnessCurve ?? DEFAULT_PALETTE_LIGHTNESS());
391
438
  let saturationCurve = $derived($editorState.palettes[label]?.saturationCurve ?? DEFAULT_PALETTE_SATURATION());
439
+ // Left undefined when absent (RJC 5): materializing here would seed every
440
+ // fresh palette with a redundant flat curve it never asked for.
441
+ let hueCurve = $derived($editorState.palettes[label]?.hueCurve);
392
442
  let scaleCurves = $derived($editorState.palettes[label]?.scaleCurves ?? defaultScaleCurvesObject());
393
443
  let curveOffset = $derived($editorState.palettes[label]?.curveOffset ?? { lightness: 0, saturation: 0 });
444
+ let curveAutoSmooth = $derived($editorState.palettes[label]?.curveAutoSmooth ?? {});
394
445
  let overrides = $derived($editorState.palettes[label]?.overrides ?? {});
395
446
  let snappedScales = $derived(new Set($editorState.palettes[label]?.snappedScales ?? []));
396
447
  let anchorToBase = $derived($editorState.palettes[label]?.anchorToBase ?? true);
397
448
  let anchorPlacement = $derived($editorState.palettes[label]?.anchorPlacement);
398
- let anchorStepLabel = $derived(anchorToBase && anchorPlacement !== undefined
399
- ? paletteStepLightness[anchorPlacement.step]?.label ?? null
400
- : null);
401
- // Dock magnification: the grid transitions between track lists, so dialing
402
- // lightness reads as swatches opening/closing while the anchor walks the
403
- // ramp. Column 0 is the white bookend, so step i is column i+1.
404
- let swatchTemplate = $derived(dockTrackTemplate(
405
- paletteStepLightness.length + 2,
406
- anchorToBase && anchorPlacement !== undefined ? anchorPlacement.step + 1 : null,
407
- ));
408
449
  let emptyMode = $derived($editorState.palettes[label]?.emptyMode ?? 'solid');
409
450
  let gradientStyle = $derived($editorState.palettes[label]?.gradientStyle ?? 'linear');
410
451
  let gradientAngle = $derived($editorState.palettes[label]?.gradientAngle ?? 180);
@@ -417,7 +458,7 @@
417
458
  let editingKey = $derived(editing.kind === 'idle' ? null : editing.kind === 'editingBase' ? BASE_KEY : editing.stepKey);
418
459
  let editingDraft = $derived(editing.kind === 'editingStep' ? editing.draft : null);
419
460
  let paletteComputed = $derived((() => {
420
- const _bc = baseColor, _lc = lightnessCurve, _sc = saturationCurve, _co = curveOffset, _ed = editingDraft, _ek = editingKey, _ov = overrides, _ab = anchorToBase, _ap = anchorPlacement;
461
+ const _bc = baseColor, _lc = lightnessCurve, _sc = saturationCurve, _hc = hueCurve, _co = curveOffset, _ed = editingDraft, _ek = editingKey, _ov = overrides, _ab = anchorToBase, _ap = anchorPlacement;
421
462
  return paletteStepLightness.map((ps, index) => {
422
463
  const k = paletteStepKey(ps.label);
423
464
  const oklch = computePaletteOklch(index, baseColor);
@@ -488,23 +529,55 @@
488
529
  <PaletteBase
489
530
  {label}
490
531
  {displayLabel}
491
- {neutral}
492
532
  {baseColor}
493
- {anchorToBase}
494
- {anchorStepLabel}
495
533
  {isEditingBase}
496
- {panelOpen}
497
534
  pinnedOpen={paletteEditorOpen}
498
- {editingColor}
499
- {editPanelTitle}
500
535
  {copiedKey}
501
536
  onStartEdit={startBaseEdit}
502
- onConfirm={confirmEdit}
503
- onCancel={cancelEdit}
504
- onBaseChange={(h, c, l) => setBaseColor(label, { l: l / 100, c, h })}
505
- onAnchorToBaseChange={setAnchorToBase}
506
537
  onCopyBaseHex={copyHex}
507
- />
538
+ >
539
+ {#snippet actions()}
540
+ <PaletteJumpButton family={label} {displayLabel} target="wheel" />
541
+ <UIPillButton size="compact" variant="outline" onclick={clearPaletteOverrides}>Clear Overrides</UIPillButton>
542
+ <UIPillButton size="compact" variant="outline" onclick={() => paletteEditorOpen = !paletteEditorOpen}>
543
+ {paletteEditorOpen ? 'Close' : 'Edit'}
544
+ </UIPillButton>
545
+ {/snippet}
546
+ </PaletteBase>
547
+
548
+ {#if paletteEditorOpen || (isEditingBase && panelOpen && editingColor)}
549
+ <div class="swatch-grid" style="--swatch-cols: {paletteStepLightness.length + 2}">
550
+ <div class="base-panel" style="grid-column: 2 / {paletteStepLightness.length + 2}">
551
+ <ColorEditPanel
552
+ title={isEditingBase ? editPanelTitle : 'Base Color'}
553
+ showRemoveOverride={false}
554
+ hideActions={!isEditingBase}
555
+ hidePreview
556
+ hue={baseColor.h}
557
+ chroma={baseColor.c}
558
+ lightness={baseColor.l * 100}
559
+ chromaMax={BASE_CHROMA_MAX}
560
+ chromaHint={neutral ? NEUTRAL_CALM_CHROMA : undefined}
561
+ onHueChromaChange={(h, c, l) => setBaseColor(label, { l: l / 100, c, h })}
562
+ onConfirm={confirmEdit}
563
+ onCancel={cancelEdit}
564
+ onRemoveOverride={() => {}}
565
+ onSliderStart={() => beginSliderGesture(`edit ${label} base`)}
566
+ >
567
+ {#snippet actions()}
568
+ <div class="base-anchor-toggle">
569
+ <Toggle
570
+ checked={anchorToBase}
571
+ onchange={(v) => setAnchorToBase(v ?? !anchorToBase)}
572
+ label="Base color must appear in palette"
573
+ labelFirst
574
+ />
575
+ </div>
576
+ {/snippet}
577
+ </ColorEditPanel>
578
+ </div>
579
+ </div>
580
+ {/if}
508
581
 
509
582
  <!-- Palette + Text row -->
510
583
  <div class="scales-row">
@@ -521,13 +594,8 @@
521
594
  <span>Gradient</span>
522
595
  </label>
523
596
  {/if}
524
- <PaletteJumpButton family={label} {displayLabel} target="wheel" />
525
- <UIPillButton size="compact" variant="outline" onclick={clearPaletteOverrides}>Clear Overrides</UIPillButton>
526
- <UIPillButton size="compact" variant="outline" onclick={() => paletteEditorOpen = !paletteEditorOpen}>
527
- {paletteEditorOpen ? 'Close' : 'Edit'}
528
- </UIPillButton>
529
597
  </div>
530
- <div class="swatch-grid" style="--swatch-cols: {paletteStepLightness.length + 2}; grid-template-columns: {swatchTemplate}">
598
+ <div class="swatch-grid" style="--swatch-cols: {paletteStepLightness.length + 2}">
531
599
  <div class="step-column">
532
600
  <button class="step-label copyable-label" class:copied={copiedLabelKey === 'palette-white'} type="button" onclick={(e) => copyVarName('palette-white', `--color-${cssNamespace}-white`, e)}>
533
601
  {copiedLabelKey === 'palette-white' ? 'copied!' : 'white'}
@@ -572,8 +640,8 @@
572
640
  </button>
573
641
  <div class="swatch gray-swatch bookend" style="background: #000000"></div>
574
642
  </div>
575
- {#if paletteEditorOpen}
576
- <div class="curve-grid-span" style="grid-column: 2 / {paletteStepLightness.length + 2}">
643
+ <UIReveal open={paletteEditorOpen} style="grid-column: 2 / {paletteStepLightness.length + 2}">
644
+ <div class="curve-grid-span">
577
645
  {#if anchorUnlockPrompt && anchorToBase}
578
646
  <div class="anchor-unlock-notice" role="alert">
579
647
  <i class="fas fa-triangle-exclamation" aria-hidden="true"></i>
@@ -585,16 +653,20 @@
585
653
  </div>
586
654
  {/if}
587
655
  <ScaleCurveEditor
588
- curveKey="lightness"
589
- anchors={lightnessCurve}
590
- cfg={lightnessCurveConfig}
656
+ curveKey="hue"
657
+ anchors={hueCurve ?? DEFAULT_PALETTE_HUE()}
658
+ cfg={hueCurveConfig}
591
659
  stepCount={paletteStepLightness.length}
592
- defaults={DEFAULT_PALETTE_LIGHTNESS()}
593
- offset={curveOffset['lightness'] ?? 0}
594
- lockedAnchorIndex={lockedLightnessIdx}
660
+ defaults={DEFAULT_PALETTE_HUE()}
661
+ offset={curveOffset['hue'] ?? 0}
662
+ autoSmooth={curveAutoSmooth['hue']}
663
+ lockedAnchorIndex={lockedHueIdx}
664
+ open={sectionOpen('hue')}
665
+ onToggleOpen={() => toggleCurveSection('hue')}
595
666
  onLockedAnchorUnlock={() => anchorUnlockPrompt = true}
596
- onAnchorsChange={setLightnessCurve}
667
+ onAnchorsChange={setHueCurve}
597
668
  onOffsetChange={handleOffset}
669
+ onAutoSmoothChange={handleAutoSmooth}
598
670
  />
599
671
  <ScaleCurveEditor
600
672
  curveKey="saturation"
@@ -603,13 +675,33 @@
603
675
  stepCount={paletteStepLightness.length}
604
676
  defaults={DEFAULT_PALETTE_SATURATION()}
605
677
  offset={curveOffset['saturation'] ?? 0}
678
+ autoSmooth={curveAutoSmooth['saturation']}
606
679
  lockedAnchorIndex={lockedSaturationIdx}
680
+ open={sectionOpen('saturation')}
681
+ onToggleOpen={() => toggleCurveSection('saturation')}
607
682
  onLockedAnchorUnlock={() => anchorUnlockPrompt = true}
608
683
  onAnchorsChange={setSaturationCurve}
609
684
  onOffsetChange={handleOffset}
685
+ onAutoSmoothChange={handleAutoSmooth}
686
+ />
687
+ <ScaleCurveEditor
688
+ curveKey="lightness"
689
+ anchors={lightnessCurve}
690
+ cfg={lightnessCurveConfig}
691
+ stepCount={paletteStepLightness.length}
692
+ defaults={DEFAULT_PALETTE_LIGHTNESS()}
693
+ offset={curveOffset['lightness'] ?? 0}
694
+ autoSmooth={curveAutoSmooth['lightness']}
695
+ lockedAnchorIndex={lockedLightnessIdx}
696
+ open={sectionOpen('lightness')}
697
+ onToggleOpen={() => toggleCurveSection('lightness')}
698
+ onLockedAnchorUnlock={() => anchorUnlockPrompt = true}
699
+ onAnchorsChange={setLightnessCurve}
700
+ onOffsetChange={handleOffset}
701
+ onAutoSmoothChange={handleAutoSmooth}
610
702
  />
611
703
  </div>
612
- {/if}
704
+ </UIReveal>
613
705
  </div>
614
706
 
615
707
  {#if emptySelector && emptyMode === 'gradient'}
@@ -641,6 +733,7 @@
641
733
  {cssNamespace}
642
734
  {scaleCurves}
643
735
  {curveOffset}
736
+ {curveAutoSmooth}
644
737
  {defaultScaleCurves}
645
738
  overrides={overridesHex}
646
739
  {editingKey}
@@ -663,6 +756,9 @@
663
756
  onCopyVarName={copyVarName}
664
757
  onSetScaleCurve={setScaleCurve}
665
758
  onOffsetChange={handleOffset}
759
+ onAutoSmoothChange={handleAutoSmooth}
760
+ {sectionOpen}
761
+ onToggleCurveSection={toggleCurveSection}
666
762
  />
667
763
  {/snippet}
668
764
 
@@ -671,18 +767,20 @@
671
767
  <span>Text, Surfaces &amp; Borders</span>
672
768
  </button>
673
769
 
674
- {#if showDerived}
675
- <div class="scales-row">
676
- {#each scales.filter(s => s.isText) as scale}
677
- {@render overridesPanel(scale, true, derivedHexForBase)}
678
- {/each}
679
- </div>
680
- <div class="scales-row">
681
- {#each scales.filter(s => !s.isText) as scale}
682
- {@render overridesPanel(scale, true, derivedHexForBase)}
683
- {/each}
770
+ <UIReveal open={showDerived}>
771
+ <div class="derived-rows">
772
+ <div class="scales-row">
773
+ {#each scales.filter(s => s.isText) as scale}
774
+ {@render overridesPanel(scale, true, derivedHexForBase)}
775
+ {/each}
776
+ </div>
777
+ <div class="scales-row">
778
+ {#each scales.filter(s => !s.isText) as scale}
779
+ {@render overridesPanel(scale, true, derivedHexForBase)}
780
+ {/each}
781
+ </div>
684
782
  </div>
685
- {/if}
783
+ </UIReveal>
686
784
 
687
785
  <!-- Color Edit Panel (non-base edits) -->
688
786
  {#if !isEditingBase && panelOpen && editingColor}
@@ -760,6 +858,14 @@
760
858
  min-width: 0;
761
859
  }
762
860
 
861
+ /* Carries the column gap the two rows used to get from .palette-editor,
862
+ now that the reveal wrapper sits between them and it. */
863
+ .derived-rows {
864
+ display: flex;
865
+ flex-direction: column;
866
+ gap: var(--ui-space-20);
867
+ }
868
+
763
869
  .scale-section {
764
870
  display: flex;
765
871
  flex-direction: column;
@@ -862,13 +968,28 @@
862
968
 
863
969
  .swatch-grid {
864
970
  display: grid;
971
+ /* Even tracks: the curve editors below plot one step per column, so a wider
972
+ anchored column would slide every swatch out from under its own point. */
865
973
  grid-template-columns: repeat(var(--swatch-cols), minmax(0, 1fr));
866
- transition: grid-template-columns var(--ui-transition-fast);
867
974
  gap: var(--ui-space-4) var(--swatch-gap, var(--ui-space-4));
868
975
  align-items: start;
869
976
  justify-content: start;
870
977
  min-width: 0;
871
- max-width: calc(var(--swatch-cols) * 4.5rem + (var(--swatch-cols) - 1) * var(--swatch-gap, var(--ui-space-4)));
978
+ /* Definite width, not max-width: the grid is a shrink-to-fit flex item, so
979
+ without it the palette sized itself to the curve row below and shrank
980
+ every time the graphs were collapsed. */
981
+ width: calc(var(--swatch-cols) * 4.5rem + (var(--swatch-cols) - 1) * var(--swatch-gap, var(--ui-space-4)));
982
+ max-width: 100%;
983
+ }
984
+
985
+ /* The picker rides the same track geometry as the curve editors below, so
986
+ the two graphs share one left and right edge. */
987
+ .base-panel {
988
+ min-width: 0;
989
+ }
990
+
991
+ .base-anchor-toggle {
992
+ margin-left: auto;
872
993
  }
873
994
 
874
995
  .curve-grid-span {
@@ -927,9 +1048,9 @@
927
1048
  outline-offset: 1px;
928
1049
  }
929
1050
 
930
- /* The step the base color is placed at: dock-magnified (its grid column is
931
- also widened via the track template) with an emphasized border. No fill
932
- change — the swatch itself already IS the picked color. */
1051
+ /* The step the base color is placed at: taller, with an emphasized border. It
1052
+ keeps its column width so the curve editors stay aligned. No fill change:
1053
+ the swatch itself already IS the picked color. */
933
1054
  .swatch.gray-swatch.anchored {
934
1055
  border-color: var(--ui-border-higher);
935
1056
  height: calc(5.75rem + var(--ui-space-2));
@@ -21,6 +21,7 @@
21
21
  saveActiveTheme,
22
22
  exportTheme,
23
23
  importTheme,
24
+ type ThemeFillReport,
24
25
  } from '../core/themes/themeService';
25
26
  import {
26
27
  THEME_APPLIED_EVENT,
@@ -119,7 +120,6 @@
119
120
  if (active) {
120
121
  openThemeSlug.set(active._fileName ?? 'default');
121
122
  currentDisplayName = active.name ?? $openThemeSlug;
122
- lookConfigs = active.componentConfigs;
123
123
  }
124
124
  } catch {
125
125
  // silent
@@ -149,15 +149,11 @@
149
149
  // ── Components ────────────────────────────────────────────────────────
150
150
  //
151
151
  // The per-component file managers live in the component editors; the list
152
- // here answers one question — how many components run something the open
153
- // theme does not carry.
152
+ // here answers one question — how many components carry an unsaved buffer.
154
153
 
155
154
  let components: ComponentSummary[] = $state([]);
156
- let lookConfigs: Theme['componentConfigs'] | null = $state(null);
157
155
 
158
- let componentsOffLook = $derived(
159
- lookConfigs ? countComponentsOffLook(components, lookConfigs, activeIsProtected) : 0,
160
- );
156
+ let componentsOffLook = $derived(countComponentsOffLook(components));
161
157
 
162
158
  async function refreshComponents() {
163
159
  try {
@@ -194,7 +190,6 @@
194
190
  const handleThemeApplied = (event: Event) => {
195
191
  const { result } = (event as CustomEvent<AppliedThemeDetail>).detail;
196
192
  currentDisplayName = result.theme.name;
197
- lookConfigs = result.theme.componentConfigs;
198
193
  };
199
194
  document.addEventListener(THEME_APPLIED_EVENT, handleThemeApplied);
200
195
  return () => document.removeEventListener(THEME_APPLIED_EVENT, handleThemeApplied);
@@ -453,6 +448,13 @@
453
448
  await commitWholeLook();
454
449
  }
455
450
 
451
+ function filledNote(filled: ThemeFillReport): string | null {
452
+ const n = filled.components.length;
453
+ if (n === 0) return null;
454
+ return `${n} component${n === 1 ? '' : 's'} arrived with gaps. `
455
+ + `The editor filled them from the current defaults.`;
456
+ }
457
+
456
458
  async function commitWholeLook() {
457
459
  const row = previewRow;
458
460
  if (!row) return;
@@ -468,14 +470,19 @@
468
470
  let result: Awaited<ReturnType<typeof applyTheme>>;
469
471
  try {
470
472
  result = await applyTheme(row.slug);
473
+ const notes: string[] = [];
471
474
  if (result.skippedComponents.length > 0) {
472
- window.alert(
473
- `Loaded "${row.name}". These components are not installed here, so their `
474
- + `saved settings were skipped:\n\n${result.skippedComponents.join(', ')}`,
475
+ notes.push(
476
+ `These components are not installed here, so their saved settings were `
477
+ + `skipped:\n${result.skippedComponents.join(', ')}`,
475
478
  );
476
479
  }
480
+ const filled = filledNote(result.filled);
481
+ if (filled) notes.push(filled);
482
+ if (notes.length > 0) {
483
+ window.alert(`Loaded "${row.name}".\n\n${notes.join('\n\n')}`);
484
+ }
477
485
  currentDisplayName = result.theme.name;
478
- lookConfigs = result.theme.componentConfigs;
479
486
  showFileList = false;
480
487
  } catch (err) {
481
488
  window.alert(`Failed to load theme: ${(err as Error).message}`);
@@ -600,6 +607,8 @@
600
607
  `The file was missing this data, which fell back to the default:\n${result.dropped.join('\n')}`,
601
608
  );
602
609
  }
610
+ const filled = filledNote(result.filled);
611
+ if (filled) notes.push(filled);
603
612
  if (notes.length > 0) {
604
613
  window.alert(`Imported as "${result.theme}".\n\n${notes.join('\n\n')}`);
605
614
  }
@@ -671,7 +680,7 @@
671
680
  <span class="mfm-header-label">Theme</span>
672
681
  <UIInfoPopover title="Theme" ariaLabel="About the theme">
673
682
  <p>
674
- A <strong>theme</strong> is a whole look in one file: the colors and type plus a setting for every component you changed.
683
+ A <strong>theme</strong> is a whole look in one file: the colors and type plus a setting for every component.
675
684
  </p>
676
685
  <p>
677
686
  It holds its own copy of that data, so the theme you open is the whole look, and one theme can never break another.
@@ -680,13 +689,13 @@
680
689
  <strong>Load</strong> opens the list. Picking a theme shows it on the page as a preview, so you can try each look with nothing written to disk. Pick another to compare, or <strong>Cancel</strong> to go back to where you were.
681
690
  </p>
682
691
  <p>
683
- <strong>Save</strong> opens and adopts the previewed theme: the editor works on it from then on and production ships it immediately. Components it does not carry go back to their defaults. Previewing and cancelling never change what your site ships.
692
+ <strong>Save</strong> opens and adopts the previewed theme: the editor works on it from then on and production ships it immediately. Previewing and cancelling never change what your site ships.
684
693
  </p>
685
694
  <p>
686
695
  <strong>Colors and type only</strong> in that window takes the palette and the fonts and leaves your shapes and component settings alone.
687
696
  </p>
688
697
  <p>
689
- The <strong>active</strong> theme is the one the editor has open. <strong>Adopt</strong> saves it and ships it to production, colors and type plus every component you changed. The line under the name says whether production is running this theme.
698
+ The <strong>active</strong> theme is the one the editor has open. <strong>Adopt</strong> saves it and ships it to production, colors and type plus every component. The line under the name says whether production is running this theme.
690
699
  </p>
691
700
  <p>
692
701
  If components have unsaved edits, Save and Adopt offer to save all of them before continuing. You can cancel to review or save components individually.
@@ -3,10 +3,18 @@
3
3
  checked?: boolean;
4
4
  disabled?: boolean;
5
5
  label?: string;
6
+ /** Put the label before the switch, for rows that align to a right edge. */
7
+ labelFirst?: boolean;
6
8
  onchange?: (checked: boolean) => void;
7
9
  }
8
10
 
9
- let { checked = $bindable(false), disabled = false, label = '', onchange }: Props = $props();
11
+ let {
12
+ checked = $bindable(false),
13
+ disabled = false,
14
+ label = '',
15
+ labelFirst = false,
16
+ onchange,
17
+ }: Props = $props();
10
18
 
11
19
  function toggle() {
12
20
  if (disabled) return;
@@ -15,7 +23,7 @@
15
23
  }
16
24
  </script>
17
25
 
18
- <label class="toggle" class:disabled>
26
+ <label class="toggle" class:disabled class:label-first={labelFirst}>
19
27
  <button
20
28
  type="button"
21
29
  role="switch"
@@ -37,24 +45,28 @@
37
45
  .toggle {
38
46
  display: inline-flex;
39
47
  align-items: center;
40
- gap: var(--space-8);
48
+ gap: var(--ui-space-8);
41
49
  cursor: pointer;
42
50
  user-select: none;
43
51
 
52
+ &.label-first {
53
+ flex-direction: row-reverse;
54
+ }
55
+
44
56
  &.disabled {
45
57
  cursor: not-allowed;
46
58
 
47
59
  .toggle-track {
48
- background: var(--surface-neutral-lower);
49
- border-color: var(--border-neutral-faint);
60
+ background: var(--ui-surface-lower);
61
+ border-color: var(--ui-border-low);
50
62
  }
51
63
 
52
64
  .toggle-thumb {
53
- background: var(--text-disabled);
65
+ background: var(--ui-text-disabled);
54
66
  }
55
67
 
56
68
  .toggle-label {
57
- color: var(--text-disabled);
69
+ color: var(--ui-text-disabled);
58
70
  }
59
71
  }
60
72
  }
@@ -62,13 +74,13 @@
62
74
  .toggle-track {
63
75
  position: relative;
64
76
  width: 2.25rem;
65
- height: var(--space-20);
66
- border-radius: var(--radius-2xl);
67
- border: var(--border-width-1) solid var(--border-neutral);
68
- background: var(--surface-neutral-low);
77
+ height: var(--ui-space-20);
78
+ border-radius: var(--ui-radius-2xl);
79
+ border: 1px solid var(--ui-border);
80
+ background: var(--ui-surface-low);
69
81
  padding: 0;
70
82
  cursor: inherit;
71
- transition: background var(--duration-150), border-color var(--duration-150);
83
+ transition: background var(--ui-transition-fast), border-color var(--ui-transition-fast);
72
84
  flex-shrink: 0;
73
85
 
74
86
  &.on {
@@ -77,34 +89,34 @@
77
89
  }
78
90
 
79
91
  &:hover:not(:disabled) {
80
- border-color: var(--border-neutral-medium);
92
+ border-color: var(--ui-border-high);
81
93
  }
82
94
 
83
95
  &:focus-visible {
84
- outline: var(--border-width-2) solid var(--border-brand);
85
- outline-offset: var(--space-2);
96
+ outline: 2px solid var(--ui-text-primary);
97
+ outline-offset: var(--ui-space-2);
86
98
  }
87
99
  }
88
100
 
89
101
  .toggle-thumb {
90
102
  position: absolute;
91
- top: var(--space-2);
92
- left: var(--space-2);
103
+ top: var(--ui-space-2);
104
+ left: var(--ui-space-2);
93
105
  width: 0.875rem;
94
106
  height: 0.875rem;
95
- border-radius: var(--radius-full);
96
- background: var(--text-secondary);
97
- transition: transform var(--duration-150), background var(--duration-150);
107
+ border-radius: var(--ui-radius-full);
108
+ background: var(--ui-text-secondary);
109
+ transition: transform var(--ui-transition-fast), background var(--ui-transition-fast);
98
110
 
99
111
  .on & {
100
- transform: translateX(var(--space-16));
101
- background: var(--text-primary);
112
+ transform: translateX(var(--ui-space-16));
113
+ background: var(--ui-text-primary);
102
114
  }
103
115
  }
104
116
 
105
117
  .toggle-label {
106
- font-size: var(--font-size-md);
107
- color: var(--text-secondary);
118
+ font-size: var(--ui-font-size-md);
119
+ color: var(--ui-text-secondary);
108
120
  line-height: 1;
109
121
  }
110
122
  </style>
@@ -115,7 +115,7 @@
115
115
  .ui-pill[aria-disabled='true'] {
116
116
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.10) 100%);
117
117
  border-color: rgba(255, 255, 255, 0.22);
118
- color: var(--ui-text-muted, #4d4d4d);
118
+ color: var(--ui-text-disabled, #333333);
119
119
  cursor: not-allowed;
120
120
  pointer-events: none;
121
121
  }