@motion-proto/live-tokens 0.65.1 → 0.67.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 (39) hide show
  1. package/CHANGELOG.md +184 -0
  2. package/dist-plugin/{chunk-NDJJORKJ.js → chunk-T4PMCFJN.js} +220 -114
  3. package/dist-plugin/index.cjs +253 -129
  4. package/dist-plugin/index.js +27 -9
  5. package/dist-plugin/migrateData/index.cjs +220 -114
  6. package/dist-plugin/migrateData/index.js +1 -1
  7. package/package.json +8 -1
  8. package/src/editor/bootstrap.ts +12 -0
  9. package/src/editor/core/productionPulse.ts +1 -1
  10. package/src/editor/core/sketch/index.ts +78 -21
  11. package/src/editor/core/sketch/maskField.ts +200 -62
  12. package/src/editor/core/sketch/sketchLayer.ts +10 -4
  13. package/src/editor/core/sketch/sketchRegistry.ts +98 -0
  14. package/src/editor/core/sketch/sketchStore.ts +110 -31
  15. package/src/editor/core/sketch/sketchStyleService.ts +3 -0
  16. package/src/editor/core/sketch/sketchStyles.ts +63 -96
  17. package/src/editor/core/themes/themeInit.ts +4 -13
  18. package/src/editor/docs/content/sketch-mode.md +82 -13
  19. package/src/editor/docs/content.generated.ts +1 -1
  20. package/src/editor/ui/sketch/SketchTab.svelte +219 -74
  21. package/src/live-tokens/data/sketch-styles/dashed.json +47 -0
  22. package/src/live-tokens/data/sketch-styles/dry.json +47 -0
  23. package/src/live-tokens/data/sketch-styles/hatched.json +47 -0
  24. package/src/live-tokens/data/sketch-styles/marker.json +47 -0
  25. package/src/live-tokens/data/sketch-styles/napkin.json +47 -0
  26. package/src/live-tokens/data/sketch-styles/pencil.json +47 -0
  27. package/src/live-tokens/data/sketch-styles/whiteboard.json +47 -0
  28. package/src/live-tokens/data/themes/autumn.json +4 -4
  29. package/src/live-tokens/data/themes/halloween.json +4 -4
  30. package/src/live-tokens/data/themes/midnight-study.json +4 -4
  31. package/src/live-tokens/data/themes/ocean.json +4 -4
  32. package/src/live-tokens/data/themes/royal-velvet.json +4 -4
  33. package/src/live-tokens/data/themes/sketchy.json +4 -4
  34. package/src/live-tokens/data/themes/spring-meadow.json +4 -4
  35. package/src/live-tokens/data/themes/sunset.json +4 -4
  36. package/src/system/components/Button.svelte +2 -2
  37. package/src/system/components/IconButton.svelte +2 -2
  38. package/src/system/styles/fonts.css +6 -6
  39. package/template/src/main.ts +14 -1
