@motion-proto/live-tokens 0.40.1 → 0.41.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 (89) hide show
  1. package/CHANGELOG.md +105 -0
  2. package/dist-plugin/{chunk-D77VD4Z6.js → chunk-H4TRUINI.js} +102 -13
  3. package/dist-plugin/index.cjs +288 -67
  4. package/dist-plugin/index.js +171 -55
  5. package/dist-plugin/tokensCssMigrations/index.cjs +102 -13
  6. package/dist-plugin/tokensCssMigrations/index.js +1 -1
  7. package/package.json +3 -2
  8. package/src/app/site.css +97 -20
  9. package/src/editor/core/palettes/colorHarmony.ts +228 -0
  10. package/src/editor/core/palettes/contrast.ts +128 -0
  11. package/src/editor/core/palettes/oklch.ts +8 -0
  12. package/src/editor/core/palettes/paletteDerivation.ts +267 -72
  13. package/src/editor/core/palettes/recommendText.ts +216 -0
  14. package/src/editor/core/palettes/solveTextContrast.ts +251 -0
  15. package/src/editor/core/store/editorCore.ts +2 -1
  16. package/src/editor/core/store/editorPersistence.ts +18 -1
  17. package/src/editor/core/store/editorStore.ts +20 -1
  18. package/src/editor/core/store/editorTypes.ts +4 -0
  19. package/src/editor/core/store/editorViewStore.ts +7 -3
  20. package/src/editor/core/themes/migrations/2026-06-05-palette-unification.ts +11 -9
  21. package/src/editor/core/themes/migrations/2026-07-21-palette-oklch-basis.ts +51 -0
  22. package/src/editor/core/themes/migrations/2026-07-24-base-anchor-placement.ts +37 -0
  23. package/src/editor/core/themes/migrations/2026-07-25-background-spot-to-base.ts +40 -0
  24. package/src/editor/core/themes/themeTypes.ts +23 -3
  25. package/src/editor/docs/CodeBlock.svelte +1 -1
  26. package/src/editor/docs/Docs.svelte +30 -13
  27. package/src/editor/pages/EditorShell.svelte +31 -3
  28. package/src/editor/ui/ColorEditPanel.svelte +22 -16
  29. package/src/editor/ui/EditorViewSwitcher.svelte +43 -9
  30. package/src/editor/ui/FontStackEditor.svelte +0 -1
  31. package/src/editor/ui/PaletteEditor.svelte +117 -155
  32. package/src/editor/ui/ProjectFontsSection.svelte +0 -3
  33. package/src/editor/ui/TextStylesSection.svelte +173 -0
  34. package/src/editor/ui/UILineHeightSelector.svelte +6 -5
  35. package/src/editor/ui/UIPaletteSelector.svelte +6 -1
  36. package/src/editor/ui/UITextTransformSelector.svelte +106 -0
  37. package/src/editor/ui/VariablesTab.svelte +23 -10
  38. package/src/editor/ui/colors/ColorReadouts.svelte +123 -0
  39. package/src/editor/ui/colors/ColorStory.svelte +375 -0
  40. package/src/editor/ui/colors/ColorWheel.svelte +740 -0
  41. package/src/editor/ui/colors/ColorsTab.svelte +508 -0
  42. package/src/editor/ui/colors/HarmonyAxesList.svelte +320 -0
  43. package/src/editor/ui/colors/LightnessBar.svelte +261 -0
  44. package/src/editor/ui/colors/PaletteStepStrip.svelte +142 -0
  45. package/src/editor/ui/colors/colorWheelMath.ts +9 -0
  46. package/src/editor/ui/colors/harmony-icons/analogous.svg +13 -0
  47. package/src/editor/ui/colors/harmony-icons/complementary.svg +10 -0
  48. package/src/editor/ui/colors/harmony-icons/compound.svg +15 -0
  49. package/src/editor/ui/colors/harmony-icons/custom.svg +10 -0
  50. package/src/editor/ui/colors/harmony-icons/monochromatic.svg +11 -0
  51. package/src/editor/ui/colors/harmony-icons/shades.svg +9 -0
  52. package/src/editor/ui/colors/harmony-icons/split-complementary.svg +13 -0
  53. package/src/editor/ui/colors/harmony-icons/square.svg +13 -0
  54. package/src/editor/ui/colors/harmony-icons/tetradic.svg +15 -0
  55. package/src/editor/ui/colors/harmony-icons/triadic.svg +13 -0
  56. package/src/editor/ui/colors/harmonyModeIcons.ts +23 -0
  57. package/src/editor/ui/colors/paletteBaseColor.ts +214 -0
  58. package/src/editor/ui/index.ts +0 -1
  59. package/src/editor/ui/palette/OverridesPanel.svelte +6 -3
  60. package/src/editor/ui/palette/PaletteBase.svelte +16 -8
  61. package/src/editor/ui/palette/dockMagnify.ts +22 -0
  62. package/src/editor/ui/palette/paletteEditorState.ts +5 -4
  63. package/src/editor/ui/palette/paletteMath.ts +93 -181
  64. package/src/editor/ui/sections/textStyles.ts +82 -0
  65. package/src/editor/ui/sections/tokenScales.ts +3 -3
  66. package/src/live-tokens/data/themes/default.json +3 -3
  67. package/src/live-tokens/data/tokens.generated.css +96 -95
  68. package/src/system/components/Badge.svelte +11 -11
  69. package/src/system/components/Button.svelte +7 -7
  70. package/src/system/components/Callout.svelte +8 -8
  71. package/src/system/components/Card.svelte +2 -2
  72. package/src/system/components/CodeSnippet.svelte +1 -1
  73. package/src/system/components/CollapsibleSection.svelte +7 -7
  74. package/src/system/components/CornerBadge.svelte +1 -1
  75. package/src/system/components/Dialog.svelte +2 -2
  76. package/src/system/components/FloatingTokenTags.css +5 -4
  77. package/src/system/components/Input.svelte +6 -6
  78. package/src/system/components/MenuSelect.svelte +4 -4
  79. package/src/system/components/Notification.svelte +8 -8
  80. package/src/system/components/ProgressBar.svelte +2 -2
  81. package/src/system/components/RadioButton.svelte +4 -4
  82. package/src/system/components/SectionDivider.svelte +6 -6
  83. package/src/system/components/SegmentedControl.svelte +5 -5
  84. package/src/system/components/SideNavigation.svelte +12 -12
  85. package/src/system/components/TabBar.svelte +4 -4
  86. package/src/system/components/Table.svelte +2 -2
  87. package/src/system/components/Tooltip.svelte +1 -1
  88. package/src/system/styles/tokens.css +59 -6
  89. package/src/editor/ui/TextTab.svelte +0 -203
