@uicopilot/storybook-addon 0.12.1 → 0.13.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/README.md +122 -8
- package/dist/manager.mjs +53 -53
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -17,8 +17,20 @@ Your design system is the contract. When a button ships with the wrong brand col
|
|
|
17
17
|
|
|
18
18
|
You get a **traffic-light verdict and an exact list of what's off** (Expected vs. Actual, per property) — not a fuzzy pixel diff you have to eyeball.
|
|
19
19
|
|
|
20
|
+
**The short version:** point a story at its Figma frame once, then press a button to find out whether the code still matches the design. No baselines to approve, no snapshots to maintain.
|
|
21
|
+
|
|
20
22
|
## Install
|
|
21
23
|
|
|
24
|
+
### Guided (recommended)
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npx uiparity init
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The CLI installs the addon, registers it in `.storybook/main.ts`, and hands you off to the in-Storybook setup wizard.
|
|
31
|
+
|
|
32
|
+
### Manual
|
|
33
|
+
|
|
22
34
|
```bash
|
|
23
35
|
npm install --save-dev @uicopilot/storybook-addon
|
|
24
36
|
```
|
|
@@ -33,11 +45,28 @@ export default {
|
|
|
33
45
|
|
|
34
46
|
That's it — no other config. Restart Storybook and you'll see a **UI Parity** tab in the addon panel and a toolbar button on every story.
|
|
35
47
|
|
|
48
|
+
### Just want to see it work?
|
|
49
|
+
|
|
50
|
+
Scaffold a throwaway Storybook that's already wired up:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npx uiparity demo # prompts for a template
|
|
54
|
+
npx uiparity demo --template radix # Radix UI Themes
|
|
55
|
+
npx uiparity demo --template mui # Material UI
|
|
56
|
+
npx uiparity demo --template cbds # CBDS Components (ships with a Figma kit)
|
|
57
|
+
npx uiparity list # see every template
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Templates also exist for Ant Design, Mantine, Carbon (IBM), Chakra UI, and Paste (Twilio). The `cbds` template is the fastest end-to-end demo because it includes a matching Figma kit — no design file of your own required.
|
|
61
|
+
|
|
36
62
|
## Quick start
|
|
37
63
|
|
|
38
64
|
1. **Open the UI Parity panel** on any story and sign in with Google — or hit **"Try without signing in"** to start a guest session.
|
|
39
|
-
2. **
|
|
40
|
-
3. **
|
|
65
|
+
2. **Connect Figma and pick the pages to index.** The setup wizard walks you through it: connect Figma, paste your file URL, choose which pages to sync, and it indexes the frames in those pages.
|
|
66
|
+
3. **Map the story to its Figma frame** (one click, "Map to Figma"). This tells UI Parity what the component is _supposed_ to look like.
|
|
67
|
+
4. **Click "Compare to design."** You get a **traffic-light verdict** — `Matches design` · `Minor differences` · `Major differences` — and a list of exactly which properties drifted (Expected vs. Actual).
|
|
68
|
+
|
|
69
|
+
Mapping is a one-time cost per component. After that, every re-check is one click.
|
|
41
70
|
|
|
42
71
|
## What it checks
|
|
43
72
|
|
|
@@ -47,10 +76,12 @@ That's it — no other config. Restart Storybook and you'll see a **UI Parity**
|
|
|
47
76
|
| -------------------------- | ----------------------------------------------------------------------------------------------------------------- |
|
|
48
77
|
| Wrong brand / token colors | `color`, fill, background (banded by ΔE, so a barely-visible shift is a minor, a wrong brand color is a critical) |
|
|
49
78
|
| Off typography | `font-family`, size, weight |
|
|
50
|
-
| Spacing drift | padding, gap, margins (sub-
|
|
79
|
+
| Spacing drift | padding, gap, margins (sub-10px diffs are downgraded a severity level) |
|
|
51
80
|
| Corner radius | `border-radius` |
|
|
52
81
|
| Borders | width, color, style |
|
|
53
82
|
|
|
83
|
+
Because it reads the **computed** styles off the rendered DOM, it doesn't care how you wrote them. Tailwind classes, CSS Modules, styled-components, vanilla-extract, plain CSS, inline styles — all produce the same computed values, and that's what gets compared.
|
|
84
|
+
|
|
54
85
|
> **AI visual review** — catching layout, shadows, missing elements, and icon drift from a screenshot comparison — is rolling out next. Today the deterministic spec-diff is what everyone gets, free.
|
|
55
86
|
|
|
56
87
|
## The verdict
|
|
@@ -59,21 +90,64 @@ Every review resolves to a single **traffic light** — the _worst_ difference f
|
|
|
59
90
|
|
|
60
91
|
| Light | Verdict | What it means |
|
|
61
92
|
| ----- | -------------------------------- | ---------------------------------------------------------------------------- |
|
|
62
|
-
| 🟢 | **Matches design** | No differences — or only
|
|
93
|
+
| 🟢 | **Matches design** | No differences — or only tiny size diffs / near-identical colors |
|
|
63
94
|
| 🟡 | **Minor differences** | Cosmetic only — barely-visible color or spacing drift, nothing visibly off |
|
|
64
95
|
| 🔴 | **Major / critical differences** | At least one clearly-wrong value — wrong brand color, font, size, or spacing |
|
|
65
96
|
|
|
66
|
-
Severities are **perceptually adjusted first** — color diffs by Δ
|
|
97
|
+
Severities are **perceptually adjusted first** — color diffs by perceptual ΔE distance, dimension diffs by pixel distance — so a barely-visible shift stays a minor, and only a real, visible problem turns the light red.
|
|
98
|
+
|
|
99
|
+
Every difference is reported as a concrete **Expected vs. Actual** pair on a named property, so there's nothing to interpret: `background-color` — expected `#ea580c`, actual `#f97316`.
|
|
100
|
+
|
|
101
|
+
## Where the verdict shows up
|
|
102
|
+
|
|
103
|
+
The result isn't buried in one panel. Once a story has been checked, you see it in three places:
|
|
104
|
+
|
|
105
|
+
- **The addon panel** — the full verdict plus the property-by-property difference list.
|
|
106
|
+
- **The story sidebar** — each checked story gets a colored marker in Storybook's tree, and stories with differences show a **count badge** in the worst severity's color. You can scan the whole sidebar and see where the drift is without opening anything.
|
|
107
|
+
- **The toolbar** — a UI Parity button on every story, so a check is always one click away.
|
|
108
|
+
|
|
109
|
+
## Review every story at once
|
|
110
|
+
|
|
111
|
+
UI Parity registers a **test provider** in Storybook's Testing module (the same sidebar area Storybook's own test widgets use). Hit **Run** and it checks every mapped story in one pass, streaming results into the sidebar as each one lands.
|
|
112
|
+
|
|
113
|
+
This is the "did anything drift?" sweep — run it after a design-system bump, a token change, or a dependency upgrade, and read the answer off the sidebar. The Run button stays disabled until you're connected and have at least one mapped story.
|
|
114
|
+
|
|
115
|
+
## Works with any Storybook framework
|
|
116
|
+
|
|
117
|
+
The check reads the **rendered DOM**, not your source, so the renderer doesn't matter:
|
|
118
|
+
|
|
119
|
+
`react` · `vue` · `angular` · `web-components` · `html` · `svelte` · `preact` · `react-native`
|
|
120
|
+
|
|
121
|
+
React is optional as a peer dependency — the addon's own UI is bundled and does not force a React version on your project. It runs against React 16.8 through 19 in a React Storybook, and against non-React Storybooks with no React in your app at all.
|
|
122
|
+
|
|
123
|
+
## How this differs from visual regression testing
|
|
124
|
+
|
|
125
|
+
Both are useful, and they answer different questions.
|
|
126
|
+
|
|
127
|
+
| | Visual regression (snapshots) | UI Parity |
|
|
128
|
+
| --- | --- | --- |
|
|
129
|
+
| Compares against | **The last approved screenshot** of your own component | **The Figma frame** — the design source of truth |
|
|
130
|
+
| Catches | Any change from the previous build | Divergence from what the design says, even if it's been wrong for months |
|
|
131
|
+
| Output | A pixel diff image to eyeball | Named properties with Expected vs. Actual values |
|
|
132
|
+
| Needs | Baselines to approve and re-approve | A one-time story → frame mapping |
|
|
133
|
+
| Blind spot | A component that never matched the design still passes forever | Anything not expressed as a comparable style property |
|
|
134
|
+
|
|
135
|
+
Snapshot tools tell you **something changed**. UI Parity tells you **it doesn't match the design** — which is the question that comes up in design review, not code review. Teams run both.
|
|
136
|
+
|
|
137
|
+
## Review history
|
|
138
|
+
|
|
139
|
+
Each story keeps its past checks. Open the history dropdown in the panel to pull up an earlier review and see what the verdict and differences were then — useful for confirming that a fix actually moved the light, or for finding when a component started drifting.
|
|
67
140
|
|
|
68
141
|
## Requirements
|
|
69
142
|
|
|
70
|
-
- **Storybook** `9.0` or newer
|
|
143
|
+
- **Storybook** `9.0` or newer (works with Storybook 9 and 10)
|
|
71
144
|
- A **Figma** account with a **Dev or Full seat** — free/Viewer seats can't grant the design-read access UI Parity needs to index your components
|
|
72
145
|
- A free **[UI Parity](https://uiparity.com)** account — sign in with Google, or start as a guest and sign up to save your results
|
|
146
|
+
- **No Figma plugin to install.** UI Parity reads your file through Figma's API — signed-in users connect via OAuth, guests paste a Figma personal access token.
|
|
73
147
|
|
|
74
|
-
##
|
|
148
|
+
## Configuration
|
|
75
149
|
|
|
76
|
-
|
|
150
|
+
All configuration is optional. Set these through `env` in `.storybook/main.ts`:
|
|
77
151
|
|
|
78
152
|
```ts
|
|
79
153
|
export default {
|
|
@@ -85,10 +159,50 @@ export default {
|
|
|
85
159
|
};
|
|
86
160
|
```
|
|
87
161
|
|
|
162
|
+
| Variable | Purpose |
|
|
163
|
+
| --- | --- |
|
|
164
|
+
| `STORYBOOK_UICOPILOT_URL` | Point the addon at your own dashboard deployment instead of `https://app.uiparity.com`. |
|
|
165
|
+
| `STORYBOOK_UICOPILOT_FIGMA_KIT` | A reference Figma community-file URL to surface in the project setup screen as a copyable starting kit. Set automatically by `npx uiparity demo` templates that ship one. |
|
|
166
|
+
| `STORYBOOK_UICOPILOT_NO_PUPPETEER` | Set to `true` to disable server-side screenshot capture and fall back to in-browser capture. Debug/troubleshooting flag. |
|
|
167
|
+
|
|
168
|
+
### Self-hosting the dashboard
|
|
169
|
+
|
|
170
|
+
The addon talks to `https://app.uiparity.com` by default. `STORYBOOK_UICOPILOT_URL` (above) is the only change needed to point it at your own deployment — the addon has no other hardcoded endpoint.
|
|
171
|
+
|
|
172
|
+
## What leaves your machine
|
|
173
|
+
|
|
174
|
+
Worth knowing before you point it at a private design system:
|
|
175
|
+
|
|
176
|
+
- **The free spec-diff check** sends a compact tree describing the _rendered_ component — element tag names, class/id selectors, any short visible text (truncated), and the element's **computed style values** (colors, sizes, spacing, fonts) — along with the story ID and the mapped Figma node ID. It does **not** upload your source files or stylesheets, and it does **not** send screenshots.
|
|
177
|
+
- **Figma data** is fetched server-side using the credentials you connected, and only for the pages you explicitly chose to sync during setup.
|
|
178
|
+
- **Screenshots**, when captured, are taken **locally** — the addon runs a capture endpoint inside your own Storybook dev server (via Puppeteer, if it's installed in your project).
|
|
179
|
+
- **Self-hosting** the dashboard keeps all of the above inside your own infrastructure.
|
|
180
|
+
|
|
181
|
+
## Troubleshooting
|
|
182
|
+
|
|
183
|
+
**The UI Parity panel doesn't appear.**
|
|
184
|
+
Confirm the addon is in the `addons` array of `.storybook/main.ts` and restart Storybook. If you've changed the addon version, clear the cache: `rm -rf node_modules/.cache .cache storybook-static`.
|
|
185
|
+
|
|
186
|
+
**"Compare to design" is disabled.**
|
|
187
|
+
The story isn't mapped to a Figma frame yet. Map it from the panel first.
|
|
188
|
+
|
|
189
|
+
**Figma won't connect / no frames show up after sync.**
|
|
190
|
+
Two usual causes: a Figma **Viewer or free seat** (a Dev or Full seat is required for design-read access), or the frames live on a page you didn't select during setup. Re-run the Figma step and include the page.
|
|
191
|
+
|
|
192
|
+
**Everything comes back as a difference.**
|
|
193
|
+
This is almost always a mapping problem — the story is pointed at the wrong Figma variant. Open the mappings list and confirm the story is mapped to the frame you actually meant.
|
|
194
|
+
|
|
195
|
+
**The sidebar markers look like Storybook's own test statuses.**
|
|
196
|
+
They share the same status glyph. UI Parity only recolors markers for stories it actually has a status for, so anything untouched is your test runner's, not ours.
|
|
197
|
+
|
|
198
|
+
**Screenshots fail or time out.**
|
|
199
|
+
Server-side capture needs `puppeteer` installed in your project (it's an optional peer dependency). Install it, or set `STORYBOOK_UICOPILOT_NO_PUPPETEER=true` to use the in-browser fallback.
|
|
200
|
+
|
|
88
201
|
## Links
|
|
89
202
|
|
|
90
203
|
- **[uiparity.com](https://uiparity.com)** — product & sign-up
|
|
91
204
|
- **[app.uiparity.com](https://app.uiparity.com)** — the dashboard
|
|
205
|
+
- **[`uiparity` CLI](https://www.npmjs.com/package/uiparity)** — `init` and `demo` scaffolding
|
|
92
206
|
- **feedback@uiparity.com** — questions, bugs, feature requests
|
|
93
207
|
|
|
94
208
|
## License
|