@@ -7,7 +7,7 @@ export const docContent: Record<string, string> = {
7
7
  "editing-tokens": "# Editing tokens\n\nA tour of the editor. The page behind it repaints on every change; saving\nwrites a theme file you can reload later.\n\nThe editor has four views:\n\n- **Tokens**: the design-system primitives (colour, type, spacing, and so on).\n They apply everywhere your site uses them.\n- **Color Wheel**: the harmony wheel, the palette curves, and the story your colours\n tell across a page.\n- **Components**: per-component editors. Re-Assign what tokens a component uses\n without changing the underlying system.\n- **Sketchstyle**: an effect layer that redraws the page by hand. See\n [Sketch mode](sketch-mode.md).\n\nThis page covers **Tokens**. For components, see\n[Creating components](creating-components.md).\n\n## Palettes\n\nMost colour work happens here. Each palette (Brand, Accent, Neutral, Canvas,\nSuccess, Warning, Info, Danger, and a few more) has:\n\n- **Base colour.** Pick a hex; the palette derives an 11-step ramp (100 to 950)\n from it.\n- **Curves.** Three curves shape the ramp, in stack order: Hue, Saturation,\n Lightness. Drag the handles to bias it warmer or cooler, more or less\n saturated, darker or lighter. Hue drifts the ramp's temperature without\n moving contrast, because OKLCH hue rotation is close to lightness-preserving.\n It holds ±45 degrees; a bigger shift belongs on the base colour or the\n harmony axis.\n- **Overrides.** Lock a single step to a hand-picked hex when the curve doesn't\n land where you want.\n\nEditing a palette base ripples through every colour that depends on it, in real\ntime. Colours use OKLCH, so the ramp stays perceptually even across hues\nwithout muddy mid-tones.\n\n## Type\n\n- **Fonts.** Add sources from Google Fonts, Adobe (Typekit), a CSS URL, or an\n inline `@font-face`. The font loads in the page as soon as you add it.\n- **Stacks.** Named font cascades you reference by token, such as a display\n stack and a body stack.\n- **Sizes and weights.** A t-shirt scale (xs, sm, md, lg, xl, 2xl…) for size and\n a numeric scale (100 to 900) for weight.\n\n## Spacing, radius, shadow\n\nNumeric scales with a slider per step.\n\n- **Spacing**: the padding, gap, and margin scale.\n- **Radius**: none through full.\n- **Shadow**: colour, offset, blur, spread, and opacity per step, with stacked\n shadows supported.\n\nChange a step and every element using it repaints.\n\n## Overlays and gradients\n\n- **Overlays** are translucent tints layered over surfaces, like the subtle\n tint a card gets on hover. Set a colour and opacity per state.\n- **Gradients** are reusable gradient tokens with a stop list and direction, for\n hero panels and accent backgrounds.\n\n## Columns\n\nThe page-grid overlay. Set column count, gutter, and outer margin, and toggle\nthe visual guide with `Cmd/Ctrl+G`. Pages built on the column system reflow\nlive.\n\n## Saving\n\nThe editor saves to your browser continuously, so work survives a reload\nmid-edit. Writing a file is a separate step: the **Theme** panel at the foot of\nthe sidebar has **Save**, **Save As**, and **Load**, and each theme is one JSON\nfile under `src/live-tokens/data/themes/`.\n\nThe header gives you undo/redo (`Cmd/Ctrl+Z`, `Cmd/Ctrl+Shift+Z`). You can keep\nmany themes side by side; one is open at a time, and only **Adopt** publishes\none. See [Themes](themes-workflow.md) for the full lifecycle.\n",
8
8
  "getting-started": "# Getting started\n\nScaffold a live token site in a moments. You need Node 20 or later, a\npackage manager (npm, pnpm, or yarn), and a browser. Open claude code in your repo and start building.\n\n## Scaffold a new app\n\n```bash\nnpm create @motion-proto/live-tokens@latest my-app\ncd my-app\nnpm install\nnpm run dev\n```\n\nOpen the URL Vite prints (usually `http://localhost:5173`). You get a\none-page Svelte + Vite app that depends on the published package, with the\neditor wired up and the full component set ready to import.\n\n`npx @motion-proto/live-tokens create my-app` runs the same scaffold without\nthe initialiser package.\n\n### What the scaffold gives you\n\nEvery editable file lives under `src/` and is committed, so `npm install` and\nversion upgrades never touch your styles. The package code stays in\n`node_modules`.\n\n| Path | What it is |\n|------|------------|\n| `src/pages/Home.svelte` | The starter page. Replace it with your own content. |\n| `src/App.svelte` | Your routes. `<LiveTokensRouter>` adds dev-only routes under a reserved `/live-tokens/*` namespace: `/live-tokens/editor`, `/live-tokens/components`, and `/live-tokens/docs`. |\n| `src/system/styles/tokens.css` | Your base token vocabulary, hand-authored. |\n| `src/styles/site.css` | Themed page typography, yours to edit. |\n\n## Your first edit\n\n1. Run `npm run dev` and open the home page.\n2. Click **Open Token Editor**, or visit `/live-tokens/editor`. The editor opens beside\n the page.\n3. Open **Palettes**, pick **Brand**, and change the base hex. The page\n repaints as you type.\n4. In the **Theme** panel at the foot of the sidebar, choose **Save As**. Your\n theme appears as JSON under `src/live-tokens/data/themes/`.\n5. Reload. The editor reopens on your theme, so the page returns as you left\n it.\n\n## What you just changed\n\nEvery edit sets a CSS custom property on `:root`. Your components read those\nproperties through `var(--...)`. There is no token build step and no\npreprocessor rewriting your code: the page renders against plain CSS variables\nthe editor swaps live.\n\nTo ship, click **Adopt** in the Theme panel. That saves the open theme and bakes\nit into `src/live-tokens/data/tokens.generated.css`, which your build bundles\nalongside `tokens.css`. Adopt is the only action that changes what your site\nships, so try any look you like first. The editor itself never reaches\nproduction.\n\nAlready have a Svelte 5 + Vite app? The\n[README](https://github.com/motionproto/live-tokens#readme) covers installing\ninto an existing project.\n\n## Where to go next\n\n- **[Editing tokens](editing-tokens.md)**: a tour of the editor.\n- **[Themes](themes-workflow.md)**: save, switch, and ship.\n- **[Creating components](creating-components.md)**: make your own component\n editable.\n",
9
9
  "light-and-dark": "# Light and dark\n\nSome things on a page cannot be written as a token. A wordmark drawn in white\ndisappears on a pale theme. Ink that multiplies onto paper vanishes on a dark\none. A photograph behind a headline is dark no matter what the palette says.\n\nEach of those needs the same fact first: which way does the surface behind this\nthing lean? One attribute carries it.\n\n## The attribute\n\n`data-backdrop` is either `light` or `dark`, and it does two things at once: it\nselects, so a rule can key on it, and it sets `color-scheme`, so every\n`light-dark()` under it resolves the half that reads.\n\n```css\n.title {\n color: light-dark(var(--color-black), var(--color-white));\n}\n```\n\nThat line is right on both sides of the theme, and it is right inside a dark\nband on a pale page, because the nearest `color-scheme` wins.\n\n## Stating it\n\nPut it in the markup when the surface knows its own tone — a hero over a\nphotograph, a plate that stays pale in every theme:\n\n```svelte\n<div class=\"hero-panel\" data-backdrop=\"dark\">\n```\n\nA stated tone beats any measurement, and it inherits, so everything inside the\npanel resolves against it.\n\n## Measuring it\n\nWhere the tone is a property of the theme rather than of the markup, let it be\nmeasured:\n\n```svelte\n<script>\n import { backdrop } from '@motion-proto/live-tokens/backdrop';\n</script>\n\n<section use:backdrop>\n```\n\nThe action reads whatever actually paints behind the element — the nearest\nancestor with an opaque fill, averaged across its gradient stops, falling back\nto the theme's `--page-bg` — and stamps the answer. It re-reads when the theme\nchanges, which the editor does by rewriting custom properties with no reload,\nso the stamp follows a live edit.\n\nThe page itself is stamped for you: the build bakes the production theme's\npolarity into `tokens.generated.css`, so the first paint is already right, and\n`syncDocumentBackdrop()` keeps `<html>` current as themes switch.\n\n```ts\nimport { syncDocumentBackdrop } from '@motion-proto/live-tokens/backdrop';\n\nsyncDocumentBackdrop();\n```\n\n## Reading it from JavaScript\n\nAnything that paints outside CSS — a canvas, a WebGL uniform, an `<img>` that\ncomes in two versions — asks the same question through the same module:\n\n```ts\nimport { isLightBackdrop, watchBackdrop, cssColorToHex } from '@motion-proto/live-tokens/backdrop';\n\nconst stop = watchBackdrop(logoEl, {\n stamp: false,\n onChange: (polarity) => (src = polarity === 'light' ? darkMark : lightMark),\n});\n```\n\n`isLightBackdrop(el)` answers once. `watchBackdrop` keeps answering and returns\na stop function. `cssColorToHex` resolves any CSS colour — including the\n`oklch()` a token holds — to a hex a non-CSS consumer can take.\n\n## What it does not do\n\nPolarity is a property of a surface, not of a component, so nothing is stamped\nfor you below `<html>`: a section that needs an answer either states one or asks\nfor one. And a measurement reads the paint at the moment it runs — an element\nthat scrolls from a pale band onto a dark one keeps the answer it was given.\nState the tone on each band instead.\n",
10
- "sketch-mode": "# Sketch mode\n\nSketch mode redraws your whole page as if it had been drawn by hand. Every\ncomponent keeps its own colours, spacing and corners; what changes is the line\nthey are drawn with.\n\nIt is an effect layer, not a set of token values. It never touches a token\nitself, so turning it off returns every component to exactly what its tokens\nalready say. A production build never carries the drawing.\n\nOpen the **Sketchstyle** view in the editor and switch **Sketch mode** on. The effect\napplies to the page behind the editor as well as to the preview, so what you see\nin context is what it does.\n\n## What it draws\n\nEach component's fill and outline are repainted from the tokens that component\nalready owns. The real background and border are hidden behind them, then both\nare pushed around one shared field of noise. Because every component samples the\nsame field, the whole page reads as one drawing rather than as a set of\nseparately wobbled boxes.\n\n## The sketchstyles\n\nSeven looks ship with the package, and each is a complete set of dials rather\nthan just a name:\n\n- **Pencil.** Two graphite passes on their own seeds, so the outline disagrees\n with itself the way a hand coming back round does.\n- **Marker.** A broad translucent nib gone round twice on the same line, so the\n overlap darkens and the ink pools where it slows.\n- **Whiteboard.** The fattest nib on glass, with a mask that streaks the fill\n like a half-wiped board.\n- **Hatched.** An etching. The fill is angled shading and the outline a single\n hard-edged scratch.\n- **Dashed.** A drafting outline: one slow drift along the ruler, broken into\n strokes. The clean pole.\n- **Napkin.** Ballpoint in a hurry. Everything loose at once.\n- **Dry marker.** Ink that ran out. One scratchy pass over a mostly eaten fill.\n\nPick one, then move whatever you like. **Save as sketchstyle…** keeps your\ndials under a name of your own, alongside the shipped seven, as a file under\n`src/live-tokens/data/sketch-styles/`. That is a different gesture from\nsaving a theme; see \"Where the settings live\" below.\n\n## The dials\n\n- **Border.** How far the outline travels and how long its wave is, then its\n width, ink, pressure and pooling. A second pass either copies the first line a\n few pixels off or runs it through the pen again on its own seed.\n- **Fill.** Solid or hatched, how far the fill's edge travels, and how far each\n instance is offset, rotated and scaled from its neighbours. **Ink coverage**\n thins the fill with a field of blotches: set their size and how many levels of\n detail, then work the field as a levels control. The field always runs black\n to white whatever the noise underneath. Steps flattens it into tones, and\n Output squeezes the whole of it into the range the ink covers, from how pale\n it gets at its thinnest to how dense at its fullest. Menus and tooltips are\n drawn solid whatever the coverage dials say: they float over the page, and a\n fill worn through in patches lets the page show through them.\n- **Shape.** **Corner spread** rounds each corner by its own share of the dial,\n so no two match. **Corner travel** leans the drawn box into a quadrilateral\n with no two sides parallel. This is the dial that stops a component reading as\n a rectangle.\n- **Icons and SVG.** Glyph travel and wavelength on their own scale. A glyph is\n all curves already, so it needs more travel than a card's long straight edge\n before the wobble reads at all.\n- **Noise.** The shared field itself: its wavelength, how many layers of detail\n sit on it, and the shape of its wave. A square wave sends nearly every edge to\n full travel, which is what makes the effect stronger rather than bigger.\n\n## Where the settings live\n\nThe sketch layer is part of the theme, the same way colors and type are.\n**Save** in the Theme panel folds your dials into the open theme; **Load**\napplies whatever a theme carries, and turns the effect off for a theme that\ncarries none.\n\nUntil you save, the dials sit in your browser only. The Theme panel calls\nthat state off the theme, the same word it uses for an unsaved component\nchange. The built-in **Motion Proto** theme is read-only, so Save\nis disabled there; use **Save As** to fold the dials into a theme of your\nown.\n\n**Save as sketchstyle…** in the **Sketchstyle** view is a different gesture. It\nwrites a named sketchstyle to `src/live-tokens/data/sketch-styles/`, a look you\ncan pick from any theme. It never touches the open theme, and it never marks\nthe look off the theme.\n\nSketch mode is a tool for looking at the page, not a layer the page can ship.\nThe theme records the dials, but nothing bakes them: `tokens.generated.css`\nnever sees them, and a production build has no sketch layer in it at all.\n\n## Drawing your own elements\n\nThe layer draws a fixed set of parts: the shipped components, and four classes\nit reserves for you. Nothing else is touched, so a page element or a\nconsumer-authored component is left crisp until it carries one of them.\n\n| Class | For |\n|---------------------|-----------------------------------------------------------|\n| `sketch-surface` | A box. The default treatment. |\n| `sketch-container` | A large box. Tilts less, so the type inside stays readable. |\n| `sketch-chip` | A small box. Finer fill mask, more rotation, less travel. |\n| `sketch-rule` | A line rather than a box. No rotation, no rounded ends. |\n\nPick by size, not by kind: a card and a modal both take `sketch-container`, a\nbadge and a pill both take `sketch-chip`.\n\nThe class opts the element in; it names no colours, so the element states its\nown. `--sketch-fill`, `--sketch-stroke`, `--sketch-hatch-color`,\n`--sketch-radius` and `--sketch-shadow` name the fill, the outline, the hatching\nink, the corners and the shadow for one element and everything inside it. The\nlayer blanks the real background and border, so an element whose fill matters\nunder Sketch mode has to name it here as well as paint it.\n\nThe layer also paints on the element's `::before` and `::after`, forces its\n`overflow` visible, and gives it a stacking context of its own. Keep the class\noff anything that owns a pseudo-element, clips its content, or is positioned\nabsolutely, and put it on a wrapper instead.\n\n```css\n.my-callout {\n background: var(--surface-brand-lowest);\n border: var(--border-width-1) solid var(--border-brand);\n border-radius: var(--radius-xl);\n\n --sketch-fill: var(--surface-brand-lowest);\n --sketch-stroke: var(--border-brand);\n --sketch-radius: var(--radius-xl);\n}\n```\n\nA gradient is a valid fill: the shorthand's last layer takes a colour or an\nimage, so `--sketch-fill` accepts either. States work the same way, since\nnothing is competing with you for the value:\n\n```css\n.my-callout:hover { --sketch-stroke: var(--border-brand-strong); }\n```\n\n## Images inside a drawn part\n\nA drawn part's `overflow` is forced visible, because the fill and outline are\npainted on pseudo-elements that travel past the box and would otherwise be cut\noff at its edge. A background that bleeds is the effect working. An image that\nbleeds is not: it keeps its square corners while the card around it turns.\n\nMedia that runs to a part's edge therefore has to carry that part's corners\nitself. `--sketch-radius` is the radius the layer drew, and it inherits, so a\nchild can read it and fall back to its own value when Sketch mode is off:\n\n```css\n.cover {\n overflow: hidden;\n border-top-left-radius: var(--sketch-radius, var(--card-default-radius));\n border-top-right-radius: var(--sketch-radius, var(--card-default-radius));\n}\n```\n\nCorner spread is per-corner and per-instance, so at high spread the crop is the\nmean rather than an exact trace of the drawn edge.\n\nA rule made from a `border` is not a box and cannot be displaced. Make it an\nelement, give it `sketch-rule`, and name its ink:\n\n```html\n<div class=\"rule sketch-rule\"></div>\n```\n```css\n.rule {\n height: var(--border-width-2);\n background: var(--border-brand);\n --sketch-fill: var(--border-brand);\n}\n```\n\nIcons and inline SVG take the wobble directly, since a glyph has no box to\nredraw. Body type is left alone: an icon is a shape and survives a wobble, a\nparagraph is not.\n\n`--sketch-icon-off` names what a subtree's glyphs are drawn with instead. It\ninherits, so one declaration covers everything under it, and it takes the ink\nmask off as well as the wobble:\n\n```css\n/* Crisp. Chrome, a logo, anything that has to stay exact. */\n.app-bar { --sketch-icon-off: none; }\n\n/* Drawn back rather than off, at a third of the travel. Small artwork, and\n type set as an SVG, which the layer reads as one large glyph. */\n.wordmark { --sketch-icon-off: var(--sketch-icon-soft); }\n```\n\nThe **Blotch size** dial under Icons and SVG is a share of the glyph rather than\na px size, because no px size is right for both a 16px icon and a page-wide\ndrawing. At 100% every glyph gets one period of the field across it whatever its\nsize. Below that the field repeats inside the glyph and the blotches get finer.\nAbove it a glyph reads part of one blotch, so the mask thins the whole glyph\nunevenly instead of breaking it up. The fill's blotches stay in px, since a\ncomponent does have a size to state one against.\n",
10
+ "sketch-mode": "# Sketch mode\n\nSketch mode redraws your whole page as if it had been drawn by hand. Every\ncomponent keeps its own colours, spacing and corners; what changes is the line\nthey are drawn with.\n\nIt is an effect layer, not a set of token values. It never touches a token\nitself, so turning it off returns every component to exactly what its tokens\nalready say.\n\nOpen the **Sketchstyle** view in the editor and switch **Sketch mode** on. The effect\napplies to the page behind the editor as well as to the preview, so what you see\nin context is what it does.\n\n## What it draws\n\nEach component's fill and outline are repainted from the tokens that component\nalready owns. The real background and border are hidden behind them, then both\nare pushed around one shared field of noise. Because every component samples the\nsame field, the whole page reads as one drawing rather than as a set of\nseparately wobbled boxes.\n\n## The sketchstyles\n\nSeven looks ship with the package, and each is a complete set of dials rather\nthan just a name:\n\n- **Pencil.** Two graphite passes on their own seeds, so the outline disagrees\n with itself the way a hand coming back round does.\n- **Marker.** A broad translucent nib gone round twice on the same line, so the\n overlap darkens and the ink pools where it slows.\n- **Whiteboard.** The fattest nib on glass, with a mask that streaks the fill\n like a half-wiped board.\n- **Hatched.** An etching. The fill is angled shading and the outline a single\n hard-edged scratch.\n- **Dashed.** A drafting outline: one slow drift along the ruler, broken into\n strokes. The clean pole.\n- **Napkin.** Ballpoint in a hurry. Everything loose at once.\n- **Dry marker.** Ink that ran out. One scratchy pass over a mostly eaten fill.\n\nAll seven ship as files, one per look, under\n`src/live-tokens/data/sketch-styles/` in the package. There is no look that\nexists only as code, so every one of them can be read, copied and edited.\n\nPick one, then move whatever you like. **Save As** keeps your dials under a name\nof your own, alongside the shipped seven, as a file under\n`src/live-tokens/data/sketch-styles/` in your project. **Save** writes them back\nover the sketchstyle you have selected, and lights as soon as the dials leave\nit. On one of your own it writes that file. On a shipped one it writes your\nproject's own copy under the same name, which takes its place in the list;\ndelete that copy and the shipped file behind it comes back. Both are a\ndifferent gesture from saving a theme; see \"Where the settings live\" below.\n\nYour sketchstyles and the shipped ones are one list. A sketchstyle named after\na shipped one replaces it, keeping its place in the list, so a project that\nwants its own Pencil saves one and every picker shows that one instead.\n\n## The dials\n\n- **Border.** How far the outline travels and how long its wave is, then its\n width, ink, pressure and pooling. A second pass either copies the first line a\n few pixels off or runs it through the pen again on its own seed.\n- **Fill.** Solid or hatched, how far the fill's edge travels, and how far each\n instance is offset, rotated and scaled from its neighbours. **Ink coverage**\n thins the fill with a field of blotches: set their size across and down and\n how many levels of detail, then work the field as a levels control. The two\n sizes move together under a chain; break it and the blotches stretch, which\n reads as ink dragged along the axis you widened, and a **Rotation** dial joins\n them to point that stretch anywhere you like. The field always runs black\n to white whatever the noise underneath. Steps flattens it into tones, and\n Output squeezes the whole of it into the range the ink covers, from how pale\n it gets at its thinnest to how dense at its fullest. Menus and tooltips are\n drawn solid whatever the coverage dials say: they float over the page, and a\n fill worn through in patches lets the page show through them.\n- **Shape.** **Corner spread** rounds each corner by its own share of the dial,\n so no two match. **Corner travel** leans the drawn box into a quadrilateral\n with no two sides parallel. This is the dial that stops a component reading as\n a rectangle.\n- **Icons and SVG.** Glyph travel and wavelength on their own scale. A glyph is\n all curves already, so it needs more travel than a card's long straight edge\n before the wobble reads at all.\n- **Noise.** The shared field itself: its wavelength, how many layers of detail\n sit on it, and the shape of its wave. A square wave sends nearly every edge to\n full travel, which is what makes the effect stronger rather than bigger.\n\n## Where the settings live\n\nThe sketch layer is part of the theme, the same way colors and type are.\n**Save** in the Theme panel folds your dials into the open theme; **Load**\napplies whatever a theme carries, and turns the effect off for a theme that\ncarries none.\n\nUntil you save, the dials sit in your browser only. The Theme panel calls\nthat state off the theme, the same word it uses for an unsaved component\nchange. The built-in **Motion Proto** theme is read-only, so Save\nis disabled there; use **Save As** to fold the dials into a theme of your\nown.\n\n**Save** and **Save As** in the **Sketchstyle** view are a different gesture.\nThey write a named sketchstyle to `src/live-tokens/data/sketch-styles/`, a look\nyou can pick from any theme. Neither touches the open theme, and neither marks\nthe look off the theme.\n\n## Shipping the layer\n\nThe dev server reads the open theme and paints whatever it carries. A built site\nhas no server to ask, so it hands the field over itself:\n\n```ts\nimport { seedSketchFromTheme } from '@motion-proto/live-tokens/sketch';\nimport theme from './live-tokens/data/themes/sketchy.json';\n\nseedSketchFromTheme(theme.sketchStyle);\nawait bootLiveTokens(App, '#app');\n```\n\nCall it before mounting, so the look is up on the first frame. Pass the field\nraw. A theme written against older dial names is carried forward on the way in,\nthe same reconciliation the dev server runs on every theme it reads.\n\nNothing is baked. `tokens.generated.css` still holds token values only, and the\nlayer stays JavaScript the page runs, because it builds an SVG filter bank\nrather than a set of custom properties.\n\nA visitor who has picked a look of their own keeps it, None included. The theme\nseeds a browser that has decided nothing and never overwrites one that has, so\ncalling this on every boot is safe.\n\n### Your own sketchstyles\n\nThe dev server lists the files in `sketch-styles/`. A built site has no server\nto ask, so it hands them over at boot, the way it hands over components:\n\n```ts\nconst files = import.meta.glob<{ name?: string; settings: unknown }>(\n './live-tokens/data/sketch-styles/*.json',\n { eager: true, import: 'default' },\n);\n\nawait bootLiveTokens(App, '#app', {\n sketchLooks: Object.entries(files).map(([path, file]) => {\n const id = path.split('/').pop()!.replace('.json', '');\n return { id, label: file.name || id, settings: file.settings };\n }),\n});\n```\n\nProjects made with `create` ship this already. The file's slug is the look's\nid, so a sketchstyle picked in the editor keeps working once the site is built.\n\n### Building a picker\n\n`sketchLooks` is every look on offer, shipped and your own, as a store. Give\neach row `setSketch(look.id)`, and add your own **None** row: off is a state of\nthe effect rather than one of the looks.\n\n`themeSketchLook` is the theme's own look as one more row. It is null when the\ntheme carries none, and null when what it carries is a look already in\n`sketchLooks`, since that row names it. Its id goes to `setSketch` like any\nother, so a visitor who wanders off the theme's look can come back to it.\n\n## Drawing your own elements\n\nThe layer draws a fixed set of parts: the shipped components, and four classes\nit reserves for you. Nothing else is touched, so a page element or a\nconsumer-authored component is left crisp until it carries one of them.\n\n| Class | For |\n|---------------------|-----------------------------------------------------------|\n| `sketch-surface` | A box. The default treatment. |\n| `sketch-container` | A large box. Tilts less, so the type inside stays readable. |\n| `sketch-chip` | A small box. Finer fill mask, more rotation, less travel. |\n| `sketch-rule` | A line rather than a box. No rotation, no rounded ends. |\n\nPick by size, not by kind: a card and a modal both take `sketch-container`, a\nbadge and a pill both take `sketch-chip`.\n\nThe class opts the element in; it names no colours, so the element states its\nown. `--sketch-fill`, `--sketch-stroke`, `--sketch-hatch-color`,\n`--sketch-radius` and `--sketch-shadow` name the fill, the outline, the hatching\nink, the corners and the shadow for one element and everything inside it. The\nlayer blanks the real background and border, so an element whose fill matters\nunder Sketch mode has to name it here as well as paint it.\n\nThe layer also paints on the element's `::before` and `::after`, forces its\n`overflow` visible, and gives it a stacking context of its own. Keep the class\noff anything that owns a pseudo-element, clips its content, or is positioned\nabsolutely, and put it on a wrapper instead.\n\n```css\n.my-callout {\n background: var(--surface-brand-lowest);\n border: var(--border-width-1) solid var(--border-brand);\n border-radius: var(--radius-xl);\n\n --sketch-fill: var(--surface-brand-lowest);\n --sketch-stroke: var(--border-brand);\n --sketch-radius: var(--radius-xl);\n}\n```\n\nA gradient is a valid fill: the shorthand's last layer takes a colour or an\nimage, so `--sketch-fill` accepts either. States work the same way, since\nnothing is competing with you for the value:\n\n```css\n.my-callout:hover { --sketch-stroke: var(--border-brand-strong); }\n```\n\n## Images inside a drawn part\n\nA drawn part's `overflow` is forced visible, because the fill and outline are\npainted on pseudo-elements that travel past the box and would otherwise be cut\noff at its edge. A background that bleeds is the effect working. An image that\nbleeds is not: it keeps its square corners while the card around it turns.\n\nMedia that runs to a part's edge therefore has to carry that part's corners\nitself. `--sketch-radius` is the radius the layer drew, and it inherits, so a\nchild can read it and fall back to its own value when Sketch mode is off:\n\n```css\n.cover {\n overflow: hidden;\n border-top-left-radius: var(--sketch-radius, var(--card-default-radius));\n border-top-right-radius: var(--sketch-radius, var(--card-default-radius));\n}\n```\n\nCorner spread is per-corner and per-instance, so at high spread the crop is the\nmean rather than an exact trace of the drawn edge.\n\nA rule made from a `border` is not a box and cannot be displaced. Make it an\nelement, give it `sketch-rule`, and name its ink:\n\n```html\n<div class=\"rule sketch-rule\"></div>\n```\n```css\n.rule {\n height: var(--border-width-2);\n background: var(--border-brand);\n --sketch-fill: var(--border-brand);\n}\n```\n\nIcons and inline SVG take the wobble directly, since a glyph has no box to\nredraw. Body type is left alone: an icon is a shape and survives a wobble, a\nparagraph is not.\n\n`--sketch-icon-off` names what a subtree's glyphs are drawn with instead. It\ninherits, so one declaration covers everything under it, and it takes the ink\nmask off as well as the wobble:\n\n```css\n/* Crisp. Chrome, a logo, anything that has to stay exact. */\n.app-bar { --sketch-icon-off: none; }\n\n/* Drawn back rather than off, at a third of the travel. Small artwork, and\n type set as an SVG, which the layer reads as one large glyph. */\n.wordmark { --sketch-icon-off: var(--sketch-icon-soft); }\n```\n\nThe **Blotch size** dial under Icons and SVG is a share of the glyph rather than\na px size, because no px size is right for both a 16px icon and a page-wide\ndrawing. At 100% every glyph gets one period of the field across it whatever its\nsize. Below that the field repeats inside the glyph and the blotches get finer.\nAbove it a glyph reads part of one blotch, so the mask thins the whole glyph\nunevenly instead of breaking it up. The fill's blotches stay in px, since a\ncomponent does have a size to state one against.\n",
11
11
  "themes-workflow": "# Themes\n\nSave your work, switch between looks, and ship one to production.\n\n## The Theme panel\n\nThe **Theme** panel at the foot of the editor sidebar holds the whole look:\ncolors, type, a setting for every component, and the sketch layer, in one\nfile. It carries the name the look ships under, whether production is running\nit, and **Adopt**. Three parts sit under it, each a read-out rather than a\nfile to manage.\n\n- **Colors & Type** holds the design tokens. Components read those tokens to\n define their appearance. It names the two faces the page is showing.\n- **Components** counts how many components have an unsaved edit that has not\n been saved into the theme, and opens the component editors.\n- **Sketchstyle** names the look the theme's sketch layer carries: its label, or\n off the theme when what's on screen no longer matches what was saved, or\n none when the theme carries no sketch layer. It travels with the theme\n like colors and type do, but never reaches a production build.\n\nA theme holds its own copy of every part, so one theme can never break another.\n\n## How themes work\n\nA theme is a document, and the editor works the way any editor does.\n\n- **A theme** is a named JSON file in `src/live-tokens/data/themes/`. It carries\n the whole look: the colors and type, a setting for every component, and the\n sketch layer.\n- **The open theme** is the one the editor is working on, named in\n `themes/_active.json`. One at a time.\n- **Your unsaved edits** are what the page shows right now. The editor keeps\n them in your browser as you work, writing most parts to a buffer,\n `_working.json`, one slot each; the sketch layer has no buffer and stays\n live in the browser until you save. **Save** captures all of it into the\n open theme.\n- **The production theme** is the one your site ships, named in\n `themes/_production.json`. **Adopt** changes it; saving a preset in the Theme\n Picker performs that Adopt for you.\n\nAbsence is the answer for anything untouched: a buffer exists only where the\nlive look diverges from the active theme, so a newly opened theme has none.\n\n## Fonts\n\nType is part of the look, so it saves, loads and ships with the theme rather\nthan on its own. Four named stacks carry it:\n\n| Stack | Used by |\n|---|---|\n| `--font-display` | headings |\n| `--font-sans` | body text and most UI |\n| `--font-serif` | anywhere you ask for it |\n| `--font-mono` | code |\n\nEach stack is a family followed by its fallbacks, so a page still reads while a\nweb font loads, and still reads if it never does. **Project fonts**, in the\nColors and type editor, is where families come from: type a Google Fonts family\nname and the editor checks it, or paste a fonts URL, an embed tag, or your own\n`@font-face` rules. Removing a family puts the stack back on its fallbacks.\n\nYou can also set both faces at once from the command line:\n\n```bash\nnpx live-tokens set-fonts fonts.json\n```\n\nwith a brief naming the families:\n\n```json\n{ \"display\": \"Fraunces\", \"body\": \"Nunito Sans\" }\n```\n\nIt checks each family against Google Fonts, works out the weights that family\nactually has, and binds it to its stack. Like every other edit, the result lands\nin the buffer, so **Save** keeps it. In Claude Code, asking for a font pairing in\nplain English runs the same command.\n\nA font is only requested by the browser once something on the page uses it, so\ncarrying a family you no longer reference costs nothing at load. Adopting is\nwhat writes the font imports your site ships, into `fonts.css`.\n\n## Saving\n\nIn the Theme panel:\n\n- **Save** captures the look on screen into the open theme. Your colors and type\n go in as part of it, so there is nothing to save first.\n- **Save As** names a new theme. Use it for your first save and for forking.\n\nComponent editors keep their own unsaved state. If one or more components are\nwaiting when you use **Save**, **Save As**, or **Adopt**, the Theme panel offers\nto save all of them before continuing. You can accept once instead of visiting\neach component, or cancel to review them individually. A component editor's\n**Save As** creates a reusable component preset.\n\nNames are tidied to lowercase with hyphens, so \"My Brand!\" becomes `my-brand`,\nand a leading underscore is dropped: those names are reserved for the buffer.\n**Motion Proto** is the built-in theme and is read-only. You can always return\nto it, and the editor never overwrites it, so start your own with **Save As**.\n\n## Switching\n\n**Load**—or clicking the active theme's name—opens the Theme Picker. Picking a\ntheme shows it on the page as a preview with nothing written to disk, sketch\nlayer included, so you can try each look and compare. **Save** in that window\nopens and adopts the previewed theme in one step: the active pointer changes,\nthe buffers clear, the editor works on it, and production ships it. **Cancel**\nreturns you to where you were, unsaved sketch dials included. Previewing alone\nnever changes what your site ships.\n\n**Colors and type only. Keep my shapes.** narrows the load to the palette and\nthe fonts: your component settings and your sketch layer stay as they are, and\nthe theme you have open stays open. Saved colors and type files are listed\nthere too, marked *colors & type*, and picking one is always that narrower\nload.\n\n## Shipping\n\n**Adopt**, in the Theme panel, is the \"ship it\" step. It saves the open theme,\nthen bakes the colors and type plus every component the theme carries into\n`src/live-tokens/data/tokens.generated.css`, which your build bundles alongside\n`tokens.css`. The sketch layer is the one part of the theme Adopt never bakes:\nit stays a preview. Fonts regenerate to match. The line under the theme name\nsays whether production is running this theme.\n\nProduction is one saved theme, so nothing else publishes. Trying a look, moving\na token, saving a theme: all of it leaves the generated CSS alone until you\nAdopt. A component editor's Adopt runs the same save-then-bake step, because a\ncomponent never ships alone. Adopting while Motion Proto is open saves your look\nas a theme of your own first, since the built-in one is read-only.\n\nProduction builds (`npm run build`) ship only that plain CSS and your\ncomponents. No editor, no JSON loading, no runtime indirection.\n\n## Keeping your work safe\n\nEverything under `src/live-tokens/data/` is plain JSON, so commit it. Themes show\nup as readable diffs you can review per branch, and the buffer shows up as the\nwork you have not saved into a theme yet. Nothing is backed up anywhere else:\ngit is your safety net. To experiment freely, **Save As** a new name first, then\nedit.\n\n## Where to go next\n\n- **[Where themes live](where-themes-live.md)**: the files behind all of this,\n and what writes each one.\n- **[Creating components](creating-components.md)**: make your own components\n editable in the same editor.\n",
12
12
  "where-themes-live": "# Where themes live\n\nEverything the editor writes is plain JSON and CSS inside your project. There\nis no database and no hidden state: the files are the storage, and git is the\nhistory.\n\n## The data tree\n\n```\nsrc/live-tokens/data/\n themes/\n _active.json names the theme the editor has open\n _production.json names the theme your site ships\n default.json Motion Proto, the built-in look, rewritten at boot\n my-brand.json a saved theme: the whole look in one file\n colors-and-type/\n _working.json unsaved colors and type edits\n component-configs/\n button/\n default.json Button's shipped settings, derived at boot\n _working.json unsaved Button edits\n my-button.json a preset you saved from the Button editor\n sketch-styles/\n my-look.json a sketchstyle saved from the Sketchstyle view\n tokens.generated.css the baked CSS your production build ships\nsrc/system/styles/\n tokens.css your token vocabulary, hand-authored, never written\n fonts.css font imports, rewritten when you Adopt\n```\n\nA saved theme carries the whole look by value: the colors and type, a\nsetting for every component, and the sketch layer. It depends on no other\nfile, so deleting anything else never breaks it.\n\n## What writes when\n\n- **Editing** changes the page through CSS variables. The editor keeps your\n edits in the browser as you work and writes them to the `_working.json`\n buffers when you save a component. When the Theme panel finds several dirty\n components, **Save all** writes those buffers together.\n- **Save** captures the buffers into the open theme's file, along with the\n sketch layer, which has no buffer of its own and lives only in the browser\n until Save writes it. That file is the durable copy of your look; matching\n buffers are then removed.\n- **Load** clears the buffers and points `themes/_active.json` at the theme you\n picked. Live reads fall through to that file. Nothing else changes, so trying\n looks is free and ordinary switching changes only the pointer.\n- **Adopt** points `themes/_production.json` at the open theme, bakes it into\n `tokens.generated.css`, and rewrites `fonts.css` to match. It is the only\n action that changes what your site ships.\n\nThe `default.json` files are the shipped baseline. The editor derives them at\nboot and refreshes them when the package updates; it never saves your work\nover them.\n\nProjects upgraded from 0.48 may initially contain working files copied from the\nactive theme. On the first dev-server boot, exact copies are removed\nautomatically. Any file that differs is kept as unsaved work, so no migration\ncommand is required.\n\n## What to commit\n\nAll of it. The data tree is designed to live in git: themes diff readably, the\ntwo pointers say what is open and what ships, and a `_working.json` in a diff\nis exactly the work you have not yet saved into a theme. Nothing is backed up\nanywhere else.\n\n## Where to go next\n\n- **[Themes](themes-workflow.md)**: the workflow built on these files: saving,\n loading, and shipping.\n",
13
13
  };