package/CHANGELOG.md CHANGED
@@ -1,5 +1,110 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.41.0 — A Colors view, and semantic text styles
4
+
5
+ ### Added
6
+
7
+ - **Colors: a third editor view, next to Tokens and Components.** It has two
8
+ sections. **Wheel** is a saturation-radial harmony wheel where every color
9
+ family that participates in harmony sits on a rail, with external rotation
10
+ handles per family plus one global rotation handle, a lightness bar under the
11
+ wheel, and an Absolute Chroma toggle that governs whether radius reads as
12
+ absolute or relative chroma. Nine harmony modes (complementary,
13
+ split-complementary, triadic, tetradic, compound, square, analogous,
14
+ monochromatic, custom) are picked from a row of geometry icons that draw the
15
+ mode's actual axis layout. Two one-shot actions sit alongside: "Tint neutrals
16
+ from anchor" re-hues Neutral and Alternate to the anchor color while keeping
17
+ their own chroma and lightness, and "Derive accessible text" solves each
18
+ family's Text lightness curve so the derived text clears WCAG AA against the
19
+ surfaces it sits on. Both are a single undo.
20
+ - **Color Story: a proportional preview of the theme, built from seeds.** It
21
+ paints the seed base colors in their intended proportions rather than the
22
+ derived `--surface-*` tokens, so it tracks the wheel one-to-one, and it renders
23
+ the neutral text ladder (primary / secondary / tertiary) on each band with live
24
+ contrast readouts.
25
+ - **Suggested neutral text hierarchy.** Color Story proposes a text ladder
26
+ anchored on the current primary, deriving secondary and tertiary as two even
27
+ OKLCH-lightness drops toward the background: hierarchy first, with AA (4.5) as
28
+ a floor rather than the driver. The floor is solved against the adverse extreme
29
+ of the neutral surface band, so a compliant suggestion holds AA on every band
30
+ surface; when the seed's reachable lightness window cannot span the band, it
31
+ falls back to the default surface and reports the reduced coverage. Coverage
32
+ alerts are informational and never block. "Use suggested" writes the Neutral
33
+ Text curve; "Use black and white" is available as the blunt alternative.
34
+ - **Harmony runs on four fixed axes.** Anchor, Secondary, Tertiary and
35
+ Quaternary each own a hue whether or not a family is bound to them, and a new
36
+ Harmony axes list binds and unbinds families per axis. Neutral and Alternate
37
+ join Brand, Accent, Background and Special in the harmony-eligible pool.
38
+ Harmony rotates hue only: each palette keeps its own chroma and lightness.
39
+ - **Semantic text styles: a role layer over the type primitives.** Eight named
40
+ style bundles ship in `tokens.css` (`heading-xl/lg/md/sm`, `body-md/sm`,
41
+ `code`, `eyebrow`), each a set of per-axis aliases (`--heading-xl-font-family`,
42
+ `--heading-xl-font-size`, `-font-weight`, `-line-height`, `-letter-spacing`,
43
+ plus `--eyebrow-text-transform`). Every value aliases an existing primitive
44
+ scale, so editing a style re-points an alias rather than minting a raw value,
45
+ and the responsive size shrink carries through for free. Additive migration
46
+ `2026-07-20-semantic-text-styles` (`kind: 'additive'`) inserts the bundle block
47
+ into a consumer's vendored `tokens.css`.
48
+ - **Text Styles table in the editor.** Tokens → Typography gains a row per style
49
+ with pickers for family, size, weight, line-height and letter-spacing, plus a
50
+ text-transform picker on `eyebrow`, the one style that carries that axis.
51
+ `site.css` and the first-party surfaces consume the style layer instead of
52
+ re-declaring the same per-element type rules.
53
+
54
+ ### Changed (breaking)
55
+
56
+ - **The line-height scale is reshaped from size vocabulary to leading
57
+ vocabulary.** `--line-height-xs/sm/md/lg/xl` become
58
+ `--line-height-none/tightest/tighter/tight/normal/relaxed`
59
+ (1, 1.1, 1.25, 1.35, 1.5, 1.75). Old values map by ratio: `xs`→`none`,
60
+ `sm`→`tighter`, `md`→`normal`, `lg`→`relaxed`; `xl` (2) has no slot in the new
61
+ scale and is dropped. Line-height now names by effect, matching the
62
+ letter-spacing scale. Token names are public API, so this ships with the paired
63
+ migration `2026-07-20-line-height-rename` (`kind: 'breaking'`); a consumer
64
+ applies it via `npx live-tokens migrate`, which rewrites their vendored
65
+ `tokens.css` declarations and every `var()` reference.
66
+ - **Palette state is numeric OKLCH, not hex.** `PaletteConfig.baseColor` and
67
+ `overrides` change from hex strings to `{ l, c, h }`. The store holds the
68
+ user's unclamped intent and gamut clamping becomes projection-only, applied at
69
+ derivation output, canvas painting and CSS serialization. This removes the
70
+ hex round-trip that made wheel and slider gestures wobble. Theme migration
71
+ `2026-07-21-palette-oklch-basis` converts saved themes on load.
72
+ - **The base-color anchor can sit at any step.** The old "lock base color to
73
+ position 500" flag becomes `anchorPlacement`, which records the step it pins
74
+ and remembers the anchor it displaced, so moving or releasing the placement
75
+ restores what was there. Theme migration `2026-07-24-base-anchor-placement`
76
+ adopts the legacy locked-500 anchor.
77
+ - **The solid page background is the Background base color.** It used to be a
78
+ separately selected palette step (`emptyStep`), which is removed. Theme
79
+ migration `2026-07-25-background-spot-to-base` adopts the color the old spot
80
+ actually rendered, curves and overrides included, so a saved theme's page
81
+ renders identically. Gradient-mode configs are untouched.
82
+ - **`Theme.harmonyOrder` is superseded by `Theme.harmonyAxes`.** The old field is
83
+ still read when `harmonyAxes` is absent, and still written on save so older
84
+ builds keep loading the file.
85
+ - **Token names are otherwise unchanged.** The palette changes above are theme
86
+ schema changes, not `tokens.css` migrations, and every theme migration applies
87
+ automatically when a theme loads.
88
+
89
+ ### Removed
90
+
91
+ - `TextTab` (`src/editor/ui/TextTab.svelte`) and its re-export. It was never
92
+ mounted; the Text Styles table supersedes it.
93
+
94
+ ### Fixed
95
+
96
+ - The `2026-07-20-semantic-text-styles` migration set `--body-sm-line-height` to
97
+ `--line-height-normal` while the package default is `--line-height-tight`. A
98
+ migrating consumer now lands on the same value as a fresh install.
99
+ - Vitest snapshots (`**/__snapshots__/**`) are excluded from the published
100
+ tarball.
101
+
102
+ ### Migration
103
+
104
+ - Run `npx live-tokens migrate` to apply the two `tokens.css` migrations. The
105
+ line-height rename is `breaking` and never auto-applies, so it rides that
106
+ explicit command. Both are idempotent.
107
+
3
108
  ## 0.40.1 — Floating token-tag labels follow the theme
