@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
@@ -0,0 +1,47 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import { slide } from 'svelte/transition';
4
+ import { cubicOut } from 'svelte/easing';
5
+
6
+ /**
7
+ * Disclosure wrapper for in-flow expandable sections: the pane opens like a
8
+ * window while its content comes forward through it. Both moves share one
9
+ * clock and one easing so they read as a single gesture; the content is
10
+ * clipped by the opening pane for the first frames, which is the point.
11
+ *
12
+ * For sections only. Popovers, menus and dialogs are floating layers with
13
+ * their own motion, and subgrid detail rows (UIPaddingSelector,
14
+ * UIPaletteSelector) cannot take a wrapper element without losing their
15
+ * placement in the parent grid.
16
+ */
17
+ interface Props {
18
+ open: boolean;
19
+ /** Placement for the outer element when the section is itself a grid item. */
20
+ style?: string;
21
+ duration?: number;
22
+ children: Snippet;
23
+ }
24
+
25
+ let { open, style = undefined, duration = 260, children }: Props = $props();
26
+
27
+ const reduceMotion = typeof window !== 'undefined'
28
+ && window.matchMedia?.('(prefers-reduced-motion: reduce)').matches === true;
29
+
30
+ let ms = $derived(reduceMotion ? 0 : duration);
31
+
32
+ function approach(_node: Element, { duration }: { duration: number }) {
33
+ return {
34
+ duration,
35
+ easing: cubicOut,
36
+ css: (u: number) => `opacity: ${u}; transform: scale(${0.95 + u * 0.05})`
37
+ };
38
+ }
39
+ </script>
40
+
41
+ {#if open}
42
+ <div {style} transition:slide|local={{ duration: ms, easing: cubicOut }}>
43
+ <div transition:approach|local={{ duration: ms }}>
44
+ {@render children()}
45
+ </div>
46
+ </div>
47
+ {/if}
@@ -92,7 +92,7 @@
92
92
  .ui-sq[aria-disabled='true'] {
93
93
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.10) 100%);
94
94
  border-color: rgba(255, 255, 255, 0.22);
95
- color: var(--ui-text-muted);
95
+ color: var(--ui-text-disabled);
96
96
  cursor: not-allowed;
97
97
  pointer-events: none;
98
98
  }
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import { oklchToHexClamped } from '../../core/palettes/oklch';
2
+ import { cssColorToOklch, oklchToHexClamped } from '../../core/palettes/oklch';
3
3
  import { palettesToVars } from '../../core/palettes/paletteDerivation';
4
4
  import { contrastRatio } from '../../core/palettes/contrast';
5
5
  import type { PaletteConfig } from '../../core/themes/themeTypes';
@@ -57,9 +57,15 @@
57
57
 
58
58
  // Ratios are measured against the DISPLAYED field — the Canvas seed —
59
59
  // so the numbers always describe what the story shows.
60
+ // Derived vars serialize as `oklch()`; contrastRatio is sRGB-terminated.
61
+ function varHex(name: string): string | null {
62
+ const parsed = cssColorToOklch(vars[name] ?? '');
63
+ return parsed ? oklchToHexClamped(parsed.l, parsed.c, parsed.h) : null;
64
+ }
65
+
60
66
  function ratioOnBg(textVar: string): number | null {
61
- const text = vars[textVar];
62
- return typeof text === 'string' ? contrastRatio(text, seedHex('Canvas')) : null;
67
+ const text = varHex(textVar);
68
+ return text === null ? null : contrastRatio(text, seedHex('Canvas'));
63
69
  }
64
70
 
65
71
  // Floor, don't round: the readout must never overstate a contrast ratio.
@@ -72,11 +78,9 @@
72
78
  // mid-lightness primary makes this pairing inherently low-contrast — the
73
79
  // readout surfaces that rather than hiding the pill.
74
80
  let invertedRatio = $derived.by(() => {
75
- const inverted = vars['--text-inverted'];
76
- const primary = vars['--text-primary'];
77
- return typeof inverted === 'string' && typeof primary === 'string'
78
- ? contrastRatio(inverted, primary)
79
- : null;
81
+ const inverted = varHex('--text-inverted');
82
+ const primary = varHex('--text-primary');
83
+ return inverted !== null && primary !== null ? contrastRatio(inverted, primary) : null;
80
84
  });