@@ -4,13 +4,12 @@
4
4
  import UISegmentedControl from '../UISegmentedControl.svelte';
5
5
  import SketchDial from './SketchDial.svelte';
6
6
  import SketchRange from './SketchRange.svelte';
7
- import { buildMaskUri } from '../../core/sketch/maskField';
7
+ import { buildMaskUri, maskLattice } from '../../core/sketch/maskField';
8
8
  import SketchPreview from './SketchPreview.svelte';
9
9
  import { onMount } from 'svelte';
10
10
  import UIPillButton from '../UIPillButton.svelte';
11
11
  import UIReveal, { REVEAL_MS } from '../UIReveal.svelte';
12
12
  import { scrollSectionIntoView } from '../scrollSection';
13
- import { SKETCH_STYLES } from '../../core/sketch/sketchStyles';
14
13
  import { openThemeSlug } from '../../core/store/editorConfigStore';
15
14
  import {
16
15
  sketchEnabled,
@@ -21,13 +20,12 @@
21
20
  sketchSettings,
22
21
  selectSketchStyle,
23
22
  updateSketchSettings,
24
- savedSketchStyles,
25
23
  refreshSavedSketchStyles,
26
- selectSavedSketchStyle,
27
24
  saveCurrentSketchStyle,
25
+ saveSelectedSketchStyle,
28
26
  deleteSavedSketchStyle,
29
- USER_STYLE_PREFIX,
30
27
  } from '../../core/sketch/sketchStore';
