@motion-proto/live-tokens 0.57.0 → 0.59.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-create-component/SKILL.md +13 -2
- package/.claude/skills/live-tokens-create-component/references/sketch-mode.md +202 -0
- package/.claude/skills/live-tokens-pick-component/SKILL.md +1 -1
- package/CHANGELOG.md +117 -0
- package/dist-plugin/generateColorsAndType/index.cjs +4 -3
- package/dist-plugin/generateColorsAndType/index.js +4 -3
- package/package.json +3 -3
- package/src/editor/component-editor/ImageLightboxEditor.svelte +11 -2
- package/src/editor/core/sketch/maskField.ts +10 -6
- package/src/editor/core/sketch/sketchLayer.ts +107 -29
- package/src/editor/core/sketch/sketchPresets.ts +34 -17
- package/src/editor/core/themes/parsers/shadow.ts +12 -4
- package/src/editor/docs/content/editing-tokens.md +2 -2
- package/src/editor/docs/content/sketch-mode.md +106 -12
- package/src/editor/docs/content.generated.ts +2 -2
- package/src/editor/ui/ColorEditPanel.svelte +13 -9
- package/src/editor/ui/EditorViewSwitcher.svelte +20 -20
- package/src/editor/ui/PaletteEditor.svelte +11 -3
- package/src/editor/ui/UIInlineEditActions.svelte +97 -0
- package/src/editor/ui/sketch/SketchTab.svelte +6 -5
- package/src/live-tokens/data/colors-and-type/autumn.json +5 -5
- package/src/live-tokens/data/colors-and-type/default.json +5 -5
- package/src/live-tokens/data/colors-and-type/halloween.json +5 -5
- package/src/live-tokens/data/colors-and-type/midnight-study.json +5 -5
- package/src/live-tokens/data/colors-and-type/ocean.json +5 -5
- package/src/live-tokens/data/colors-and-type/royal-velvet.json +5 -5
- package/src/live-tokens/data/colors-and-type/{sketches.json → sketchy.json} +6 -6
- package/src/live-tokens/data/colors-and-type/spring-meadow.json +5 -5
- package/src/live-tokens/data/colors-and-type/sunset.json +5 -5
- package/src/live-tokens/data/themes/autumn.json +5 -5
- package/src/live-tokens/data/themes/halloween.json +5 -5
- package/src/live-tokens/data/themes/midnight-study.json +5 -5
- package/src/live-tokens/data/themes/ocean.json +5 -5
- package/src/live-tokens/data/themes/royal-velvet.json +5 -5
- package/src/live-tokens/data/themes/{sketches.json → sketchy.json} +32 -32
- package/src/live-tokens/data/themes/spring-meadow.json +5 -5
- package/src/live-tokens/data/themes/sunset.json +5 -5
- package/src/live-tokens/data/tokens.generated.css +5 -5
- package/src/system/components/Card.svelte +12 -1
- package/src/system/components/ImageLightbox.svelte +26 -2
- package/src/system/components/SectionDivider.svelte +4 -0
- package/src/system/styles/tokens.css +5 -5
|
@@ -44,7 +44,15 @@ For pattern reference, read any shipped component's source directly from the con
|
|
|
44
44
|
```
|
|
45
45
|
The schema side-effect happens inside `registerComponent` (which `bootLiveTokens` calls for you), so you don't call `registerComponentSchema` separately. **Do not place a standalone `registerComponent(...)` *before* `bootLiveTokens`** — that registers before the editor's init hooks run, which is the wrong window and can leave editor changes disconnected from the live page. Only call `registerComponent` directly if your app mounts manually (no `bootLiveTokens`), in which case call it before `mount(App, ...)`.
|
|
46
46
|
4. **Tell the picker** — open `.claude/skills/live-tokens-pick-component/SKILL.md` and add your new component to the **Catalogue** line under the family it belongs to (Action / Input / Selection / Containers / Messaging / Display). If it's confusable with an existing component (a second selection control, a competing container), add a row to that family's decision table explaining the use-case it owns. Without this step, the component exists but [[live-tokens-pick-component]] can't recommend it when a user asks "which component should I use?" — the same rule applies whether the component is first-party (update the picker shipped in this package) or consumer-authored (update the local copy at `.claude/skills/live-tokens-pick-component/SKILL.md` that `setup-claude` placed in your project).
|
|
47
|
-
5. **
|
|
47
|
+
5. **Join the sketch layer** — the effect draws a fixed set of parts, so a new
|
|
48
|
+
component stays crisp while the page around it goes hand-drawn until it opts
|
|
49
|
+
in. A consumer component carries one of four reserved classes on its root and
|
|
50
|
+
names the five `--sketch-*` colours it is drawn with; a first-party component
|
|
51
|
+
adds a `PartSpec` row instead. The layer also takes `background`,
|
|
52
|
+
`border-color`, `box-shadow`, `overflow`, `position` and both pseudo-elements
|
|
53
|
+
away from the element it draws, which constrains where the class can go. Read
|
|
54
|
+
`references/sketch-mode.md`.
|
|
55
|
+
6. **Verify** with the checklist at the bottom of this file.
|
|
48
56
|
|
|
49
57
|
## Token discipline
|
|
50
58
|
|
|
@@ -123,6 +131,7 @@ The authoritative recognised list lives in `bin/check-component.mjs` (`KNOWN_SUF
|
|
|
123
131
|
|
|
124
132
|
The helper strips the `--<component>-` prefix and those segments, keeping the rest: `--mywidget-header-default-text` → `header-text`, `--mywidget-header-default-text-font-family` → `header-text-font-family`. Two parts ending in the same word stay distinct; one slot across variants collapses to one key. To override a single derived key, set `colorGroupKey` on that type-group config — it wins and is never recomputed, so your fix survives. There is no name-based fallback: a bare `buildTypeGroupColorTokens` call emits un-grouped (solo) colors rather than guessing, and a bare *font* helper across multiple slots is a `check-component` warning (its default `font-family`/… keys would merge the slots' fonts).
|
|
125
133
|
|
|
134
|
+
|
|
126
135
|
## State model
|
|
127
136
|
|
|
128
137
|
Components *can* have two state axes. Many don't: container and messaging components (Card, Badge, Callout, CollapsibleSection) have only variants, no hover/disabled. Skip the rest of this section for those.
|
|
@@ -194,10 +203,11 @@ For your own component, copy the pattern and substitute your id. Registering aga
|
|
|
194
203
|
|
|
195
204
|
## Extensions
|
|
196
205
|
|
|
197
|
-
Read the
|
|
206
|
+
Read the sketch reference for every component; the other two only when they apply.
|
|
198
207
|
|
|
199
208
|
- `references/linked-siblings.md`: variants that share base properties and should move together (Badge, Card, SegmentedControl).
|
|
200
209
|
- `references/intrinsics.md`: structural or display choices that are not token values (an alignment, an element's visibility), where the runtime default and the editor's read-back must agree.
|
|
210
|
+
- `references/sketch-mode.md`: joining the sketch layer. **Every component needs this.** One class on the root, the five `--sketch-*` values the layer draws with, and the list of what it takes over from the element. Skip it and the component stays crisp while the page around it goes hand-drawn.
|
|
201
211
|
|
|
202
212
|
## Verification checklist
|
|
203
213
|
|
|
@@ -230,3 +240,4 @@ Finally navigate to `/live-tokens/components` and confirm the runtime behaviours
|
|
|
230
240
|
- [ ] `component-configs/<id>/default.json` is derived from the `:global(:root)` block at boot. Save writes `_working.json`, the unsaved buffer the open theme captures; Save As also writes a named preset.
|
|
231
241
|
- [ ] Reset returns each variable to its `:global(:root)` default.
|
|
232
242
|
- [ ] Boot validation is clean (no warnings about the component being missing from the server scan, or about disk-vs-registry drift).
|
|
243
|
+
- [ ] Switch Sketch mode on in the editor and walk the checklist at the end of `references/sketch-mode.md`. The component is drawn in every variant and on hover, in its own colours, not crisp and not wearing another part's palette. Switch it off again and the component is unchanged.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# Joining the sketch layer
|
|
2
|
+
|
|
3
|
+
Sketch mode blanks each part's real background and border and repaints them onto
|
|
4
|
+
`::before`/`::after` through a shared noise field. It draws a fixed set of
|
|
5
|
+
selectors: the shipped components, plus four classes reserved for everyone else.
|
|
6
|
+
Your component is skipped until it opts in, so it stays crisp while the page
|
|
7
|
+
around it goes hand-drawn.
|
|
8
|
+
|
|
9
|
+
The whole contract is CSS. There is nothing to import and no function to call:
|
|
10
|
+
the layer exports no runtime API, and a component joins it by carrying a class
|
|
11
|
+
and naming five custom properties.
|
|
12
|
+
|
|
13
|
+
## What the layer takes over
|
|
14
|
+
|
|
15
|
+
An opted-in element is no longer painting itself. On every drawn part the layer
|
|
16
|
+
forces:
|
|
17
|
+
|
|
18
|
+
| It forces | So you must |
|
|
19
|
+
|----------------------------------------------|----------------------------------------------------------|
|
|
20
|
+
| `background: transparent !important` | Name the fill again as `--sketch-fill` |
|
|
21
|
+
| `border-color: transparent !important` | Name the outline again as `--sketch-stroke` |
|
|
22
|
+
| `box-shadow: none !important` | Name the shadow again as `--sketch-shadow` |
|
|
23
|
+
| `overflow: visible !important` | Never put the class on a box whose clip carries meaning |
|
|
24
|
+
| `position: relative` | Never put the class on an absolutely-positioned root |
|
|
25
|
+
| `z-index: 0` | Expect a new stacking context on that element |
|
|
26
|
+
| `::before` (the fill), `::after` (the stroke) | Never own either pseudo-element on that element |
|
|
27
|
+
|
|
28
|
+
`::after` survives on `sketch-rule` alone, which draws no outline. `::before` is
|
|
29
|
+
claimed on all four.
|
|
30
|
+
|
|
31
|
+
## Opting in
|
|
32
|
+
|
|
33
|
+
Put one class on the runtime component's root, chosen by **size, not by kind**.
|
|
34
|
+
A card and a modal are both containers; a badge and a pill are both chips.
|
|
35
|
+
|
|
36
|
+
| Class | For |
|
|
37
|
+
|---------------------|-------------------------------------------------------------|
|
|
38
|
+
| `sketch-surface` | A box. The default treatment. |
|
|
39
|
+
| `sketch-container` | A large box. Tilts less, so the type inside stays readable. |
|
|
40
|
+
| `sketch-chip` | A small box. Finer fill mask, more rotation, less travel. |
|
|
41
|
+
| `sketch-rule` | A line rather than a box. No rotation, no rounded ends. |
|
|
42
|
+
|
|
43
|
+
The class opts you in and nothing more. It names no colour, so the layer emits
|
|
44
|
+
no rule for it and whatever your component declares survives.
|
|
45
|
+
|
|
46
|
+
```svelte
|
|
47
|
+
<div class="mywidget sketch-container {variant}">…</div>
|
|
48
|
+
|
|
49
|
+
<style>
|
|
50
|
+
.mywidget {
|
|
51
|
+
background: var(--mywidget-surface);
|
|
52
|
+
border: var(--mywidget-border-width) solid var(--mywidget-border);
|
|
53
|
+
border-radius: var(--mywidget-radius);
|
|
54
|
+
box-shadow: var(--mywidget-shadow);
|
|
55
|
+
|
|
56
|
+
/* The layer hides all four above. These are what it draws instead. */
|
|
57
|
+
--sketch-fill: var(--mywidget-surface);
|
|
58
|
+
--sketch-stroke: var(--mywidget-border);
|
|
59
|
+
--sketch-hatch-color: var(--mywidget-border);
|
|
60
|
+
--sketch-radius: var(--mywidget-radius);
|
|
61
|
+
--sketch-shadow: var(--mywidget-shadow);
|
|
62
|
+
}
|
|
63
|
+
</style>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
State all five. `--sketch-radius` is registered as an inheriting `<length>`, and
|
|
67
|
+
the other four inherit as ordinary custom properties, so a part that states
|
|
68
|
+
nothing is drawn with its **ancestor's** value: a badge inside a hatched card
|
|
69
|
+
stripes itself in the card's ink, and a square header inside a rounded card
|
|
70
|
+
picks up the card's corners.
|
|
71
|
+
|
|
72
|
+
## Variants, states and inner parts
|
|
73
|
+
|
|
74
|
+
Nothing competes with you for these values, so every case is one more
|
|
75
|
+
declaration at the specificity you already use.
|
|
76
|
+
|
|
77
|
+
```css
|
|
78
|
+
.mywidget.danger { --sketch-fill: var(--mywidget-danger-surface); }
|
|
79
|
+
.mywidget:hover,
|
|
80
|
+
.mywidget.force-hover { --sketch-stroke: var(--mywidget-hover-border); }
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Pair every `:hover` with `.force-hover`, as elsewhere: that is the editor's
|
|
84
|
+
preview of the hover state, and a hover the sketch layer cannot paint reads as
|
|
85
|
+
no hover at all once the real background is transparent.
|
|
86
|
+
|
|
87
|
+
An inner part that carries its own surface (a header strip, a footer) takes its
|
|
88
|
+
own class and its own five values. Where such a part draws no outline, bind the
|
|
89
|
+
hatch ink to the ink its **parent** is outlined in, so the component reads as one
|
|
90
|
+
drawing rather than a shaded panel dropped into a box:
|
|
91
|
+
|
|
92
|
+
```css
|
|
93
|
+
.mywidget-header {
|
|
94
|
+
--sketch-fill: var(--mywidget-header-surface);
|
|
95
|
+
--sketch-stroke: transparent;
|
|
96
|
+
--sketch-hatch-color: var(--mywidget-border);
|
|
97
|
+
--sketch-radius: 0px;
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
A part with a visible stroke needs no `--sketch-hatch-color`; it falls back to
|
|
102
|
+
the stroke and follows it into hover. A part with no fill wants none, because
|
|
103
|
+
there is no surface there to shade.
|
|
104
|
+
|
|
105
|
+
A gradient is a valid fill. The `background` shorthand's last layer takes a
|
|
106
|
+
colour or an image, so `--sketch-fill` accepts either.
|
|
107
|
+
|
|
108
|
+
## Where the class does not go
|
|
109
|
+
|
|
110
|
+
- **A positioned root.** The layer forces `position: relative` on parts that sit
|
|
111
|
+
in flow, which drops an absolutely or fixed-positioned element back to its
|
|
112
|
+
flow position. Put the class on an inner box instead.
|
|
113
|
+
- **A box that clips something real.** `overflow` is forced visible so the ink
|
|
114
|
+
can travel past the border box, and there is no consumer opt-out. A scroller,
|
|
115
|
+
a fill bar held to its track, or a picture held to its frame keeps its clip by
|
|
116
|
+
keeping the class off that element and carrying it on a wrapper.
|
|
117
|
+
- **An element that owns `::before` or `::after`.** The layer claims both. A
|
|
118
|
+
shimmer, a caret or a decorative arrow on the opted-in element is gone.
|
|
119
|
+
- **A shipped part's selector** (`.card`, `.panel`). Borrowing one to get drawn
|
|
120
|
+
works, but it hands your component that part's colours and its damping, and it
|
|
121
|
+
is package-internal. The reserved classes are the contract.
|
|
122
|
+
|
|
123
|
+
## Rules, which are not boxes
|
|
124
|
+
|
|
125
|
+
A `border` cannot be displaced: the effect moves boxes, and a border is not one.
|
|
126
|
+
Make the rule an element, give it `sketch-rule`, and name its ink as the fill.
|
|
127
|
+
|
|
128
|
+
```svelte
|
|
129
|
+
<span class="mywidget-rule sketch-rule" aria-hidden="true"></span>
|
|
130
|
+
```
|
|
131
|
+
```css
|
|
132
|
+
.mywidget-rule {
|
|
133
|
+
height: var(--border-width-2);
|
|
134
|
+
background: var(--mywidget-divider);
|
|
135
|
+
--sketch-fill: var(--mywidget-divider);
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Media inside your component
|
|
140
|
+
|
|
141
|
+
A drawn part's `overflow` is visible so the fill and outline can travel past the
|
|
142
|
+
box. A background that bleeds is the effect working. An image that bleeds is
|
|
143
|
+
not, since it keeps square corners while the part around it turns. Media running
|
|
144
|
+
to your component's edge has to carry the corners itself:
|
|
145
|
+
|
|
146
|
+
```css
|
|
147
|
+
.mywidget-cover {
|
|
148
|
+
overflow: hidden;
|
|
149
|
+
border-top-left-radius: var(--sketch-radius, var(--mywidget-radius));
|
|
150
|
+
border-top-right-radius: var(--sketch-radius, var(--mywidget-radius));
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
`--sketch-radius` is the radius the layer drew and it inherits, so the fallback
|
|
155
|
+
covers the effect being off. Corner spread is per-corner and per-instance, so at
|
|
156
|
+
high spread the crop is the mean rather than an exact trace of the drawn edge.
|
|
157
|
+
|
|
158
|
+
## Icons and SVG
|
|
159
|
+
|
|
160
|
+
Icons and inline SVG take the wobble directly, since a glyph has no box to
|
|
161
|
+
redraw. Body type is left alone deliberately: an icon is a shape and survives a
|
|
162
|
+
wobble, a paragraph is not. You opt into none of this; it applies to every
|
|
163
|
+
`[class*="fa-"]` and every `svg` under the scope.
|
|
164
|
+
|
|
165
|
+
`--sketch-icon-off` names what a subtree's glyphs are drawn with instead. It
|
|
166
|
+
inherits, so one declaration covers everything under it:
|
|
167
|
+
|
|
168
|
+
```css
|
|
169
|
+
/* Crisp. Chrome, a logo, anything that has to stay exact. */
|
|
170
|
+
.mywidget-toolbar { --sketch-icon-off: none; }
|
|
171
|
+
|
|
172
|
+
/* Drawn back rather than off, at a third of the travel. Small artwork, and
|
|
173
|
+
type set as an SVG, which the layer reads as one large glyph. */
|
|
174
|
+
.mywidget-mark { --sketch-icon-off: var(--sketch-icon-soft); }
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Travel is stated in px against a glyph whose size the layer cannot know, so the
|
|
178
|
+
dial that suits a card's worth of artwork tears a 16px icon apart. Reach for the
|
|
179
|
+
soft bank before reaching for `none`. The shipped `SectionDivider` is the worked
|
|
180
|
+
example.
|
|
181
|
+
|
|
182
|
+
## First-party components
|
|
183
|
+
|
|
184
|
+
A component authored inside the package does not use the reserved classes. Add a
|
|
185
|
+
`PartSpec` row to `PART_SPECS` in `src/editor/core/sketch/sketchLayer.ts`
|
|
186
|
+
instead, which is keyed to the component's own token stem and gets the shipped
|
|
187
|
+
damping. `sketchPartTokens.test.ts` then holds you to it: every colour the layer
|
|
188
|
+
paints must be one the component itself assigns to that same element, checked
|
|
189
|
+
against the compiled `<style>` block.
|
|
190
|
+
|
|
191
|
+
## Verify
|
|
192
|
+
|
|
193
|
+
Switch Sketch mode on from the editor's **Sketch Style** view, then check the
|
|
194
|
+
component in place:
|
|
195
|
+
|
|
196
|
+
- [ ] Drawn, not crisp, in every variant.
|
|
197
|
+
- [ ] Wearing its own colours, not its parent's, including inner parts.
|
|
198
|
+
- [ ] Hover repaints. The wobble holds still while it does.
|
|
199
|
+
- [ ] Hatched fill uses ink that belongs to the component.
|
|
200
|
+
- [ ] Media at the component's edge turns with the drawn corners.
|
|
201
|
+
- [ ] Nothing that has to stay exact is torn: icons, clipped content, overlays.
|
|
202
|
+
- [ ] Switch it off. Every trace is gone and the component is unchanged.
|
|
@@ -49,7 +49,7 @@ All four pick one option from a set. The right one depends on **option count**,
|
|
|
49
49
|
| `Dialog` | Modal, blocks page | Confirmations, focused tasks the page can't continue around |
|
|
50
50
|
| `Panel` | Inline, fixed stage | A demo or preview surface whose height must not reflow |
|
|
51
51
|
|
|
52
|
-
- Default to `Card`. It's the workhorse.
|
|
52
|
+
- Default to `Card`. It's the workhorse. For full-bleed media — cover art, a poster, a chart that reaches its own border — pass `flush` (with `prose={false}`) rather than zeroing its padding tokens from the page.
|
|
53
53
|
- Reach for `CollapsibleSection` only when the content is *legitimately secondary* (advanced users open it; most skip). Don't use collapse as a styling choice when the content matters.
|
|
54
54
|
- `Panel` is a stage, not a content container. It pins its own height so what it shows can resize without moving the page, which is what a component preview or a live example needs and what article content does not. Content goes in `Card`.
|
|
55
55
|
- **Don't use `Dialog` for routine forms.** Reach for it only when the page cannot meaningfully continue until the user decides (destructive confirmations, payment, sign-in). Routine forms go inline in a `Card`.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,122 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.59.0 — The shadow traces the art
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **`shadow` on `ImageLightbox`.** The tile cast its shadow from its own
|
|
8
|
+
rectangle and offered no way out, so a PNG or WebP with transparency sat on a
|
|
9
|
+
phantom slab: the shadow drew the box, and the box was not the picture. Art
|
|
10
|
+
cut out against the page — a device mockup, a logo, a chart on no background —
|
|
11
|
+
showed a hard rounded rectangle behind it. `shadow` now picks where that
|
|
12
|
+
shadow falls. `box` is the old behaviour and stays the default. `content`
|
|
13
|
+
casts from the image's own alpha, so the shadow follows the silhouette.
|
|
14
|
+
`none` drops it. All three read the one `--imagelightbox-tile-shadow` the
|
|
15
|
+
theme already sets — the mode moves the shadow, it does not restyle it. The
|
|
16
|
+
open modal keeps its shadow only under `box`: it casts against a near-opaque
|
|
17
|
+
scrim where nothing reads, and filtering the pan-and-zoom surface would
|
|
18
|
+
repaint it every frame.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- **A shadow token writes its spread slot only when the spread is set.**
|
|
23
|
+
`--shadow-md` read `3px 3px 6px 0px hsla(…)`, and that fourth length was the
|
|
24
|
+
reason a shadow token could not also be a filter: `drop-shadow()` has no
|
|
25
|
+
spread slot, so the declaration was invalid and dropped. Every shipped theme
|
|
26
|
+
carries a zero spread, so the slot said nothing and cost the scale half its
|
|
27
|
+
reach. The zero-spread form is now three lengths, which `box-shadow` reads
|
|
28
|
+
identically and `drop-shadow()` accepts — one token, both properties, no
|
|
29
|
+
second scale to keep in step. The spread control is untouched: dial one and
|
|
30
|
+
the token grows its fourth length back, still a shadow but no longer a
|
|
31
|
+
filter, so a theme with a real spread has no shadow under `content`.
|
|
32
|
+
Four-length values still parse, and normalise on the next save.
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
|
|
36
|
+
- **The colour edit panel wears editor chrome again.** Its confirm, cancel and
|
|
37
|
+
"Remove override" buttons were the shipped `Button` and `InlineEditActions`
|
|
38
|
+
components, which read the theme's own tokens — so the controls you edit a
|
|
39
|
+
theme *with* restyled themselves as you edited, and a saturated success or
|
|
40
|
+
danger palette turned three small chrome buttons into slabs. They are now
|
|
41
|
+
`UIInlineEditActions` and `UIPillButton`, drawn from the theme-immune `--ui-*`
|
|
42
|
+
scale like the rest of the editor. `UIInlineEditActions` is the editor's
|
|
43
|
+
check/cross pair, sized to the 1.5rem chrome buttons it sits beside.
|
|
44
|
+
- **The base colour panel offers a confirm and a cancel.** Opening a palette's
|
|
45
|
+
editor showed the base panel with no way to accept or discard — every slider
|
|
46
|
+
wrote straight through, and only the docked step panel carried the pair. The
|
|
47
|
+
panel now shows both, greyed until an edit is pending; the first touch of a
|
|
48
|
+
slider, a hex field or the eyedropper opens the same session the step panel
|
|
49
|
+
uses, so cancel restores the colour the panel opened with and confirm keeps
|
|
50
|
+
the drag as one undo step.
|
|
51
|
+
|
|
52
|
+
## 0.58.0 — The sketch layer states its contract
|
|
53
|
+
|
|
54
|
+
### Added
|
|
55
|
+
|
|
56
|
+
- **`flush` on `Card`.** A card holding full-bleed media has to reach its own
|
|
57
|
+
border, but the body's inset stood in the way and the only way around it was
|
|
58
|
+
for the page to zero the five `--card-default-body-padding*` tokens at its own
|
|
59
|
+
scope — reaching around the component to undo something the component did, and
|
|
60
|
+
repeating it at every such card. `flush` drops the inset from the body alone,
|
|
61
|
+
outweighs `size="compact"` so it holds at either size, and pairs with
|
|
62
|
+
`prose={false}`: a flush body is a frame, not a column of text.
|
|
63
|
+
- **`sketch-container` and `sketch-chip`, beside the existing `sketch-surface`
|
|
64
|
+
and `sketch-rule`.** The sketch layer draws a fixed set of selectors, so a
|
|
65
|
+
consumer-authored component stayed crisp while the page around it went
|
|
66
|
+
hand-drawn. The four reserved classes are now a size ladder — a container
|
|
67
|
+
tilts less than the type inside it can tolerate, a chip is smaller than one
|
|
68
|
+
blob of the fill mask — and a consumer picks the band its part belongs to
|
|
69
|
+
instead of inheriting the middle treatment or borrowing a shipped part's
|
|
70
|
+
selector to get drawn at all. The classes name no colours, so the element's
|
|
71
|
+
own `--sketch-fill` / `--sketch-stroke` survive untouched.
|
|
72
|
+
|
|
73
|
+
### Changed
|
|
74
|
+
|
|
75
|
+
- **The `Sketches` preset theme is now `Sketchy`.** The old name read as a
|
|
76
|
+
collection of sketches rather than as the look itself, which is the one thing
|
|
77
|
+
a preset name has to do. The theme's files move to
|
|
78
|
+
`themes/sketchy.json` and `colors-and-type/sketchy.json`. Presets are served
|
|
79
|
+
read-through from the package, so a consumer who never opened it sees only the
|
|
80
|
+
new name; one whose active or production pointer names `sketches` has to
|
|
81
|
+
repoint it at `sketchy`.
|
|
82
|
+
- **The editor's `Sketch` and `Colors` views are now `Sketch Style` and
|
|
83
|
+
`Color Wheel`,** and the condensed rail cycles Tokens, Components, Sketch
|
|
84
|
+
Style, Color Wheel. `Sketch` named the mode and the view identically while
|
|
85
|
+
`Colors` said less than the view does; the flow order now runs from the
|
|
86
|
+
narrowest edit to the widest.
|
|
87
|
+
- **The sketch layer's contract is now documented from both sides.** The guide
|
|
88
|
+
and the component-authoring skill each described what an element has to
|
|
89
|
+
declare to be drawn, and neither said what the layer takes away from it: the
|
|
90
|
+
element's `background`, `border-color` and `box-shadow` are forced off, its
|
|
91
|
+
`overflow` is forced visible, it is given a stacking context, and both its
|
|
92
|
+
pseudo-elements are claimed. That is what decides where the opt-in class can
|
|
93
|
+
go, so a component that owned a `::before`, clipped its content or positioned
|
|
94
|
+
its root failed in a way neither document accounted for. The skill reference
|
|
95
|
+
now carries the full contract, including the icon controls, the hatch-ink
|
|
96
|
+
fallback for a part with no outline, and the `PART_SPECS` path a first-party
|
|
97
|
+
component takes instead of the reserved classes. The guide gains a short
|
|
98
|
+
section on where the dials live, since nothing said they are held in the
|
|
99
|
+
browser rather than in the theme.
|
|
100
|
+
|
|
101
|
+
### Fixed
|
|
102
|
+
|
|
103
|
+
- **Sketch mode's "Drawing your own elements" section showed the custom
|
|
104
|
+
properties without the class that opts an element in**, so the example it gave
|
|
105
|
+
drew nothing. It now documents all four reserved classes, how to pick one, and
|
|
106
|
+
that variants, states and gradients are all just further declarations of
|
|
107
|
+
`--sketch-fill` / `--sketch-stroke`.
|
|
108
|
+
- **Nothing said how to keep an image inside a drawn part from bleeding.** A
|
|
109
|
+
part's `overflow` is forced visible so the fill and outline can travel past
|
|
110
|
+
the box, which is right for a background and wrong for a photo: it kept square
|
|
111
|
+
corners while the card around it turned. `--sketch-radius` was already the
|
|
112
|
+
radius the layer drew and already inherited, so the fix was a documentation
|
|
113
|
+
one. Both the Sketch mode chapter and the component-authoring reference now
|
|
114
|
+
show media reading it, with a fallback for the effect being off.
|
|
115
|
+
- **`live-tokens-create-component` never mentioned sketch mode.** Joining the
|
|
116
|
+
layer is now step 5 of the recipe, with `references/sketch-mode.md` behind it
|
|
117
|
+
and a line on the verification checklist. A component authored to the old
|
|
118
|
+
recipe was invisible to the effect and nothing said so.
|
|
119
|
+
|
|
3
120
|
## 0.57.0 — A theme can be drawn by hand
|
|
4
121
|
|
|
5
122
|
### Added
|
|
@@ -719,15 +719,16 @@ function computeAngleDistance(x, y) {
|
|
|
719
719
|
return { angle: Math.round(angle), distance };
|
|
720
720
|
}
|
|
721
721
|
function shadowTokenCss(t) {
|
|
722
|
-
|
|
722
|
+
const spread = t.spread ? `${t.spread}px ` : "";
|
|
723
|
+
return `${t.x}px ${t.y}px ${t.blur}px ${spread}hsla(${t.hue}, ${t.saturation}%, ${t.lightness}%, ${t.opacity})`;
|
|
723
724
|
}
|
|
724
725
|
function parseShadowCss(variable, raw) {
|
|
725
|
-
const m = raw.trim().match(/^(-?\d+)px\s+(-?\d+)px\s+(\d+)px\s+(-?\d+)px\s+hsla\(([\d.]+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)$/);
|
|
726
|
+
const m = raw.trim().match(/^(-?\d+)px\s+(-?\d+)px\s+(\d+)px\s+(?:(-?\d+)px\s+)?hsla\(([\d.]+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)$/);
|
|
726
727
|
if (!m) return null;
|
|
727
728
|
const x = parseInt(m[1], 10);
|
|
728
729
|
const y = parseInt(m[2], 10);
|
|
729
730
|
const blur = parseInt(m[3], 10);
|
|
730
|
-
const spread = parseInt(m[4], 10);
|
|
731
|
+
const spread = m[4] === void 0 ? 0 : parseInt(m[4], 10);
|
|
731
732
|
const hue = Math.round(parseFloat(m[5]));
|
|
732
733
|
const saturation = Math.round(parseFloat(m[6]));
|
|
733
734
|
const lightness = Math.round(parseFloat(m[7]));
|
|
@@ -105,15 +105,16 @@ function computeAngleDistance(x, y) {
|
|
|
105
105
|
return { angle: Math.round(angle), distance };
|
|
106
106
|
}
|
|
107
107
|
function shadowTokenCss(t) {
|
|
108
|
-
|
|
108
|
+
const spread = t.spread ? `${t.spread}px ` : "";
|
|
109
|
+
return `${t.x}px ${t.y}px ${t.blur}px ${spread}hsla(${t.hue}, ${t.saturation}%, ${t.lightness}%, ${t.opacity})`;
|
|
109
110
|
}
|
|
110
111
|
function parseShadowCss(variable, raw) {
|
|
111
|
-
const m = raw.trim().match(/^(-?\d+)px\s+(-?\d+)px\s+(\d+)px\s+(-?\d+)px\s+hsla\(([\d.]+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)$/);
|
|
112
|
+
const m = raw.trim().match(/^(-?\d+)px\s+(-?\d+)px\s+(\d+)px\s+(?:(-?\d+)px\s+)?hsla\(([\d.]+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)$/);
|
|
112
113
|
if (!m) return null;
|
|
113
114
|
const x = parseInt(m[1], 10);
|
|
114
115
|
const y = parseInt(m[2], 10);
|
|
115
116
|
const blur = parseInt(m[3], 10);
|
|
116
|
-
const spread = parseInt(m[4], 10);
|
|
117
|
+
const spread = m[4] === void 0 ? 0 : parseInt(m[4], 10);
|
|
117
118
|
const hue = Math.round(parseFloat(m[5]));
|
|
118
119
|
const saturation = Math.round(parseFloat(m[6]));
|
|
119
120
|
const lightness = Math.round(parseFloat(m[7]));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@motion-proto/live-tokens",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.59.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Design token editor with live CSS variable editing. Svelte 5 + Vite 8.",
|
|
6
6
|
"keywords": [
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"src/live-tokens/data/colors-and-type/midnight-study.json",
|
|
31
31
|
"src/live-tokens/data/colors-and-type/ocean.json",
|
|
32
32
|
"src/live-tokens/data/colors-and-type/royal-velvet.json",
|
|
33
|
-
"src/live-tokens/data/colors-and-type/
|
|
33
|
+
"src/live-tokens/data/colors-and-type/sketchy.json",
|
|
34
34
|
"src/live-tokens/data/colors-and-type/spring-meadow.json",
|
|
35
35
|
"src/live-tokens/data/colors-and-type/sunset.json",
|
|
36
36
|
"src/live-tokens/data/themes/autumn.json",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"src/live-tokens/data/themes/midnight-study.json",
|
|
39
39
|
"src/live-tokens/data/themes/ocean.json",
|
|
40
40
|
"src/live-tokens/data/themes/royal-velvet.json",
|
|
41
|
-
"src/live-tokens/data/themes/
|
|
41
|
+
"src/live-tokens/data/themes/sketchy.json",
|
|
42
42
|
"src/live-tokens/data/themes/spring-meadow.json",
|
|
43
43
|
"src/live-tokens/data/themes/sunset.json",
|
|
44
44
|
"dist-plugin",
|
|
@@ -44,12 +44,13 @@
|
|
|
44
44
|
];
|
|
45
45
|
|
|
46
46
|
let multiple = $state(true);
|
|
47
|
+
let shadow = $state<'box' | 'content' | 'none'>('box');
|
|
47
48
|
</script>
|
|
48
49
|
|
|
49
50
|
<ComponentEditorBase
|
|
50
51
|
{component}
|
|
51
52
|
title="Image Lightbox"
|
|
52
|
-
description="Click an inline image to expand it into a centered modal with a backdrop. Pass multiple images for a gallery (chevrons + counter). Extended mode adds zoom controls and drag panning."
|
|
53
|
+
description="Click an inline image to expand it into a centered modal with a backdrop. Pass multiple images for a gallery (chevrons + counter). Extended mode adds zoom controls and drag panning. `shadow` picks where the one tile-shadow token falls: `box` casts it from the tile rectangle, `content` from the image's own alpha, or `none`."
|
|
53
54
|
tokens={allTokens}
|
|
54
55
|
>
|
|
55
56
|
<VariantGroup name="imagelightbox" title="Image Lightbox" {states} {component}>
|
|
@@ -58,9 +59,17 @@
|
|
|
58
59
|
<input type="checkbox" checked={multiple} onchange={(e) => (multiple = e.currentTarget.checked)} />
|
|
59
60
|
<span>Multiple images</span>
|
|
60
61
|
</label>
|
|
62
|
+
<label class="preview-toggle">
|
|
63
|
+
<span>Shadow</span>
|
|
64
|
+
<select value={shadow} onchange={(e) => (shadow = e.currentTarget.value as typeof shadow)}>
|
|
65
|
+
<option value="box">Box</option>
|
|
66
|
+
<option value="content">Content</option>
|
|
67
|
+
<option value="none">None</option>
|
|
68
|
+
</select>
|
|
69
|
+
</label>
|
|
61
70
|
{/snippet}
|
|
62
71
|
<div class="preview-frame">
|
|
63
|
-
<ImageLightbox images={multiple ? demoImages : [demoImages[0]]} extended />
|
|
72
|
+
<ImageLightbox images={multiple ? demoImages : [demoImages[0]]} {shadow} extended />
|
|
64
73
|
</div>
|
|
65
74
|
</VariantGroup>
|
|
66
75
|
</ComponentEditorBase>
|
|
@@ -155,10 +155,14 @@ function normalise(f: Float32Array): Float32Array {
|
|
|
155
155
|
|
|
156
156
|
/* ------------------------------------------------------------- levelling --- */
|
|
157
157
|
|
|
158
|
-
/** Output levels. The field
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
158
|
+
/** Output levels. The field is stretched into the gap between the handles, so
|
|
159
|
+
the pair states the range the mask paints: nothing is barer than Min or
|
|
160
|
+
denser than Max, and the field keeps its own shape in between.
|
|
161
|
+
|
|
162
|
+
Clamping instead makes Min the value most of the field sits AT rather than
|
|
163
|
+
its rare floor, because the field arrives centred on its own middle: half of
|
|
164
|
+
it is below 0.5, so a floor of 0.6 piles that half onto 0.6 and the fill
|
|
165
|
+
comes out a flat wash at the floor with a thin bright tail above it. */
|
|
162
166
|
function applyOutput(f: Float32Array, min: number, max: number): Float32Array {
|
|
163
167
|
const span = max - min;
|
|
164
168
|
for (let i = 0; i < f.length; i++) f[i] = min + f[i] * span;
|
|
@@ -239,8 +243,8 @@ export function buildMaskField(
|
|
|
239
243
|
const raw = cachedRaw(s, seed);
|
|
240
244
|
if (through === 'noise') return { field: raw, raster: RASTER };
|
|
241
245
|
|
|
242
|
-
const levelled =
|
|
243
|
-
|
|
246
|
+
const levelled = applyOutput(
|
|
247
|
+
posterise(Float32Array.from(raw), s.maskPosterize), s.maskOutputMin, s.maskOutputMax,
|
|
244
248
|
);
|
|
245
249
|
if (through === 'output') return { field: levelled, raster: RASTER };
|
|
246
250
|
|