@motion-proto/live-tokens 0.78.0 → 0.79.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-check-compliance/SKILL.md +60 -31
- package/.claude/skills/live-tokens-create-component/SKILL.md +23 -28
- package/.claude/skills/live-tokens-create-component/references/contract-tests.md +61 -0
- package/.claude/skills/live-tokens-create-component/references/sketch-mode.md +2 -2
- package/.claude/skills/live-tokens-create-component/references/token-naming.md +6 -15
- package/.claude/skills/live-tokens-create-page/SKILL.md +6 -4
- package/.claude/skills/live-tokens-create-theme/references/design-directions.md +1 -1
- package/.claude/skills/live-tokens-pick-component/SKILL.md +3 -3
- package/.claude/skills/live-tokens-set-colors/references/color-anchors.md +1 -1
- package/.claude/skills/live-tokens-set-geometry/SKILL.md +1 -1
- package/.claude/skills/live-tokens-set-geometry/references/geometry-anchors.md +1 -1
- package/CHANGELOG.md +231 -0
- package/README.md +9 -15
- package/bin/check-component.mjs +152 -551
- package/bin/check-page.mjs +55 -541
- package/bin/cli.mjs +59 -13
- package/bin/contractRunner.mjs +37 -91
- package/bin/lib/catalogue.mjs +161 -34
- package/bin/lib/componentSource.mjs +152 -0
- package/bin/lib/cssValues.mjs +9 -0
- package/bin/lib/dataDir.mjs +126 -0
- package/bin/lib/findings.mjs +103 -12
- package/bin/lib/fixers.mjs +64 -0
- package/bin/lib/geometry.mjs +92 -0
- package/bin/lib/pageSource.mjs +230 -0
- package/bin/lib/report.mjs +57 -59
- package/bin/lib/tokenVocabulary.mjs +104 -34
- package/bin/rules/componentStructure.mjs +344 -0
- package/bin/rules/componentUse.mjs +313 -0
- package/bin/rules/importsAndRoutes.mjs +136 -0
- package/bin/rules/testRuns.mjs +122 -0
- package/bin/rules/tokens.mjs +363 -0
- package/bin/setup-claude.mjs +1 -2
- package/dist-plugin/{chunk-PDNL4NC5.js → chunk-D4WRIKEZ.js} +7 -2
- package/dist-plugin/{chunk-SWXRVZKT.js → chunk-REBHE3ZM.js} +414 -1
- package/dist-plugin/index.cjs +432 -15
- package/dist-plugin/index.js +8 -9
- package/dist-plugin/migrateData/index.cjs +422 -4
- package/dist-plugin/migrateData/index.js +2 -2
- package/dist-plugin/setColors/index.cjs +414 -1
- package/dist-plugin/setColors/index.d.cts +1 -1
- package/dist-plugin/setColors/index.d.ts +1 -1
- package/dist-plugin/setColors/index.js +1 -1
- package/dist-plugin/setGeometry/index.cjs +423 -13
- package/dist-plugin/setGeometry/index.d.cts +3 -3
- package/dist-plugin/setGeometry/index.d.ts +3 -3
- package/dist-plugin/setGeometry/index.js +10 -13
- package/dist-plugin/setType/index.d.cts +1 -1
- package/dist-plugin/setType/index.d.ts +1 -1
- package/dist-plugin/{themeTypes-BxRtuN5V.d.cts → themeTypes-B8_Idrp4.d.cts} +2 -2
- package/dist-plugin/{themeTypes-BxRtuN5V.d.ts → themeTypes-B8_Idrp4.d.ts} +2 -2
- package/package.json +2 -2
- package/src/editor/component-editor/CalloutEditor.svelte +2 -2
- package/src/editor/component-editor/CollapsibleSectionEditor.svelte +14 -15
- package/src/editor/component-editor/CornerBadgeEditor.svelte +14 -14
- package/src/editor/component-editor/DialogEditor.svelte +5 -5
- package/src/editor/component-editor/InlineEditActionsEditor.svelte +2 -2
- package/src/editor/component-editor/RadioButtonEditor.svelte +21 -21
- package/src/editor/component-editor/SectionDividerEditor.svelte +7 -7
- package/src/editor/component-editor/SegmentedControlEditor.svelte +5 -5
- package/src/editor/component-editor/SideNavigationEditor.svelte +25 -25
- package/src/editor/component-editor/TabBarEditor.svelte +6 -6
- package/src/editor/component-editor/TableEditor.svelte +6 -6
- package/src/editor/component-editor/ToggleEditor.svelte +2 -2
- package/src/editor/component-editor/index.ts +3 -0
- package/src/editor/component-editor/registry.ts +57 -1
- package/src/editor/component-editor/scaffolding/TokenLayout.svelte +14 -14
- package/src/editor/component-editor/scaffolding/VariantGroup.svelte +3 -0
- package/src/editor/component-editor/scaffolding/types.ts +15 -0
- package/src/editor/core/components/adjustAliases.ts +4 -4
- package/src/editor/core/components/aliasKinds.ts +20 -19
- package/src/editor/core/sketch/sketchLayer.ts +3 -3
- package/src/editor/core/themes/migrateComponentConfig.ts +14 -6
- package/src/editor/core/themes/migrations/2026-09-13-badge-brand.ts +42 -0
- package/src/editor/core/themes/migrations/2026-09-13-collapsiblesection-open.ts +33 -0
- package/src/editor/core/themes/migrations/2026-09-13-cornerbadge-prefix.ts +70 -0
- package/src/editor/core/themes/migrations/2026-09-13-hairline.ts +92 -0
- package/src/editor/core/themes/migrations/2026-09-13-indicator.ts +54 -0
- package/src/editor/core/themes/migrations/2026-09-13-sectiondivider-surface.ts +36 -0
- package/src/editor/core/themes/migrations/2026-09-13-selected-state.ts +124 -0
- package/src/editor/core/themes/migrations/2026-09-13-toggle-label.ts +31 -0
- package/src/editor/core/themes/migrations/index.ts +16 -0
- package/src/editor/core/themes/themeService.ts +3 -3
- package/src/editor/core/themes/themeTypes.ts +13 -15
- package/src/editor/docs/Docs.svelte +1 -1
- package/src/editor/docs/content/light-and-dark.md +3 -3
- package/src/editor/docs/content.generated.ts +1 -1
- package/src/editor/index.ts +1 -0
- package/src/editor/overlay/LiveEditorOverlay.svelte +15 -0
- package/src/editor/skill-atlas/SkillAtlas.svelte +4 -4
- package/src/editor/skill-atlas/TreeNodeCard.svelte +4 -4
- package/src/editor/skill-atlas/skillSources.generated.ts +11 -14
- package/src/editor/skill-atlas/skillTrees.ts +1 -3
- package/src/editor/skill-atlas/trees/check-compliance.ts +258 -93
- package/src/editor/skill-atlas/trees/create-component.ts +73 -62
- package/src/editor/skill-atlas/trees/create-page.ts +38 -17
- package/src/editor/skill-atlas/trees/pick-component.ts +3 -3
- package/src/editor/skill-atlas/trees/set-geometry.ts +1 -1
- package/src/editor/ui/UIPaletteSelector.svelte +11 -15
- package/src/editor/ui/variantScales.ts +8 -8
- package/src/live-tokens/data/themes/autumn.json +188 -188
- package/src/live-tokens/data/themes/halloween.json +188 -188
- package/src/live-tokens/data/themes/midnight-study.json +245 -245
- package/src/live-tokens/data/themes/ocean.json +188 -188
- package/src/live-tokens/data/themes/royal-velvet.json +188 -188
- package/src/live-tokens/data/themes/sketchy.json +188 -188
- package/src/live-tokens/data/themes/spring-meadow.json +188 -188
- package/src/live-tokens/data/themes/sunset.json +188 -188
- package/src/system/components/Badge.svelte +27 -23
- package/src/system/components/Button.svelte +13 -7
- package/src/system/components/Callout.svelte +16 -11
- package/src/system/components/Card.svelte +22 -15
- package/src/system/components/CodeSnippet.svelte +10 -6
- package/src/system/components/CollapsibleSection.svelte +68 -63
- package/src/system/components/CornerBadge.svelte +78 -72
- package/src/system/components/Dialog.svelte +21 -18
- package/src/system/components/IconButton.svelte +13 -9
- package/src/system/components/Image.svelte +14 -8
- package/src/system/components/ImageLightbox.svelte +10 -6
- package/src/system/components/InlineEditActions.svelte +17 -14
- package/src/system/components/Input.svelte +13 -7
- package/src/system/components/MenuSelect.svelte +13 -7
- package/src/system/components/Notification.svelte +17 -11
- package/src/system/components/Panel.svelte +13 -6
- package/src/system/components/ProgressBar.svelte +10 -5
- package/src/system/components/RadioButton.svelte +33 -30
- package/src/system/components/SectionDivider.svelte +28 -21
- package/src/system/components/SegmentedControl.svelte +27 -23
- package/src/system/components/SideNavigation.svelte +175 -171
- package/src/system/components/Slider.svelte +11 -7
- package/src/system/components/TabBar.svelte +53 -49
- package/src/system/components/Table.svelte +20 -15
- package/src/system/components/Toggle.svelte +14 -10
- package/src/system/components/Tooltip.svelte +10 -6
- package/src/system/styles/CONVENTIONS.md +3 -4
- package/src/testing-js/chunk-3UKGXCDL.js +48 -0
- package/src/testing-js/chunk-3UKGXCDL.js.map +1 -0
- package/src/testing-js/{chunk-FAFOAWYL.js → chunk-Q3YIAAG3.js} +17 -3
- package/src/testing-js/chunk-Q3YIAAG3.js.map +1 -0
- package/src/testing-js/{chunk-GNIUPIU2.js → chunk-U7OJE5DU.js} +18 -18
- package/src/testing-js/chunk-U7OJE5DU.js.map +1 -0
- package/src/testing-js/{chunk-4JQX6WWL.js → chunk-ZMZQZ33J.js} +474 -166
- package/src/testing-js/chunk-ZMZQZ33J.js.map +1 -0
- package/src/testing-js/component-behavior.contract.js +155 -0
- package/src/testing-js/component-behavior.contract.js.map +1 -0
- package/src/testing-js/component-editor.contract.js +6 -4
- package/src/testing-js/component-editor.contract.js.map +1 -1
- package/src/testing-js/component-render.contract.js +14 -10
- package/src/testing-js/component-render.contract.js.map +1 -1
- package/src/testing-js/index.d.ts +44 -4
- package/src/testing-js/index.js +13 -7
- package/src/testing-js/index.js.map +1 -1
- package/src/testing-js/page-compliance.contract.js +48 -10
- package/src/testing-js/page-compliance.contract.js.map +1 -1
- package/src/testing-js/registry.contract.js +5 -3
- package/src/testing-js/registry.contract.js.map +1 -1
- package/src/testing-js/{vitest-C-wNWcoA.d.ts → vitest-BMLIbDs2.d.ts} +8 -2
- package/src/testing-js/vitest.d.ts +1 -1
- package/src/testing-js/vitest.js +2 -1
- package/template/package.json +1 -1
- package/.claude/skills/live-tokens-create-component/SKILL copy.md +0 -196
- package/.claude/skills/live-tokens-fix-findings/SKILL.md +0 -105
- package/src/editor/skill-atlas/trees/fix-findings.ts +0 -504
- package/src/testing-js/chunk-4JQX6WWL.js.map +0 -1
- package/src/testing-js/chunk-FAFOAWYL.js.map +0 -1
- package/src/testing-js/chunk-GNIUPIU2.js.map +0 -1
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
app---
|
|
2
|
-
name: live-tokens-create-component
|
|
3
|
-
description: Create a custom Svelte component in a @motion-proto/live-tokens project with semantic properties that reference the existing theme tokens, a live editor, and registration. Use for a new component or to make an existing component editable. Use live-tokens-create-page to place existing components on a page.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Creating a Live Tokens component
|
|
7
|
-
|
|
8
|
-
Create a component whose structure and behavior serve the user's purpose. Give each editable visual property a semantic name and assign its default from the design system's existing token vocabulary. Deliver the runtime component, its editor, and its registration together.
|
|
9
|
-
|
|
10
|
-
## Design model
|
|
11
|
-
|
|
12
|
-
Live Tokens has two token layers:
|
|
13
|
-
|
|
14
|
-
| Layer | Responsibility | Example |
|
|
15
|
-
|---|---|---|
|
|
16
|
-
| Theme tokens | Define the available colors, typography, geometry, and motion values. Theme presets change these values. | `--space-16`, `--radius-md`, `--surface-neutral` |
|
|
17
|
-
| Component properties | Name the visual roles within a component and reference theme tokens. Component presets record these assignments. | `--statcard-frame-padding: var(--space-16)` |
|
|
18
|
-
|
|
19
|
-
The rendering chain is **theme token → semantic component property → CSS declaration**. The editor changes the assignment; the runtime reads the property. Keep the assignment as a token reference so a theme change reaches the component.
|
|
20
|
-
|
|
21
|
-
A property describes its purpose: `--statcard-value-text`, `--statcard-frame-radius`, `--statcard-label-font-size`. Its name stays stable when its assigned color or size changes. Use role names such as `surface` and `text`, and full words for component ids and parts.
|
|
22
|
-
|
|
23
|
-
Build distinct components through their anatomy, proportions, content hierarchy, behavior, and choice of existing tokens. Create only the variants and states the task requires. Keep the theme vocabulary intact during component creation; a new theme token belongs in a separate theme change.
|
|
24
|
-
|
|
25
|
-
Component props carry content and behavior, such as `value`, `label`, `selected`, and callbacks. Semantic CSS properties carry the editable appearance. Expose variants through props when they represent meaningful component choices.
|
|
26
|
-
|
|
27
|
-
## Source inspection
|
|
28
|
-
|
|
29
|
-
Read the project's `package.json`, `live-tokens.config.json`, and application bootstrap before writing files. Run `npx live-tokens components` to inspect the catalogue and `npx live-tokens components <id>` for a candidate's props. Use an existing component when it fulfills the request; create a new component when the request needs distinct structure or behavior.
|
|
30
|
-
|
|
31
|
-
Locate the installed package at `node_modules/@motion-proto/live-tokens`. When working inside the Live Tokens repository, use the repository root instead. Read these sources from that root:
|
|
32
|
-
|
|
33
|
-
- `src/system/styles/tokens.css` for the available default tokens, and the project's theme files for overrides. Treat `tokens.generated.css` as generated output.
|
|
34
|
-
- `src/system/components/<Name>.svelte` and `src/editor/component-editor/<Name>Editor.svelte` for a matching runtime/editor pair. Use `Toggle` for interaction states, `Badge` for variants and linking, and `Card` for separate text and container parts.
|
|
35
|
-
- `src/editor/core/components/aliasKinds.ts` for the suffixes that select editor controls.
|
|
36
|
-
- `src/editor/component-editor/index.ts` and the package exports for available authoring APIs.
|
|
37
|
-
|
|
38
|
-
Use the current source as the contract when older prose differs. For example, the current brand color family uses `--surface-brand`, `--border-brand`, and `--text-brand`; `--text-primary` names neutral primary text.
|
|
39
|
-
|
|
40
|
-
Read [references/token-naming.md](references/token-naming.md) when choosing property suffixes. Read the other references at the steps that need them.
|
|
41
|
-
|
|
42
|
-
## Property design
|
|
43
|
-
|
|
44
|
-
Before implementation, identify the component's parts, text roles, variants, and states. Make a short property map that connects each editable role to an existing default token and the CSS property it controls. Keep separate roles independent even when they start with the same value.
|
|
45
|
-
|
|
46
|
-
| Component property | Default assignment | CSS use |
|
|
47
|
-
|---|---|---|
|
|
48
|
-
| `--statcard-frame-surface` | `--surface-neutral` | `background` |
|
|
49
|
-
| `--statcard-frame-border` | `--border-neutral` | `border-color` |
|
|
50
|
-
| `--statcard-frame-border-width` | `--border-width-1` | `border-width` |
|
|
51
|
-
| `--statcard-frame-radius` | `--radius-md` | `border-radius` |
|
|
52
|
-
| `--statcard-frame-padding` | `--space-16` | `padding` |
|
|
53
|
-
| `--statcard-value-text` | `--text-primary` | `color` |
|
|
54
|
-
| `--statcard-label-text` | `--text-secondary` | `color` |
|
|
55
|
-
|
|
56
|
-
Choose defaults from tokens that exist in the target project. Prefer the color role that matches the purpose: surfaces for fills, borders for outlines, and text tokens for text. Select geometry from the relevant spacing, radius, stroke, and icon scales. Give each text role its own family, size, weight, line height, and letter spacing properties, using existing typography tokens.
|
|
57
|
-
|
|
58
|
-
Name properties with the component id first and the property suffix last:
|
|
59
|
-
|
|
60
|
-
```text
|
|
61
|
-
--<componentId>-<part-or-variant>[-<state>][-<element>]-<property>
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
Use a lowercase id with no dashes that matches the runtime filename: `StatCard.svelte` has id `statcard`. Include the segments that distinguish the role. Follow the closest shipped component for components with both variants and parts. Put state segments before the final property: `--statcard-frame-hover-surface`.
|
|
65
|
-
|
|
66
|
-
The suffix selects the editor control. Use `-surface` for a fill, `-border` for border color, `-border-width` for stroke thickness, `-radius` for corners, and `-padding` or `-gap` for spacing. Use the full typography suffixes such as `-font-size`. Verify other suffixes against `aliasKinds.ts`.
|
|
67
|
-
|
|
68
|
-
## Runtime component
|
|
69
|
-
|
|
70
|
-
Create `src/system/components/StatCard.svelte`. Use Svelte 5 props and snippets, semantic HTML, and the behavior the task requires. Start with a short HTML comment that states the component's purpose, suitable uses, and an alternative for uses outside its scope. The component CLI reads this comment and `interface Props` to describe the component.
|
|
71
|
-
|
|
72
|
-
Declare every editable property explicitly in a literal `:global(:root)` block. The discovery parser reads the Svelte source to seed `component-configs/<id>/default.json`; it needs concrete property names. Keep SCSS loops and interpolation out of this declaration block.
|
|
73
|
-
|
|
74
|
-
```svelte
|
|
75
|
-
<style>
|
|
76
|
-
:global(:root) {
|
|
77
|
-
--statcard-frame-surface: var(--surface-neutral);
|
|
78
|
-
--statcard-frame-border: var(--border-neutral);
|
|
79
|
-
--statcard-frame-border-width: var(--border-width-1);
|
|
80
|
-
--statcard-frame-radius: var(--radius-md);
|
|
81
|
-
--statcard-frame-padding: var(--space-16);
|
|
82
|
-
--statcard-value-text: var(--text-primary);
|
|
83
|
-
--statcard-label-text: var(--text-secondary);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.statcard {
|
|
87
|
-
display: grid;
|
|
88
|
-
background: var(--statcard-frame-surface);
|
|
89
|
-
border: var(--statcard-frame-border-width) solid var(--statcard-frame-border);
|
|
90
|
-
border-radius: var(--statcard-frame-radius);
|
|
91
|
-
padding: var(--statcard-frame-padding);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
.value { color: var(--statcard-value-text); }
|
|
95
|
-
.label { color: var(--statcard-label-text); }
|
|
96
|
-
</style>
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
This excerpt shows the assignment chain. Add typography, spacing, and other properties from the component's actual property map.
|
|
100
|
-
|
|
101
|
-
Route editable styling through component properties. Keep structural CSS such as `display: grid`, `width: 100%`, and `align-items: center` in the component's layout rules. Use token references for visual defaults. A token expression such as `calc(var(--space-64) * 4)` can express a dimension beyond the scale when the component needs it; prefer a direct assignment when a preset value fits.
|
|
102
|
-
|
|
103
|
-
For persistent structural choices such as alignment or visibility, read [references/intrinsics.md](references/intrinsics.md). Declare an `IntrinsicSpec`, mirror its default in `:global(:root)`, and register it through the `intrinsics` field. Keep these choices outside `allTokens`.
|
|
104
|
-
|
|
105
|
-
## Variants and states
|
|
106
|
-
|
|
107
|
-
Parts coexist, variants provide alternative presentations, and states reflect runtime conditions. Preserve those distinctions in both the component API and the editor.
|
|
108
|
-
|
|
109
|
-
Use the default state for shared geometry and typography. Add state properties for the values that change. Follow `Toggle` for a component state such as `on` with an interaction state such as `hover`. Live Tokens treats `disabled` as terminal: its editor fieldset is flat, and its tokens carry no combined hover or selected state.
|
|
110
|
-
|
|
111
|
-
Make the preview render the state whose properties the user edits. Pair each hover selector with a `.force-hover` selector and expose a class prop so the editor can show hover without a pointer. Preserve native disabled behavior, keyboard operation, and visible focus for interactive controls.
|
|
112
|
-
|
|
113
|
-
For action emphasis, use `primary` for the single action that completes the page's main task, `secondary` for supporting or directly related actions, and `outline` for unrelated or informational actions. Use `danger` for actions that destroy saved work. The page chooses the one primary action; a component supplies the relevant variants.
|
|
114
|
-
|
|
115
|
-
## Component editor
|
|
116
|
-
|
|
117
|
-
Create `src/system/components/StatCardEditor.svelte` beside the custom runtime file. Shipped editors use a separate internal directory; custom components keep both files together.
|
|
118
|
-
|
|
119
|
-
In `<script module lang="ts">`, declare `const component = 'statcard'`, define the token lists, and export their flat union as `allTokens: Token[]`. Each editable runtime property has one schema entry with the exact variable name. Use `element` to group rows by part and a short `label` to name the property.
|
|
120
|
-
|
|
121
|
-
```ts
|
|
122
|
-
import type { Token } from '@motion-proto/live-tokens/component-editor';
|
|
123
|
-
|
|
124
|
-
const component = 'statcard';
|
|
125
|
-
const states: Record<string, Token[]> = {
|
|
126
|
-
default: [
|
|
127
|
-
{ label: 'surface', element: 'frame', variable: '--statcard-frame-surface' },
|
|
128
|
-
{ label: 'padding', element: 'frame', variable: '--statcard-frame-padding' },
|
|
129
|
-
{ label: 'text', element: 'value', variable: '--statcard-value-text' },
|
|
130
|
-
{ label: 'text', element: 'label', variable: '--statcard-label-text' },
|
|
131
|
-
],
|
|
132
|
-
};
|
|
133
|
-
export const allTokens: Token[] = Object.values(states).flat();
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
Expand this illustrative schema to cover the full property map. In the instance script, import the runtime component and the editor primitives. Mount `ComponentEditorBase` with `component` and `tokens={allTokens}`, then a `VariantGroup` for each variant with its `states`, `component`, and runtime preview. Follow the matching shipped editor for the exact snippet API.
|
|
137
|
-
|
|
138
|
-
Use public imports in consumer projects:
|
|
139
|
-
|
|
140
|
-
```ts
|
|
141
|
-
import { ComponentEditorBase, VariantGroup } from '@motion-proto/live-tokens/component-editor';
|
|
142
|
-
import StatCard from './StatCard.svelte';
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
Read shipped source files for examples; import package APIs through their public exports. Use `--ui-*` tokens for custom editor chrome and let the runtime preview consume the theme through its component properties.
|
|
146
|
-
|
|
147
|
-
When variants should share properties, read [references/linked-siblings.md](references/linked-siblings.md). Declare intentional sibling sets with `groupKey`, enable the linked controls with `canBeLinked`, and wire the linked block using the shipped helpers. Scope keys to the role: `value-font-size` and `label-font-size` stay independent. When using `buildTypeGroup*` helpers, pass `{ component, variants }` so they derive keys for each slot.
|
|
148
|
-
|
|
149
|
-
## Registration and persistence
|
|
150
|
-
|
|
151
|
-
Add the custom component to the existing `bootLiveTokens` call, preserving the project's other registrations and setup:
|
|
152
|
-
|
|
153
|
-
```ts
|
|
154
|
-
import StatCardEditor, { allTokens as statCardTokens } from './system/components/StatCardEditor.svelte';
|
|
155
|
-
|
|
156
|
-
bootLiveTokens(App, '#app', {
|
|
157
|
-
components: [{
|
|
158
|
-
id: 'statcard',
|
|
159
|
-
label: 'Stat Card',
|
|
160
|
-
icon: 'fas fa-chart-simple',
|
|
161
|
-
sourceFile: 'src/system/components/StatCard.svelte',
|
|
162
|
-
editorComponent: StatCardEditor,
|
|
163
|
-
schema: statCardTokens,
|
|
164
|
-
}],
|
|
165
|
-
});
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
`bootLiveTokens` registers components after editor initialization and before theme initialization. Use that registration window. For a manual bootstrap, follow the package initialization order and register before mounting the app. Choose a unique id so the registration preserves built-in entries.
|
|
169
|
-
|
|
170
|
-
The runtime root declarations supply the initial assignments. The plugin derives `default.json`; editor saves write `_working.json`, and Save As creates a named preset. Preserve token references through this flow. Verify the project's configured data path rather than creating a second persistence mechanism.
|
|
171
|
-
|
|
172
|
-
For a first-party addition inside the Live Tokens package, follow the internal layout instead: runtime in `src/system/components`, editor in `src/editor/component-editor`, and an entry in `builtInRegistry` in `src/editor/component-editor/registry.ts`. Update the built-in id union and catalogue through the repository's existing conventions.
|
|
173
|
-
|
|
174
|
-
## Rendering integration
|
|
175
|
-
|
|
176
|
-
Read [references/sketch-mode.md](references/sketch-mode.md) and integrate the component's painted parts with Sketch mode. Custom components use the reserved sketch classes and bind the sketch properties to their own semantic properties. Choose a wrapper that accommodates the layer's positioning, overflow, and pseudo-element requirements. First-party components add the corresponding `PartSpec` entries.
|
|
177
|
-
|
|
178
|
-
For a fixed overlay, read [references/fixed-overlays.md](references/fixed-overlays.md) and portal the layer to `body`. Follow the existing container pattern when the component owns typography inside a content snippet.
|
|
179
|
-
|
|
180
|
-
## Verification
|
|
181
|
-
|
|
182
|
-
Run `npx live-tokens check-component <id> --strict --json`. Inside the package repository, use `node bin/cli.mjs check-component <id> --strict --json`. Resolve findings and rerun until the command passes. Run the project's Svelte checks and the build or tests that cover the new behavior.
|
|
183
|
-
|
|
184
|
-
Read [references/contract-tests.md](references/contract-tests.md) and verify the registry entry with `checkRegistryEntry`. The contract checks registration, unique schema variables, runtime declarations, seeded defaults, and alias round trips. Include intrinsic checks when the component declares intrinsics.
|
|
185
|
-
|
|
186
|
-
Open `/live-tokens/components` and verify:
|
|
187
|
-
|
|
188
|
-
- The component appears under Custom, or among system components for a first-party addition.
|
|
189
|
-
- Each property has the correct editor control and changes the matching runtime part.
|
|
190
|
-
- Preview variants and states match the controls; keyboard and pointer behavior work.
|
|
191
|
-
- Linked properties change together, and separate roles remain independent.
|
|
192
|
-
- Save and reload retain assignments. Reset restores runtime defaults.
|
|
193
|
-
- Theme changes reach every property that references a theme token.
|
|
194
|
-
- Sketch mode renders each painted part correctly and restores the normal appearance when switched off.
|
|
195
|
-
|
|
196
|
-
Report the files, component id, available props, and verification results. State any checks the environment prevented you from running.
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: live-tokens-fix-findings
|
|
3
|
-
description: Fix every finding of check-page and check-component in an existing @motion-proto/live-tokens project until both exit 0. Called with the fix list by live-tokens-check-compliance. Use when the user asks to fix the project. Edits the files the checkers name. Updates tokens.css only through the migration command.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Fixing the findings of check-page and check-component
|
|
7
|
-
|
|
8
|
-
Fix every finding of `check-page` and `check-component` until both exit 0. `check-page` checks pages. Every component comes from the catalogue, every prop is declared, and every value in page CSS is a design token. `check-component` checks authored components. Every token names a semantic property, and its default is the design token that property reads. Update `tokens.css` only through the migration command. That command also heals the data tree, and with `--write` rewrites the route references it lists. When live-tokens-check-compliance hands over a fix list, the user's choices in it stand.
|
|
9
|
-
|
|
10
|
-
## Workflow
|
|
11
|
-
|
|
12
|
-
When `check-page` is an unknown command, upgrade `@motion-proto/live-tokens` first.
|
|
13
|
-
|
|
14
|
-
1. Run `npx live-tokens migrate --check` to see the plan, then `npx live-tokens migrate` to apply it. `--tokens <path>` names a tokens.css in an unusual place.
|
|
15
|
-
2. Run both checkers with `--json`. Each finding carries a `rule`, a file, and a line.
|
|
16
|
-
```sh
|
|
17
|
-
npx live-tokens check-page --json
|
|
18
|
-
npx live-tokens check-component --json
|
|
19
|
-
```
|
|
20
|
-
3. Group the findings by rule.
|
|
21
|
-
4. Take the largest error group first, then the remaining errors. Take warnings only when the repair scope includes warnings.
|
|
22
|
-
5. Fix every finding in the group with its section: Color by role, Geometry by scale, or The remaining rules.
|
|
23
|
-
6. Run both checkers again. When repairable findings remain in scope, return to step 3. When no token fits a remaining finding, leave it and continue to the reply with its reason.
|
|
24
|
-
7. When the errors are clear, run both checkers with `--strict`. Report what `--strict` adds. Clear warnings within the existing request. Otherwise ask whether to clear the warnings now.
|
|
25
|
-
8. When the repair scope includes warnings, return to step 3 with `--strict`. When strict checks pass or the user defers warnings, continue to the reply.
|
|
26
|
-
9. Reply with:
|
|
27
|
-
- the changes by rule, each with its count and any visible shift
|
|
28
|
-
- the findings left, each with its reason and any config entry the user chose
|
|
29
|
-
- both checker commands with their exit codes
|
|
30
|
-
|
|
31
|
-
`check-page <path>` scopes a run to one page. `check-component <id>` scopes a run to one component: its runtime, its editor, and its registration. The checkers read tokens.css from its default location.
|
|
32
|
-
|
|
33
|
-
When `package.json` has no `check:design` script, add `"check:design": "live-tokens check-page && live-tokens check-component"`. When both checkers exit 0, prepend `npm run check:design &&` to the existing build command. Preserve its other build steps.
|
|
34
|
-
|
|
35
|
-
## Scope
|
|
36
|
-
|
|
37
|
-
- Add no token to `tokens.css`. Map a literal with no matching token to the nearest existing token by role. When no token fits, leave the finding and say so.
|
|
38
|
-
- When the user has chosen to lower a rule's severity, record it in `live-tokens.config.json` under `"checks": { "rules": { "<rule>": "warn" } }`. `--off=<rule>` silences a rule for one run only.
|
|
39
|
-
- When the nearest token differs from the literal, use the token and name the shift in the report, such as `14px` to `--space-16`.
|
|
40
|
-
|
|
41
|
-
## Color by role
|
|
42
|
-
|
|
43
|
-
`color-literal` is a judgement finding. The replacement is the token for the role the color plays. The theme moves every role together. `npx live-tokens tokens --scale <name>` prints a scale's names and values, with `--json` for data.
|
|
44
|
-
|
|
45
|
-
| Literal | Token | Notes |
|
|
46
|
-
| --- | --- | --- |
|
|
47
|
-
| Text on a surface | `--text-primary` through `--text-disabled` | The neutral text scale. `--text-<family>` for a family color. |
|
|
48
|
-
| Light text on a dark chip | `--text-inverted` | No AA guarantee. |
|
|
49
|
-
| A surface fill | `--surface-<family>-<level>` | The role names the family: `neutral` for chrome, `brand` for emphasis, `danger` for status. |
|
|
50
|
-
| A stroke | `--border-<family>-<level>` | Levels run `faint` to `strong`. |
|
|
51
|
-
| A translucent layer that dims what is behind it | `--scrim-low`, `--scrim`, `--scrim-high` | Behind a modal. |
|
|
52
|
-
| A translucent wash on a surface | `--tint-low`, `--tint`, `--tint-high` | A hover state. |
|
|
53
|
-
| Any other translucent color | The role's token at an opacity: `color-mix(in srgb, var(--surface-brand) 80%, transparent)` | The editor reads that form. |
|
|
54
|
-
| Fully transparent | `--color-transparent` | |
|
|
55
|
-
| A gradient | `--gradient-*` | Or compose one from surface tokens. |
|
|
56
|
-
|
|
57
|
-
## Geometry by scale
|
|
58
|
-
|
|
59
|
-
`dimension-literal` is a mechanical finding. A size, such as a hero's height, is layout. Leave it.
|
|
60
|
-
|
|
61
|
-
| Literal | Token | Notes |
|
|
62
|
-
| --- | --- | --- |
|
|
63
|
-
| Spacing | `--space-<px>` | `npx live-tokens tokens --scale space` prints the steps. Round to the nearest step. |
|
|
64
|
-
| A stroke width | `--border-width-1`, `-2`, `-4` | Also for `outline`. |
|
|
65
|
-
| A corner | `--radius-sm` through `--radius-4xl`, or `--radius-full` | |
|
|
66
|
-
| A shadow | `--shadow-sm` through `--shadow-xl` | Replace the whole value. |
|
|
67
|
-
| Part of a `calc()` | The token inside the calc | `calc(var(--space-64) * -2 + var(--space-8))` |
|
|
68
|
-
| A duration or easing | `--duration-*`, `--ease-*` | No rule reports it. Fix it while in the file. |
|
|
69
|
-
| A `blur()` | `--blur-*` | No rule reports it. Fix it while in the file. |
|
|
70
|
-
|
|
71
|
-
## The remaining rules
|
|
72
|
-
|
|
73
|
-
| Rule | Fix |
|
|
74
|
-
| --- | --- |
|
|
75
|
-
| `unknown-token` | Search `tokens.css` for the stem. When a contract-family name is gone, `npx live-tokens migrate --check` lists the migration that adds the current name. |
|
|
76
|
-
| `raw-text-axis` | Set every axis from one text style, `-font-family` through `-letter-spacing`. `npx live-tokens tokens --scale heading` prints one text style. The text styles are `heading`, `body`, `editorial`, and `code`. Rewrite a `font:` shorthand the same way. |
|
|
77
|
-
| `unknown-component` | Read **live-tokens-pick-component** for the shipped component that fits. When none fits, author one with **live-tokens-create-component**. |
|
|
78
|
-
| `unknown-prop` | `npx live-tokens components <id>` prints the declared props and their values. Map the prop to one of them, or delete it. |
|
|
79
|
-
| `unknown-prop-value` | Use a value from the union the message lists. |
|
|
80
|
-
| `control-size` | Delete the `size` prop. The shipped default is the page's size. When that default is wrong for the project, retune the component in `/live-tokens/components`. |
|
|
81
|
-
| `multiple-primary` | Keep the action that completes the main task `primary`. A Button with no `variant` counts as `primary`. Use `secondary` for supporting or related actions and `outline` for unrelated or informational actions. |
|
|
82
|
-
| `danger-without-dialog` | Open a `Dialog` from the danger Button or IconButton and run the action from the Dialog's confirm. The rule fires once per page, when the page imports no Dialog. For other actions, assign emphasis by the action's relationship to the main task. |
|
|
83
|
-
| `native-control` | Replace the native element with the shipped component the message names: Button or IconButton, Input, MenuSelect. |
|
|
84
|
-
| `property-override` | Delete the declaration from the page. Retune the component's token for the whole project at `/live-tokens/components`. |
|
|
85
|
-
| `page-component-paint` | The finding names the page file and the line of the instance whose part painted a value its semantic property never resolves to. Remove the global rule reaching past the component, from `site.css` or the page's own CSS, and retune the component's token for the whole project at `/live-tokens/components`. |
|
|
86
|
-
| `page-text-style` | The finding names the page file and the line of the text element and the nearest bundle it missed. Set the container's text style directly on the text element, one shipped bundle from `npx live-tokens tokens --scale heading` (or `body`, `editorial`, `code`), rather than leaving it to inherit from an ancestor typed for a different role. |
|
|
87
|
-
| `page-contrast` | The finding names the page file and the line of the text element, the surface ancestor, and both computed colors. Pick the text token the surface pairs with, from the Color by role table above. |
|
|
88
|
-
| `page-grid` | The finding names the page file and the line of the section whose edge sits off a column line. Move the edge to the line: place it by page-column numbers per the Grid section of **live-tokens-create-page**, and give a centered section symmetric insets rather than a margin, a width, or a transform. |
|
|
89
|
-
| `page-overflow` | The finding names the page file and the line of the element or the instance that overflows. Give the control its shipped width, remove a fixed width that does not fit its column at the viewport, and set `overflow-x: auto` only on an element deliberately meant to scroll, such as a code block. When the overflow is the page grid itself at a phone width, collapse it: `grid-template-columns: 1fr`, `column-gap: 0`, per the Grid section of **live-tokens-create-page**. |
|
|
90
|
-
| `hardcoded-columns` | `repeat(var(--columns-count), 1fr)` for the page grid. `calc(var(--columns-count) - 2)` for a sub-grid spanning fewer columns. |
|
|
91
|
-
| `site-css-in-main` | Delete the import from `main.ts`. Add it to each page's `<script>`. Page CSS then stays off the editor routes. |
|
|
92
|
-
| `missing-source` | Add `source: 'src/...'` to the route entry. |
|
|
93
|
-
| `reserved-route` | Move the route out of `/live-tokens/*`. |
|
|
94
|
-
| `deep-import` | Import from `@motion-proto/live-tokens`, `/component-editor`, or `/components/<Name>.svelte`. |
|
|
95
|
-
| `fix: property-name` | Rename the token to the name a shipped component uses for the same role. The vocabulary and the state model are in **live-tokens-create-component**. |
|
|
96
|
-
| `fix: property-token` | Make the `:global(:root)` default read a design token, composed when needed. Declare a structural keyword, such as `start`, in the editor's `intrinsics`. |
|
|
97
|
-
| `fix: runtime` | Wire the component as the recipe in **live-tokens-create-component** wires it. |
|
|
98
|
-
| `fix: runtime-defaults` | Make the `:global(:root)` default the value Reset should restore, per the Runtime component section of **live-tokens-create-component**. |
|
|
99
|
-
| `fix: editor` | The editor names a token the runtime never declares, or a property targets the wrong part. Fix the editor's schema, states, or preview props by the Component editor section of **live-tokens-create-component**. |
|
|
100
|
-
| `fix: registration` | Register the component in the shared module the Registration section of **live-tokens-create-component** wires up, importable by the app and by `check-component --tests`. |
|
|
101
|
-
| `fix: sketch` | Add the missing Sketch part or marker, per the Sketch mode and overlays section of **live-tokens-create-component**. |
|
|
102
|
-
| `fix: tooling` | Install the named package (`@playwright/test`, `vitest`, or `happy-dom`) as a devDependency, then `npx playwright install chromium` for a missing browser. A bad path or config is named in the message; fix it and rerun `check-component <id> --tests`. |
|
|
103
|
-
| `fix: coverage` | A contract obligation never ran to a result. Add the missing contract, or find why the suite skipped it, then rerun. |
|
|
104
|
-
|
|
105
|
-
A `tests-*` finding names a problem with the run itself: the tool, the path, or a missing contract. Fix what the message names and rerun `check-component <id> --tests --json` until every applicable rule passes with no rule left `--off`.
|