4
109
 
5
110
  ### Fixed
@@ -107,20 +107,9 @@ function escapeRe(s) {
107
107
  var tokensCssMigration_2026_05_29_typographyScaleAdditions = {
108
108
  id: "2026-05-29-typography-scale-additions",
109
109
  kind: "additive",
110
- description: "Add --line-height-{xs..xl}, --letter-spacing-* and --ease-out-quart scales",
110
+ description: "Add --letter-spacing-* and --ease-out-quart scales",
111
111
  apply(css) {
112
112
  let out = css;
113
- out = ensureScale(out, {
114
- sectionComment: "Line height (t-shirt scale)",
115
- anchorPrefixes: ["--line-height-", "--font-size-", "--font-weight-", "--font-"],
116
- entries: [
117
- { name: "--line-height-xs", value: "1" },
118
- { name: "--line-height-sm", value: "1.25" },
119
- { name: "--line-height-md", value: "1.5" },
120
- { name: "--line-height-lg", value: "1.75" },
121
- { name: "--line-height-xl", value: "2" }
122
- ]
123
- });
124
113
  out = ensureScale(out, {
125
114
  sectionComment: "Letter spacing",
126
115
  anchorPrefixes: ["--letter-spacing-", "--line-height-", "--font-size-", "--font-"],
@@ -263,6 +252,104 @@ var tokensCssMigration_2026_06_04_easingColorAndTypescaleAdditions = {
263
252
  }
264
253
  };
265
254
 
255
+ // vite-plugin/tokensCssMigrations/migrations/2026-07-20-line-height-rename.ts
256
+ var RENAMES = [
257
+ ["--line-height-xs", "--line-height-none"],
258
+ ["--line-height-sm", "--line-height-tighter"],
259
+ ["--line-height-md", "--line-height-normal"],
260
+ ["--line-height-lg", "--line-height-relaxed"]
261
+ ];
262
+ var SCALE = [
263
+ { name: "--line-height-none", value: "1" },
264
+ { name: "--line-height-tightest", value: "1.1" },
265
+ { name: "--line-height-tighter", value: "1.25" },
266
+ { name: "--line-height-tight", value: "1.35" },
267
+ { name: "--line-height-normal", value: "1.5" },
268
+ { name: "--line-height-relaxed", value: "1.75" }
269
+ ];
270
+ var tokensCssMigration_2026_07_20_lineHeightRename = {
271
+ id: "2026-07-20-line-height-rename",
272
+ kind: "breaking",
273
+ description: "Reshape --line-height-{xs..xl} to leading vocabulary (none/tightest/tighter/tight/normal/relaxed); retire the 2.0 slot",
274
+ apply(css) {
275
+ let out = css;
276
+ for (const [oldName, newName] of RENAMES) out = renameToken(out, oldName, newName);
277
+ out = removeToken(out, "--line-height-xl");
278
+ out = ensureScale(out, {
279
+ anchorPrefixes: ["--line-height-", "--font-size-", "--font-weight-", "--font-"],
280
+ entries: SCALE
281
+ });
282
+ return out;
283
+ }
284
+ };
285
+
286
+ // vite-plugin/tokensCssMigrations/migrations/2026-07-20-semantic-text-styles.ts
287
+ var BUNDLE = [
288
+ { name: "--heading-xl-font-family", value: "var(--font-display)" },
289
+ { name: "--heading-xl-font-size", value: "var(--font-size-4xl)" },
290
+ { name: "--heading-xl-font-weight", value: "var(--font-weight-semibold)" },
291
+ { name: "--heading-xl-line-height", value: "var(--line-height-tightest)" },
292
+ { name: "--heading-xl-letter-spacing", value: "var(--letter-spacing-normal)" },
293
+ { name: "--heading-lg-font-family", value: "var(--font-display)" },
294
+ { name: "--heading-lg-font-size", value: "var(--font-size-2xl)" },
295
+ { name: "--heading-lg-font-weight", value: "var(--font-weight-semibold)" },
296
+ { name: "--heading-lg-line-height", value: "var(--line-height-tightest)" },
297
+ { name: "--heading-lg-letter-spacing", value: "var(--letter-spacing-normal)" },
298
+ { name: "--heading-md-font-family", value: "var(--font-display)" },
299
+ { name: "--heading-md-font-size", value: "var(--font-size-xl)" },
300
+ { name: "--heading-md-font-weight", value: "var(--font-weight-semibold)" },
301
+ { name: "--heading-md-line-height", value: "var(--line-height-tighter)" },
302
+ { name: "--heading-md-letter-spacing", value: "var(--letter-spacing-normal)" },
303
+ { name: "--heading-sm-font-family", value: "var(--font-sans)" },
304
+ { name: "--heading-sm-font-size", value: "var(--font-size-lg)" },
305
+ { name: "--heading-sm-font-weight", value: "var(--font-weight-semibold)" },
306
+ { name: "--heading-sm-line-height", value: "var(--line-height-tighter)" },
307
+ { name: "--heading-sm-letter-spacing", value: "var(--letter-spacing-normal)" },
308
+ { name: "--body-md-font-family", value: "var(--font-sans)" },
309
+ { name: "--body-md-font-size", value: "var(--font-size-md)" },
310
+ { name: "--body-md-font-weight", value: "var(--font-weight-normal)" },
311
+ { name: "--body-md-line-height", value: "var(--line-height-normal)" },
312
+ { name: "--body-md-letter-spacing", value: "var(--letter-spacing-normal)" },
313
+ { name: "--body-sm-font-family", value: "var(--font-sans)" },
314
+ { name: "--body-sm-font-size", value: "var(--font-size-sm)" },
315
+ { name: "--body-sm-font-weight", value: "var(--font-weight-normal)" },
316
+ { name: "--body-sm-line-height", value: "var(--line-height-tight)" },
317
+ { name: "--body-sm-letter-spacing", value: "var(--letter-spacing-normal)" },
318
+ { name: "--code-font-family", value: "var(--font-mono)" },
319
+ { name: "--code-font-size", value: "var(--font-size-sm)" },
320
+ { name: "--code-font-weight", value: "var(--font-weight-normal)" },
321
+ { name: "--code-line-height", value: "var(--line-height-normal)" },
322
+ { name: "--code-letter-spacing", value: "var(--letter-spacing-normal)" },
323
+ { name: "--eyebrow-font-family", value: "var(--font-sans)" },
324
+ { name: "--eyebrow-font-size", value: "var(--font-size-sm)" },
325
+ { name: "--eyebrow-font-weight", value: "var(--font-weight-normal)" },
326
+ { name: "--eyebrow-line-height", value: "var(--line-height-normal)" },
327
+ { name: "--eyebrow-letter-spacing", value: "var(--letter-spacing-normal)" },
328
+ { name: "--eyebrow-text-transform", value: "none" }
329
+ ];
330
+ var tokensCssMigration_2026_07_20_semanticTextStyles = {
331
+ id: "2026-07-20-semantic-text-styles",
332
+ kind: "additive",
333
+ description: "Add the semantic text-style bundles (--heading-*/--body-*/--code-*/--eyebrow-*)",
334
+ apply(css) {
335
+ return ensureScale(css, {
336
+ sectionComment: "Text styles \u2014 semantic typography roles",
337
+ anchorPrefixes: [
338
+ "--eyebrow-",
339
+ "--code-",
340
+ "--body-",
341
+ "--heading-",
342
+ "--letter-spacing-",
343
+ "--line-height-",
344
+ "--font-weight-",
345
+ "--font-size-",
346
+ "--font-"
347
+ ],
348
+ entries: BUNDLE
349
+ });
350
+ }
351
+ };
352
+
266
353
  // vite-plugin/files/dataPaths.ts
267
354
  import fs from "fs";
268
355
  import path from "path";
@@ -315,7 +402,9 @@ var TOKENS_CSS_MIGRATIONS = [
315
402
  tokensCssMigration_2026_05_29_sectiondividerLegacyAxisCleanup,
316
403
  tokensCssMigration_2026_06_03_transformScaleAdditions,
317
404
  tokensCssMigration_2026_06_04_removeDeadSizeIconScale,
318
- tokensCssMigration_2026_06_04_easingColorAndTypescaleAdditions
405
+ tokensCssMigration_2026_06_04_easingColorAndTypescaleAdditions,
406
+ tokensCssMigration_2026_07_20_lineHeightRename,
407
+ tokensCssMigration_2026_07_20_semanticTextStyles
319
408
  ];
320
409
  function runTokensCssMigrations(css) {
321
410
  return foldMigrations(css, () => true);