28
+ import { sketchLooks } from '../../core/sketch/sketchRegistry';
31
29
 
32
30
  interface Props {
33
31
  /** The rail's last jump. A fresh object per click, not a bare id, so
@@ -100,6 +98,13 @@
100
98
 
101
99
  const layers = (n: number) => (n === 1 ? '1 layer' : `${n} layers`);
102
100
 
101
+ /** One number while the blob dials are linked, both once they are not: a
102
+ stretched field is the thing you would open the section to check. */
103
+ const blobSummary = () =>
104
+ s.maskBlobX === s.maskBlobY
105
+ ? `${s.maskBlobX}px`
106
+ : `${s.maskBlobX}×${s.maskBlobY}px${blobAngle === 0 ? '' : ` at ${blobAngle}°`}`;
107
+
103
108
  /** Trigger-row summaries: the settings you would open the section to check. */
104
109
  let summary = $derived({
105
110
  border: `${s.strokeWidth}px · ${s.strokeStyle} · ${passLabel(s.doubleStroke)}`
@@ -107,7 +112,7 @@
107
112
  + (s.borderWavelength === 1 ? '' : ` · ${against(s.borderWavelength)} wave`)
108
113
  + (s.strokeInk < 1 ? ` · ${Math.round(s.strokeInk * 100)}% ink` : ''),
109
114
  fill: `${s.fillStyle} · ${s.jitterX === 0 && s.jitterY === 0 && s.jitterRot === 0 ? 'aligned' : `±${s.jitterX}, ${s.jitterY}px`}`
110
- + (s.maskOn ? ` · ${s.maskBlob}px · ${layers(s.maskOctaves)}` : ' · no mask'),
115
+ + (s.maskOn ? ` · ${blobSummary()} · ${layers(s.maskOctaves)}` : ' · no mask'),
111
116
  shape: s.cornerSpread === 0 && s.cornerTravel === 0
112
117
  ? 'true to the theme'
113
118
  : `±${s.cornerSpread}px corners · ${px(s.cornerTravel)} travel`,
@@ -130,6 +135,34 @@
130
135
  : { name: s.label, blurb: s.blurb || 'Your saved sketchstyle.' },
131
136
  );
132
137
 
138
+ let selectedLook = $derived($sketchLooks.find((l) => l.id === $sketchStyleName));
139
+ /** Offered whenever the dials have moved off the sketchstyle they name. A
140
+ look backed by a project file is written over. A shipped one's file lives
141
+ in the package, so saving it writes this project's own under the same
142
+ name, which is how a project comes to own its Pencil: the id is the same,
143
+ so the new file takes the shipped one's place in the grid rather than
144
+ sitting beside it. Nothing is lost either way, since deleting that file
145
+ uncovers the packaged one again. */
146
+ let canSave = $derived(!!selectedLook && $sketchDirty);
147
+ let saveTitle = $derived(
148
+ !selectedLook
149
+ ? 'Pick a sketchstyle to save over'
150
+ : !$sketchDirty
151
+ ? 'No changes to save'
152
+ : selectedLook.source === 'file'
153
+ ? `Save over ${selectedLook.label}`
154
+ : `Keep these dials as this project's ${selectedLook.label}`,
155
+ );
156
+
157
+ function saveInPlace() {
158
+ if (!selectedLook) return;
159
+ runStyleAction(
160
+ selectedLook.source === 'file'
161
+ ? saveSelectedSketchStyle()
162
+ : saveCurrentSketchStyle(selectedLook.label),
163
+ );
164
+ }
165
+
133
166
  let naming = $state(false);
134
167
  let draftName = $state('');
135
168
  let styleError = $state('');
@@ -141,7 +174,7 @@
141
174
  });