81
85
  </script>
82
86
 
@@ -153,8 +153,9 @@
153
153
  <div class="colors-tab">
154
154
  <div class="pane">
155
155
  <section id="colors-wheel" class="block">
156
- <header class="block-head">
156
+ <header class="block-head head-inline">
157
157
  <h2 class="title">Color Wheel</h2>
158
+ <PaletteJumpButton family={selected} displayLabel={selectedSpec.displayLabel} target="tokens" />
158
159
  </header>
159
160
 
160
161
  <div class="wheel-hero">
@@ -309,9 +310,8 @@
309
310
  </section>
310
311
 
311
312
  <section id="colors-selected" class="block">
312
- <header class="block-head head-row">
313
+ <header class="block-head">
313
314
  <h2 class="title">Palette <span class="mode-name">&middot; {selectedSpec.displayLabel ?? selected}</span></h2>
314
- <PaletteJumpButton family={selected} displayLabel={selectedSpec.displayLabel} target="tokens" />
315
315
  </header>
316
316
 
317
317
  <div class="group">
@@ -385,10 +385,9 @@
385
385
  gap: var(--ui-space-2);
386
386
  }
387
387
 
388
- .block-head.head-row {
388
+ .block-head.head-inline {
389
389
  flex-direction: row;
390
390
  align-items: center;
391
- justify-content: space-between;
392
391
  gap: var(--ui-space-12);
393
392
  }
394
393
 
@@ -12,7 +12,8 @@ export interface CurveConfig {
12
12
  yMax: number;
13
13
  label: string;
14
14
  gridLines: number[];
15
- dashedLines: number[];
15
+ /** Suffix for the offset readout only. The axis range lives in `label`. */
16
+ unit?: string;
16
17
  }
17
18
 
18
19
  export interface CurveTemplate {
@@ -29,21 +30,27 @@ export const lightnessCurveConfig: CurveConfig = {
29
30
  yMin: 0, yMax: 100,
30
31
  label: 'Lightness',
31
32
  gridLines: [50],
32
- dashedLines: [25, 75],
33
33
  };
34
34
 
35
35
  export const saturationCurveConfig: CurveConfig = {
36
36
  yMin: 0, yMax: 200,
37
37
  label: 'Saturation',
38
38
  gridLines: [100],
39
- dashedLines: [50, 150],
40
39
  };
41
40
 
42
41
  export const textLightnessCurveConfig: CurveConfig = {
43
42
  yMin: 0, yMax: 200,
44
43
  label: 'Lightness',
45
44
  gridLines: [100],
46
- dashedLines: [50, 150],
45
+ };
46
+
47
+ // The range is written into `label` rather than derived, because it is the
48
+ // only config whose axis is not self-evident from its name (RJC 4).
49
+ export const hueCurveConfig: CurveConfig = {
50
+ yMin: -45, yMax: 45,
51
+ label: 'Hue ±45°',
52
+ unit: '°',
53
+ gridLines: [0],
47
54
  };
48
55
 
49
56
  export const curveTemplates: CurveTemplate[] = [
@@ -51,7 +58,8 @@ export const curveTemplates: CurveTemplate[] = [
51
58
  name: 'Flat',
52
59
  icon: 'M2,6 L18,6',
53
60
  anchors: (cfg) => {
54
- const mid = (cfg.yMin + cfg.yMax) / 2;
61
+ const range = cfg.yMax - cfg.yMin;
62
+ const mid = cfg.yMin + range / 2;
55
63
  return [
56
64
  { x: 0, y: mid, inDx: 0, inDy: 0, outDx: 30, outDy: 0 },
57
65
  { x: 100, y: mid, inDx: -30, inDy: 0, outDx: 0, outDy: 0 },
@@ -60,19 +68,23 @@ export const curveTemplates: CurveTemplate[] = [
60
68
  },
61
69
  {
62
70
  name: 'Peak',
63
- icon: 'M2,10 L10,2 L18,10',
64
- anchors: (cfg) => [
65
- { x: 0, y: cfg.yMin, inDx: 0, inDy: 0, outDx: 15, outDy: 0 },
66
- { x: 50, y: cfg.yMax / 2, inDx: -15, inDy: 0, outDx: 15, outDy: 0 },
67
- { x: 100, y: cfg.yMin, inDx: -15, inDy: 0, outDx: 0, outDy: 0 },
68
- ],
71
+ icon: 'M2,10 C4.4,10 7.6,2 10,2 C12.4,2 15.6,10 18,10',
72
+ anchors: (cfg) => {
73
+ const range = cfg.yMax - cfg.yMin;
74
+ return [
75
+ { x: 0, y: cfg.yMin, inDx: 0, inDy: 0, outDx: 15, outDy: 0 },
76
+ { x: 50, y: cfg.yMin + range / 2, inDx: -15, inDy: 0, outDx: 15, outDy: 0 },
77
+ { x: 100, y: cfg.yMin, inDx: -15, inDy: 0, outDx: 0, outDy: 0 },
78
+ ];
79
+ },
69
80
  },
70
81
  {
71
82
  name: 'Ramp up',
72
- icon: 'M2,10 L18,2',
83
+ icon: 'M2,10 C6.8,10 13.2,2 18,2',
73
84
  anchors: (cfg) => {
74
- const lo = cfg.yMax * 0.1;
75
- const hi = cfg.yMax * 0.9;
85
+ const range = cfg.yMax - cfg.yMin;
86
+ const lo = cfg.yMin + range * 0.1;
87
+ const hi = cfg.yMin + range * 0.9;
76
88
  return [
77
89
  { x: 0, y: lo, inDx: 0, inDy: 0, outDx: 30, outDy: 0 },
78
90
  { x: 100, y: hi, inDx: -30, inDy: 0, outDx: 0, outDy: 0 },
@@ -81,10 +93,11 @@ export const curveTemplates: CurveTemplate[] = [
81
93
  },
82
94
  {
83
95
  name: 'Ramp down',
84
- icon: 'M2,2 L18,10',
96
+ icon: 'M2,2 C6.8,2 13.2,10 18,10',
85
97
  anchors: (cfg) => {
86
- const lo = cfg.yMax * 0.1;
87
- const hi = cfg.yMax * 0.9;
98
+ const range = cfg.yMax - cfg.yMin;
99
+ const lo = cfg.yMin + range * 0.1;
100
+ const hi = cfg.yMin + range * 0.9;
88
101
  return [
89
102
  { x: 0, y: hi, inDx: 0, inDy: 0, outDx: 30, outDy: 0 },
90
103
  { x: 100, y: lo, inDx: -30, inDy: 0, outDx: 0, outDy: 0 },
@@ -145,10 +158,58 @@ export function tangentAnchor(
145
158
  return { x, y, inDx, inDy: m * inDx, outDx, outDy: m * outDx };
146
159
  }
147
160
 
161
+ /** Re-derive one anchor's tangents from its current neighbours. Handles are stored,
162
+ * not computed, so an anchor the user cannot drag keeps whatever slope the curve had
163
+ * when it was placed. */
164
+ export function resmoothAnchor(anchors: CurveAnchor[], index: number): CurveAnchor[] {
165
+ const a = anchors[index];
166
+ if (!a) return anchors;
167
+ const out = [...anchors];
168
+ out[index] = tangentAnchor(a.x, a.y, anchors[index - 1] ?? null, anchors[index + 1] ?? null);
169
+ return out;
170
+ }
171
+
148
172
  export function isCornerAnchor(a: CurveAnchor): boolean {
149
173
  return a.inDx === 0 && a.inDy === 0 && a.outDx === 0 && a.outDy === 0;
150
174
  }
151
175
 
176
+ /** Sampled-y agreement below this counts as the same curve. Saved handles round
177
+ * to two decimals, so an exact compare would read every round-tripped curve as
178
+ * hand-edited. */
179
+ const AUTO_EPSILON = 0.05;
180
+
181
+ const AUTO_SAMPLES = 25;
182
+
183
+ /** Re-derive every anchor's tangents from its neighbours. Corner anchors are the
184
+ * per-anchor opt-out and keep their zero handles; their neighbours still smooth
185
+ * into them, because a tangent reads a neighbour's position, not its handles. */
186
+ export function resmoothAutoCurve(anchors: CurveAnchor[]): CurveAnchor[] {
187
+ if (anchors.length < 2) return anchors;
188
+ return anchors.map((a, i) =>
189
+ isCornerAnchor(a)
190
+ ? a
191
+ : tangentAnchor(a.x, a.y, anchors[i - 1] ?? null, anchors[i + 1] ?? null),
192
+ );
193
+ }
194
+
195
+ /**
196
+ * Would switching auto smoothing on leave the curve where it is?
197
+ *
198
+ * Compares sampled y rather than handle values, because more than one handle
199
+ * pair draws the same path: a flat run with handles at 30 and one at the derived
200
+ * 33.33 are the same line. Curves saved before the flag existed carry their auto
201
+ * state in their shape alone, so this doubles as the read fallback for them.
202
+ */
203
+ export function isAutoSmoothCurve(anchors: CurveAnchor[]): boolean {
204
+ if (anchors.length < 2) return true;
205
+ const auto = resmoothAutoCurve(anchors);
206
+ for (let i = 0; i <= AUTO_SAMPLES; i++) {
207
+ const x = (i / AUTO_SAMPLES) * 100;
208
+ if (Math.abs(sampleCurve(anchors, x) - sampleCurve(auto, x)) >= AUTO_EPSILON) return false;
209
+ }
210
+ return true;
211
+ }
212
+
152
213
  export function curveXToSvg(v: number, w: number, padX: number = 0): number {
153
214
  return padX + (v / 100) * (w - 2 * padX);
154
215
  }
@@ -212,21 +273,40 @@ export function sampleCurve(anchors: CurveAnchor[], xPos: number): number {
212
273
 
213
274
  const CLIPBOARD_PREFIX = 'mp-curve:';
214
275
 
215
- export function serializeCurve(anchors: CurveAnchor[], offset: number): string {
216
- return CLIPBOARD_PREFIX + JSON.stringify({ anchors, offset });
276
+ export function serializeCurve(anchors: CurveAnchor[], offset: number, autoSmooth: boolean): string {
277
+ return CLIPBOARD_PREFIX + JSON.stringify({ anchors, offset, autoSmooth });
217
278
  }
218
279
 
219
- export function deserializeCurve(text: string): { anchors: CurveAnchor[]; offset: number } | null {
280
+ export function deserializeCurve(
281
+ text: string,
282
+ ): { anchors: CurveAnchor[]; offset: number; autoSmooth: boolean } | null {
220
283
  if (!text.startsWith(CLIPBOARD_PREFIX)) return null;
221
284
  try {
222
285
  const data = JSON.parse(text.slice(CLIPBOARD_PREFIX.length));
223
286
  if (!Array.isArray(data.anchors) || typeof data.offset !== 'number') return null;
224
- return data;
287
+ // Payloads copied before the flag existed carry their auto state in the shape.
288
+ const autoSmooth = typeof data.autoSmooth === 'boolean'
289
+ ? data.autoSmooth
290
+ : isAutoSmoothCurve(data.anchors);
291
+ return { anchors: data.anchors, offset: data.offset, autoSmooth };
225
292
  } catch {
226
293
  return null;
227
294
  }
228
295
  }
229
296
 
297
+ /** Pasted anchors come from another curve's axis (the clipboard is
298
+ * deliberately cross-editor), so they can carry y values this axis never
299
+ * produces on its own: `svgToY` clamps every drag, but a paste never touches
300
+ * it. Clamp the anchor y and each handle's absolute y (not just its delta)
301
+ * so a pasted curve cannot bulge past the axis between anchors either. */
302
+ export function clampAnchorsToRange(anchors: CurveAnchor[], cfg: CurveConfig): CurveAnchor[] {
303
+ const bound = (v: number) => Math.max(cfg.yMin, Math.min(cfg.yMax, v));
304
+ return anchors.map((a) => {
305
+ const y = bound(a.y);
306
+ return { ...a, y, inDy: bound(a.y + a.inDy) - y, outDy: bound(a.y + a.outDy) - y };
307
+ });
308
+ }
309
+
230
310
  export function buildCurvePath(anchors: CurveAnchor[], cfg: CurveConfig, w: number, padX: number = 0): string {
231
311
  if (anchors.length < 2) return '';
232
312
  let d = `M${curveXToSvg(anchors[0].x, w, padX)},${curveYToSvg(anchors[0].y, cfg)}`;
@@ -1,8 +1,10 @@
1
1
  <script lang="ts">
2
2
  import ScaleCurveEditor from './ScaleCurveEditor.svelte';
3
3
  import UIPillButton from '../UIPillButton.svelte';
4
- import { type CurveAnchor, lightnessCurveConfig, saturationCurveConfig, textLightnessCurveConfig } from '../curveEngine';
4
+ import UIReveal from '../UIReveal.svelte';
5
+ import { type CurveAnchor, lightnessCurveConfig, saturationCurveConfig, textLightnessCurveConfig, hueCurveConfig } from '../curveEngine';
5
6
  import { scaleToCssVar } from '../../core/palettes/paletteDerivation';
7
+ import { DEFAULT_PALETTE_HUE } from './paletteMath';
6
8
  import type { Oklch } from '../../core/palettes/oklch';
7
9
 
8
10
  /**
@@ -29,7 +31,7 @@
29
31
  steps: Step[];
30
32
  }
31
33
 
32
- type Channel = 'lightness' | 'saturation';
34
+ type Channel = 'lightness' | 'saturation' | 'hue';
33
35
 
34
36
  interface ScaleCurveDef {
35
37
  lightness: () => CurveAnchor[];
@@ -48,8 +50,9 @@
48
50
  snapped: boolean;
49
51
  supportsSnap: boolean;
50
52
  cssNamespace: string | null;
51
- scaleCurves: Record<string, { lightness: CurveAnchor[]; saturation: CurveAnchor[] }>;
53
+ scaleCurves: Record<string, { lightness: CurveAnchor[]; saturation: CurveAnchor[]; hue?: CurveAnchor[] }>;
52
54
  curveOffset: Record<string, number>;
55
+ curveAutoSmooth: Record<string, boolean | undefined>;
53
56
  defaultScaleCurves: Record<string, ScaleCurveDef>;
54
57
  overrides: Record<string, string>;
55
58
  editingKey: string | null;
@@ -72,6 +75,9 @@
72
75
  onCopyVarName: (key: string, varName: string, event?: MouseEvent) => void;
73
76
  onSetScaleCurve: (scaleTitle: string, channel: Channel, anchors: CurveAnchor[]) => void;
74
77
  onOffsetChange: (key: string, value: number) => void;
78
+ onAutoSmoothChange: (key: string, value: boolean) => void;
79
+ sectionOpen: (key: string) => boolean;
80
+ onToggleCurveSection: (key: string) => void;
75
81
  }
76
82
 
77
83
  let {
@@ -82,6 +88,7 @@
82
88
  cssNamespace,
83
89
  scaleCurves,
84
90
  curveOffset,
91
+ curveAutoSmooth,
85
92
  defaultScaleCurves,
86
93
  overrides,
87
94
  editingKey,
@@ -103,7 +110,10 @@
103
110
  onCopyHex,
104
111
  onCopyVarName,
105
112
  onSetScaleCurve,
106
- onOffsetChange
113
+ onOffsetChange,
114
+ onAutoSmoothChange,
115
+ sectionOpen,
116
+ onToggleCurveSection
107
117
  }: Props = $props();
108
118
 
109
119
  interface CurveDescriptor {
@@ -120,8 +130,9 @@
120
130
  const defs = defaultScaleCurves[scale.title];
121
131
  if (!sc || !defs) return [];
122
132
  return [
123
- { key: scaleCurveKeyFor(scale.title, 'lightness'), anchors: sc.lightness, cfg: lightnessCfg, defaults: defs.lightness(), channel: 'lightness' },
133
+ { key: scaleCurveKeyFor(scale.title, 'hue'), anchors: sc.hue ?? DEFAULT_PALETTE_HUE(), cfg: hueCurveConfig, defaults: DEFAULT_PALETTE_HUE(), channel: 'hue' },
124
134
  { key: scaleCurveKeyFor(scale.title, 'saturation'), anchors: sc.saturation, cfg: saturationCurveConfig, defaults: defs.saturation(), channel: 'saturation' },
135
+ { key: scaleCurveKeyFor(scale.title, 'lightness'), anchors: sc.lightness, cfg: lightnessCfg, defaults: defs.lightness(), channel: 'lightness' },
125
136
  ];
126
137
  })());
127
138
  </script>
@@ -245,8 +256,8 @@
245
256
  >{copiedKey === k ? 'copied!' : hex}</button>
246
257
  </div>
247
258
  {/each}
248
- {#if editorOpen}
249
- <div class="curve-grid-span" style="grid-column: 1 / -1">
259
+ <UIReveal open={editorOpen} style="grid-column: 1 / -1">
260
+ <div class="curve-grid-span">
250
261
  {#each curveDescriptors as curve (curve.key)}
251
262
  <ScaleCurveEditor
252
263
  curveKey={curve.key}
@@ -255,12 +266,16 @@
255
266
  stepCount={scale.steps.length}
256
267
  defaults={curve.defaults}
257
268
  offset={curveOffset[curve.key] ?? 0}
269
+ autoSmooth={curveAutoSmooth[curve.key]}
270
+ open={sectionOpen(curve.key)}
271
+ onToggleOpen={() => onToggleCurveSection(curve.key)}
258
272
  onAnchorsChange={(a) => onSetScaleCurve(scale.title, curve.channel, a)}
259
273
  onOffsetChange={onOffsetChange}
274
+ onAutoSmoothChange={onAutoSmoothChange}
260
275
  />
261
276
  {/each}
262
277
  </div>
263
- {/if}
278
+ </UIReveal>
264
279
  </div>
265
280
  </div>
266
281
 
@@ -1,74 +1,38 @@
1
1
  <script lang="ts">
2
- import ColorEditPanel from '../ColorEditPanel.svelte';
3
- import Toggle from '../Toggle.svelte';
4
- import { beginSliderGesture } from '../../core/store/editorStore';
2
+ import type { Snippet } from 'svelte';
5
3
  import { oklchToHexClamped, type Oklch } from '../../core/palettes/oklch';
6
4
 
7
- // Full sRGB chroma range (gamutClamp trims per hue/lightness). Neutrals default
8
- // low but are not capped; their calm character comes from defaults, not a ceiling.
9
- const CHROMA_MAX = 0.4;
10
- // Where a typical neutral's chroma sits, marked on the slider as a soft nudge.
11
- const NEUTRAL_CALM_CHROMA = 0.05;
12
-
13
-
14
-
15
-
16
5
  interface Props {
17
6
  /**
18
- * The header swatch + label + base-hex + (when active) the OKLCH ColorEditPanel
19
- * for editing the palette's base colour. The picker edits hue/chroma/lightness
20
- * and maps them straight to the base hex. `neutral` only nudges the picker
21
- * (a calm-chroma hint on the slider); it does not change behaviour.
22
- *
23
- * State (`editing`, scope handle) is owned by the parent — this component
24
- * fires callbacks (`onStartEdit`, `onConfirm`, `onCancel`, etc.).
7
+ * The header band: swatch, label, base hex, and the palette's actions on the
8
+ * right. The base-colour picker itself is rendered by the parent below this
9
+ * band so it can line up with the curve editors.
25
10
  */
26
11
  label: string;
27
12
  displayLabel?: string | null;
28
- neutral?: boolean;
29
13
  baseColor: Oklch;
30
- anchorToBase: boolean;
31
- /** Palette step label ('500', '850', …) the base color is placed at; null while off or unplaced. */
32
- anchorStepLabel?: string | null;
33
14
  isEditingBase: boolean;
34
- panelOpen: boolean;
35
- /** Keep the panel open in live-apply mode (no confirm/cancel session) while the curve editors are visible. */
15
+ /** Keep the swatch reading as active while the curve editors are visible. */
36
16
  pinnedOpen?: boolean;
37
- editingColor: Oklch | null;
38
- editPanelTitle: string | null;
39
17
  copiedKey: string | null;
40
18
  onStartEdit: () => void;
41
- onConfirm: () => void;
42
- onCancel: () => void;
43
- onBaseChange: (hue: number, chroma: number, lightness: number) => void;
44
- onAnchorToBaseChange: (next: boolean) => void;
45
19
  onCopyBaseHex: (key: string, hex: string, event?: MouseEvent) => void;
20
+ actions?: Snippet;
46
21
  }
47
22
 
48
23
  let {
49
24
  label,
50
25
  displayLabel = null,
51
- neutral = false,
52
26
  baseColor,
53
- anchorToBase,
54
- anchorStepLabel = null,
55
27
  isEditingBase,
56
- panelOpen,
57
28
  pinnedOpen = false,
58
- editingColor,
59
- editPanelTitle,
60
29
  copiedKey,
61
30
  onStartEdit,
62
- onConfirm,
63
- onCancel,
64
- onBaseChange,
65
- onAnchorToBaseChange,
66
- onCopyBaseHex
31
+ onCopyBaseHex,
32
+ actions
67
33
  }: Props = $props();
68
34
 
69
- let baseOklch = $derived(baseColor);
70
35
  let baseHex = $derived(oklchToHexClamped(baseColor.l, baseColor.c, baseColor.h));
71
- let pickerChromaHint = $derived(neutral ? NEUTRAL_CALM_CHROMA : undefined);
72
36
  </script>
73
37
 
74
38
  <div class="editor-top">
@@ -103,42 +67,18 @@
103
67
  </div>
104
68
  </div>
105
69
 
106
- {#if pinnedOpen || (isEditingBase && panelOpen && editingColor)}
107
- <div class="editor-controls">
108
- <ColorEditPanel
109
- title={isEditingBase ? editPanelTitle : 'Base Color'}
110
- showRemoveOverride={false}
111
- hideActions={!isEditingBase}
112
- hidePreview
113
- hue={baseOklch.h}
114
- chroma={baseOklch.c}
115
- lightness={baseOklch.l * 100}
116
- chromaMax={CHROMA_MAX}
117
- chromaHint={pickerChromaHint}
118
- onHueChromaChange={onBaseChange}
119
- onConfirm={onConfirm}
120
- onCancel={onCancel}
121
- onRemoveOverride={() => {}}
122
- onSliderStart={() => beginSliderGesture(`edit ${label} base`)}
123
- >
124
- {#snippet actions()}
125
- <Toggle
126
- checked={anchorToBase}
127
- onchange={(v) => onAnchorToBaseChange(v ?? !anchorToBase)}
128
- label={anchorStepLabel ? `Base color placed at ${anchorStepLabel}` : 'Place base color in palette'}
129
- />
130
- {/snippet}
131
- </ColorEditPanel>
132
- </div>
70
+ {#if actions}
71
+ <div class="header-actions">{@render actions()}</div>
133
72
  {/if}
134
73
  </div>
135
74
 
136
75
  <style>
137
- /* Identity and controls read as one band: the sliders sit beside the swatch
138
- rather than under it, which is what leaves the palette below its height. */
76
+ /* Identity on the left, actions on the right: close and reset sit where a
77
+ panel's controls are expected, at the top-right of the band they close. */
139
78
  .editor-top {
140
79
  display: flex;
141
80
  align-items: flex-start;
81
+ justify-content: space-between;
142
82
  gap: var(--ui-space-16);
143
83
  flex-wrap: wrap;
144
84
  }
@@ -157,11 +97,10 @@
157
97
  gap: var(--ui-space-2);
158
98
  }
159
99
 
160
- /* Basis, not width: the panel takes the rest of the row and drops below only
161
- when it can't hold that much. */
162
- .editor-controls {
163
- flex: 1 1 26rem;
164
- min-width: 0;
100
+ .header-actions {
101
+ display: flex;
102
+ align-items: center;
103
+ gap: var(--ui-space-8);
165
104
  }
166
105
 
167
106
  .header-swatch {
@@ -12,12 +12,12 @@
12
12
  let { family, displayLabel = null, target }: Props = $props();
13
13
 
14
14
  let name = $derived(displayLabel ?? family);
15
- let icon = $derived(target === 'wheel' ? 'fa-palette' : 'fa-sliders');
16
- let label = $derived(target === 'wheel' ? 'Wheel' : 'Edit');
15
+ let icon = $derived(target === 'wheel' ? 'fa-palette' : 'fa-chart-line');
16
+ let label = $derived(target === 'wheel' ? 'Wheel' : 'Graph View');
17
17
  let title = $derived(
18
18
  target === 'wheel'
19
19
  ? `Open ${name} on the color wheel`
20
- : `Edit the ${name} palette in Tokens`
20
+ : `Open the ${name} palette in the graph view`
21
21
  );
22
22
 
23
23
  function jump() {