142
175
 
143
176
  function startNaming() {
144
- draftName = s.label && $sketchStyleName.startsWith(USER_STYLE_PREFIX) ? s.label : '';
177
+ draftName = '';
145
178
  styleError = '';
146
179
  naming = true;
147
180
  }
@@ -194,11 +227,11 @@
194
227
 
195
228
  // The mask's dials are the stages the field is built in, in the order they
196
229
  // run: make the noise, level it, soften it.
197
- /** Blobs much bigger than a component stop reading as coverage: one patch
198
- spans a whole button, so it is either untouched or gone entirely. The
199
- ceiling is a few blobs across a card, which is where it still reads as
200
- uneven ink. */
201
- const SIZE = { min: 20, max: 250 };
230
+ /** The field is painted at whatever the dials say now, rather than fitted to
231
+ a fixed tile, so the travel is only bounded by what still reads: speckle
232
+ finer than 8px is a texture rather than coverage, and a blob past 600px
233
+ covers a whole card in one patch, which the stretched end wants. */
234
+ const SIZE = { min: 8, max: 600 };
202
235
  const BLUR_MAX = 64;
203
236
  /** Squared response. A blur only reads as a different blur while it is small,
204
237
  so a linear walk to 64px would spend a tenth of the dial on everything
@@ -220,9 +253,36 @@
220
253
  const logVal = (t: number, r: { min: number; max: number }) =>
221
254
  r.min * Math.pow(r.max / r.min, Math.min(1, Math.max(0, t)));
222
255
 
223
- let scalePos = $derived(logPos(s.maskBlob, SIZE));
224
- const setScale = (v: number) =>
225
- updateSketchSettings({ maskBlob: Math.round(logVal(v / 100, SIZE) / 5) * 5 });
256
+ let scaleXPos = $derived(logPos(s.maskBlobX, SIZE));
257
+ let scaleYPos = $derived(logPos(s.maskBlobY, SIZE));
258
+ /** Rounded to a whole px, and to fives above a hundred, where a single px is
259
+ under half a percent of the blob and only makes the readout twitch. */
260
+ const scaleVal = (t: number) => {
261
+ const px = logVal(t / 100, SIZE);
262
+ return px < 100 ? Math.round(px) : Math.round(px / 5) * 5;
263
+ };
264
+ const setScaleX = (v: number) => {
265
+ const maskBlobX = scaleVal(v);
266
+ updateSketchSettings(s.maskBlobLinked ? { maskBlobX, maskBlobY: maskBlobX } : { maskBlobX });
267
+ };
268
+ const setScaleY = (v: number) => {
269
+ const maskBlobY = scaleVal(v);
270
+ updateSketchSettings(s.maskBlobLinked ? { maskBlobX: maskBlobY, maskBlobY } : { maskBlobY });
271
+ };
272
+ /** The turn the tile can actually hold, which is not always the one asked
273
+ for: only the angles that land the page's axes back on whole noise cells
274
+ leave a tile that meets itself. */
275
+ let blobAngle = $derived(Math.round(maskLattice(s).angle));
276
+
277
+ /** Linking again squares the field off on the width, which is the axis the
278
+ pair reads from left to right. Leaving them apart would make the chain a
279
+ claim the dials contradict. */
280
+ const toggleBlobLink = () =>
281
+ updateSketchSettings(
282
+ s.maskBlobLinked
283
+ ? { maskBlobLinked: false }
284
+ : { maskBlobLinked: true, maskBlobY: s.maskBlobX },
285
+ );
226
286
  let outputMin = $derived(Math.round(s.maskOutputMin * 100));
227
287
  let outputMax = $derived(Math.round(s.maskOutputMax * 100));
228
288
  let stepPos = $derived(Math.max(0, STEP_TONES.indexOf(s.maskPosterize)));
@@ -285,25 +345,49 @@
285
345
  </div>
286
346
 
287
347
  <div class="presets">
288
- {#each Object.entries(SKETCH_STYLES) as [name, style] (name)}
289
- <label class="preset">
290
- <input
291
- type="radio"
292
- name={STYLE_RADIO_GROUP}
293
- value={name}
294
- checked={$sketchStyleName === name}
295
- onchange={() => selectSketchStyle(name)}
296
- />
297
- <span class="preset-name">{style.label}</span>
298
- </label>
348
+ {#each $sketchLooks as look (look.id)}
349
+ <div class="saved-item">
350
+ <label class="preset">
351
+ <input
352
+ type="radio"
353
+ name={STYLE_RADIO_GROUP}
354
+ value={look.id}
355
+ checked={$sketchStyleName === look.id}
356
+ onchange={() => selectSketchStyle(look.id)}
357
+ />
358
+ <span class="preset-name">{look.label}</span>
359
+ </label>
360
+ {#if look.source === 'file'}
361
+ <button
362
+ type="button"
363
+ class="saved-delete"
364
+ title="Delete {look.label}"
365
+ aria-label="Delete {look.label}"
366
+ onclick={() => runStyleAction(deleteSavedSketchStyle(look.id))}
367
+ ><i class="fas fa-xmark"></i></button>
368
+ {/if}
369
+ </div>
299
370
  {/each}
300
371
  </div>
301
372
 
302
373
  <div class="saved">
303
- <div class="saved-head">
304
- <span class="band-label">Saved sketchstyles</span>
305
- <UIPillButton size="compact" icon="fa-floppy-disk" onclick={startNaming}>
306
- Save as sketchstyle…
374
+ <div class="saved-actions">
375
+ <UIPillButton
376
+ size="compact"
377
+ icon="fa-floppy-disk"
378
+ disabled={!canSave}
379
+ title={saveTitle}
380
+ onclick={saveInPlace}
381
+ >
382
+ Save
383
+ </UIPillButton>
384
+ <UIPillButton
385
+ size="compact"
386
+ icon="fa-plus"
387
+ title="Keep these dials under a name of your own"
388
+ onclick={startNaming}
389
+ >
390
+ Save As
307
391
  </UIPillButton>
308
392
  </div>
309
393
 
@@ -322,32 +406,6 @@
322
406
  </form>
323
407
  {/if}
324
408
 
325
- {#if $savedSketchStyles.length > 0}
326
- <div class="presets">
327
- {#each $savedSketchStyles as saved (saved.fileName)}
328
- <div class="saved-item">
329
- <label class="preset">
330
- <input
331
- type="radio"
332
- name={STYLE_RADIO_GROUP}
333
- value={USER_STYLE_PREFIX + saved.fileName}
334
- checked={$sketchStyleName === USER_STYLE_PREFIX + saved.fileName}
335
- onchange={() => runStyleAction(selectSavedSketchStyle(saved.fileName))}
336
- />
337
- <span class="preset-name">{saved.name}</span>
338
- </label>
339
- <button
340
- type="button"
341
- class="saved-delete"
342
- title="Delete {saved.name}"
343
- aria-label="Delete {saved.name}"
344
- onclick={() => runStyleAction(deleteSavedSketchStyle(saved.fileName))}
345
- ><i class="fas fa-xmark"></i></button>
346
- </div>
347
- {/each}
348
- </div>
349
- {/if}
350
-
351
409
  {#if styleError}
352
410
  <p class="saved-error">{styleError}</p>
353
411
  {/if}
@@ -577,13 +635,44 @@
577
635
  onchange={(v) => updateSketchSettings({ maskGrain: v as 'fractal' | 'turbulence' })}
578
636
  />
579
637
  </div>
580
- <SketchDial
581
- label="Scale" value={scalePos} min={0} max={100} step={1}
582
- readout={`${s.maskBlob}px`}
583
- ends={['speckle', 'patches']}
584
- hint="Blob size on the page. Small reads as speckle, large as patches."
585
- onchange={setScale}
586
- />
638
+ <div class="pair" class:linked={s.maskBlobLinked}>
639
+ <button
640
+ type="button"
641
+ class="pair-link"
642
+ aria-pressed={s.maskBlobLinked}
643
+ aria-label={s.maskBlobLinked ? 'Unlink the two scales' : 'Link the two scales'}
644
+ title={s.maskBlobLinked
645
+ ? 'Both axes move together. Click to scale them on their own.'
646
+ : 'Each axis on its own. Click to move them together.'}
647
+ onclick={toggleBlobLink}
648
+ >
649
+ <i class="fas" class:fa-link={s.maskBlobLinked} class:fa-link-slash={!s.maskBlobLinked}
650
+ aria-hidden="true"></i>
651
+ </button>
652
+ <div class="pair-dials">
653
+ <SketchDial
654
+ label="Scale across" value={scaleXPos} min={0} max={100} step={1}
655
+ readout={`${s.maskBlobX}px`}
656
+ hint="Blob width on the page. Small reads as speckle, large as patches."
657
+ onchange={setScaleX}
658
+ />
659
+ <SketchDial
660
+ label="Scale down" value={scaleYPos} min={0} max={100} step={1}
661
+ readout={`${s.maskBlobY}px`}
662
+ ends={['speckle', 'patches']}
663
+ hint="Blob height. Unlink the two to stretch the field: wide and short reads as ink dragged sideways."
664
+ onchange={setScaleY}
665
+ />
666
+ </div>
667
+ </div>
668
+ {#if !s.maskBlobLinked}
669
+ <SketchDial
670
+ label="Rotation" value={s.maskAngle} min={0} max={180} step={1}
671
+ readout={`${blobAngle}°`}
672
+ hint="Which way the stretch runs. The tile has to meet itself, so the turn lands on the nearest angle that does."
673
+ onchange={(v) => updateSketchSettings({ maskAngle: v })}
674
+ />
675
+ {/if}
587
676
  <SketchDial
588
677
  label="Detail" value={s.maskOctaves} min={1} max={4} step={1}
589
678
  readout={layers(s.maskOctaves)}
@@ -916,20 +1005,13 @@
916
1005
  border-top: 1px solid var(--ui-border-low);
917
1006
  }
918
1007
 
919
- .saved-head {
1008
+ .saved-actions {
920
1009
  display: flex;
921
1010
  align-items: center;
922
- justify-content: space-between;
923
- gap: var(--ui-space-8);
1011
+ gap: var(--ui-space-6);
924
1012
  min-height: 1.75rem;
925
1013
  }
926
1014
 
927
- .band-label {
928
- font-size: var(--ui-font-size-xs);
929
- font-weight: var(--ui-font-weight-semibold);
930
- color: var(--ui-text-tertiary);
931
- }
932
-
933
1015
  .save-row {
934
1016
  display: flex;
935
1017
  align-items: center;
@@ -953,8 +1035,8 @@
953
1035
  outline-offset: 1px;
954
1036
  }
955
1037
 
956
- /* The row is one control with a delete affordance, so the border lives here
957
- and the inner .preset label drops its own. */
1038
+ /* A row is one control, with a delete affordance on the ones this project
1039
+ owns, so the border lives here and the inner .preset label drops its own. */
958
1040
  .saved-item {
959
1041
  display: flex;
960
1042
  align-items: stretch;
@@ -1155,6 +1237,69 @@
1155
1237
  background: var(--ui-border-high);
1156
1238
  }
1157
1239
 
1240
+ /* Two dials under one chain: the bracket is drawn on the gutter, and the
1241
+ button sits on top of it with a punched-out background so the line reads as
1242
+ running behind the glyph rather than into it. */
1243
+ .pair {
1244
+ display: grid;
1245
+ grid-template-columns: var(--ui-space-24) 1fr;
1246
+ gap: var(--ui-space-10);
1247
+ }
1248
+
1249
+ .pair-dials {
1250
+ display: grid;
1251
+ gap: var(--ui-space-12);
1252
+ }
1253
+
1254
+ .pair-link {
1255
+ position: relative;
1256
+ align-self: center;
1257
+ justify-self: stretch;
1258
+ display: flex;
1259
+ align-items: center;
1260
+ justify-content: center;
1261
+ padding: 0;
1262
+ height: 100%;
1263
+ background: none;
1264
+ border: none;
1265
+ color: var(--ui-text-tertiary);
1266
+ cursor: pointer;
1267
+ }
1268
+
1269
+ /* The bracket. Right-hand side open, so it reaches for the dials it holds. */
1270
+ .pair-link::before {
1271
+ content: '';
1272
+ position: absolute;
1273
+ inset: var(--ui-space-8) 0 var(--ui-space-8) var(--ui-space-4);
1274
+ border: 1px solid var(--ui-border);
1275
+ border-right: none;
1276
+ border-radius: var(--ui-radius-sm) 0 0 var(--ui-radius-sm);
1277
+ }
1278
+
1279
+ .pair-link i {
1280
+ position: relative;
1281
+ padding: var(--ui-space-4) 0;
1282
+ background: var(--ui-surface-low);
1283
+ font-size: var(--ui-font-size-sm);
1284
+ }
1285
+
1286
+ .pair-link:hover,
1287
+ .pair-link:focus-visible {
1288
+ color: var(--ui-text-primary);
1289
+ }
1290
+
1291
+ /* Broken chain, broken bracket: the two dials are no longer held together. */
1292
+ .pair:not(.linked) .pair-link::before {
1293
+ border-color: var(--ui-border-low);
1294
+ border-style: dashed;
1295
+ }
1296
+
1297
+ .pair-link:focus-visible {
1298
+ outline: 2px solid var(--ui-highlight);
1299
+ outline-offset: 2px;
1300
+ border-radius: var(--ui-radius-sm);
1301
+ }
1302
+
1158
1303
  .phase h5 {
1159
1304
  margin: var(--ui-space-8) 0 0;
1160
1305
  font-size: var(--ui-font-size-xs);
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "Dashed",
3
+ "settings": {
4
+ "label": "Dashed",
5
+ "blurb": "A drafting outline. One slow drift along the ruler, broken into strokes, with jitter, mask and pressure all off. The clean pole.",
6
+ "fillTravel": 0.5,
7
+ "strokeTravel": 1,
8
+ "wobble": 120,
9
+ "roughness": 1,
10
+ "borderWavelength": 1,
11
+ "waveform": 1,
12
+ "strokeWidth": 1.5,
13
+ "doubleStroke": false,
14
+ "retraceOffset": 1.2,
15
+ "retracePass": "copy",
16
+ "fillStyle": "solid",
17
+ "hatchInk": 0.4,
18
+ "strokeStyle": "dashed",
19
+ "pressure": 0,
20
+ "pressureMod": 0,
21
+ "pooling": 0,
22
+ "strokeInk": 1,
23
+ "maskOn": false,
24
+ "maskBlobX": 100,
25
+ "maskBlobY": 100,
26
+ "maskBlobLinked": true,
27
+ "maskAngle": 0,
28
+ "maskOutputMin": 0.45,
29
+ "maskOutputMax": 1,
30
+ "maskOctaves": 2,
31
+ "maskGrain": "fractal",
32
+ "maskPosterize": 1,
33
+ "maskSoftness": 1.5,
34
+ "jitterX": 0,
35
+ "jitterY": 0,
36
+ "jitterRot": 0,
37
+ "jitterScale": 0,
38
+ "cornerSpread": 4,
39
+ "cornerTravel": 3,
40
+ "iconTravel": 0,
41
+ "iconWavelength": 0.625,
42
+ "iconMaskOn": false,
43
+ "iconMaskScale": 1
44
+ },
45
+ "updatedAt": "2026-08-28T15:47:36.934Z",
46
+ "createdAt": "2026-08-28T15:47:36.934Z"
47
+ }
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "Dry marker",
3
+ "settings": {
4
+ "label": "Dry marker",
5
+ "blurb": "Ink that ran out. One scratchy pass that breaks up along its length, over a fill the mask has worn nearly through in patches.",
6
+ "fillTravel": 2.25,
7
+ "strokeTravel": 1.75,
8
+ "wobble": 50,
9
+ "roughness": 3,
10
+ "borderWavelength": 0.5,
11
+ "waveform": 2,
12
+ "strokeWidth": 3.5,
13
+ "doubleStroke": false,
14
+ "retraceOffset": 1.2,
15
+ "retracePass": "copy",
16
+ "fillStyle": "solid",
17
+ "hatchInk": 0.4,
18
+ "strokeStyle": "solid",
19
+ "pressure": 0.4,
20
+ "pressureMod": 0.8,
21
+ "pooling": 1.5,
22
+ "strokeInk": 0.4,
23
+ "maskOn": true,
24
+ "maskBlobX": 150,
25
+ "maskBlobY": 150,
26
+ "maskBlobLinked": true,
27
+ "maskAngle": 0,
28
+ "maskOutputMin": 0.24,
29
+ "maskOutputMax": 0.91,
30
+ "maskOctaves": 2,
31
+ "maskGrain": "fractal",
32
+ "maskPosterize": 4,
33
+ "maskSoftness": 1.75,
34
+ "jitterX": 5,
35
+ "jitterY": 5,
36
+ "jitterRot": 1.4,
37
+ "jitterScale": 0.08,
38
+ "cornerSpread": 16,
39
+ "cornerTravel": 13,
40
+ "iconTravel": 1.75,
41
+ "iconWavelength": 0.625,
42
+ "iconMaskOn": true,
43
+ "iconMaskScale": 3.8
44
+ },
45
+ "updatedAt": "2026-08-28T15:47:36.934Z",
46
+ "createdAt": "2026-08-28T15:47:36.934Z"
47
+ }
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "Hatched",
3
+ "settings": {
4
+ "label": "Hatched",
5
+ "blurb": "An etching. The fill is angled shading, the outline a single hard-edged scratch that chatters along its length. No mask: the hatch is the texture.",
6
+ "fillTravel": 1.25,
7
+ "strokeTravel": 1.5,
8
+ "wobble": 24,
9
+ "roughness": 3,
10
+ "borderWavelength": 1,
11
+ "waveform": 3,
12
+ "strokeWidth": 1.5,
13
+ "doubleStroke": false,
14
+ "retraceOffset": 1.2,
15
+ "retracePass": "copy",
16
+ "fillStyle": "hatched",
17
+ "hatchInk": 0.5,
18
+ "strokeStyle": "solid",
19
+ "pressure": 0.3,
20
+ "pressureMod": 0.45,
21
+ "pooling": 0.8,
22
+ "strokeInk": 1,
23
+ "maskOn": false,
24
+ "maskBlobX": 100,
25
+ "maskBlobY": 100,
26
+ "maskBlobLinked": true,
27
+ "maskAngle": 0,
28
+ "maskOutputMin": 0.45,
29
+ "maskOutputMax": 1,
30
+ "maskOctaves": 2,
31
+ "maskGrain": "fractal",
32
+ "maskPosterize": 1,
33
+ "maskSoftness": 1.5,
34
+ "jitterX": 1.5,
35
+ "jitterY": 1.5,
36
+ "jitterRot": 0.4,
37
+ "jitterScale": 0.03,
38
+ "cornerSpread": 6,
39
+ "cornerTravel": 6,
40
+ "iconTravel": 1.25,
41
+ "iconWavelength": 0.5,
42
+ "iconMaskOn": false,
43
+ "iconMaskScale": 1
44
+ },
45
+ "updatedAt": "2026-08-28T15:47:36.934Z",
46
+ "createdAt": "2026-08-28T15:47:36.934Z"
47
+ }