Skip to content

feat(storybook): still capture, story shots and visual diff - #394

Open
H4ad wants to merge 2 commits into
mainfrom
chore/storybook-still-capture
Open

H4ad wants to merge 2 commits into
mainfrom
chore/storybook-still-capture

Conversation

@H4ad

@H4ad H4ad commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

What

Ported from SigNoz/signoz and adapted to this repo's Storybook.

  • A Motion toolbar global with two values, Still (default) and Live, settleForCapture run as afterEach (so after a story's play), and the html.sb-still block in preview.css: zero-length single-iteration animations that keep their end state, no transitions, transparent caret.
  • apps/docs/scripts/story-shots.mjs (pnpm -F docs shots) screenshots stories off a running dev server, one PNG per story and theme plus a shots.json recording what each shot is.
  • apps/docs/scripts/story-shots-diff.mjs (pnpm -F docs diff:shots) pairs the PNGs of two runs by relative path and reports what moved, largest first, using Chromatic's comparison (YIQ distance over diffThreshold, antialiasing-only pixels ignored).
  • .claude/skills/storybook-visual-diff drives both scripts.

Why

A snapshot of a story with a spinner or a caret catches it at whatever frame the capture landed on, so the same story reports a change on every run. Parking animations on their last frame is also where Chromatic parks them, so local shots and Chromatic agree. Live stays available for watching a transition in the browser.

The scripts give a local read on what a change moved before pushing to Chromatic.

How to verify

Run pnpm dev, open any story with motion (Spinner, Tooltip), and toggle the Motion control in the toolbar: Still holds the end frame, Live animates.

From apps/docs, shoot the same tree twice and diff it; the noise floor should be zero:

pnpm shots .story-shots/a --stories badge --theme dark,light
pnpm shots .story-shots/b --stories badge --theme dark,light
pnpm diff:shots .story-shots/a .story-shots/b .story-shots/diff

Needs ImageMagick (magick or convert) on PATH. Playwright is already a devDependency of apps/docs.

@H4ad
H4ad requested a review from a team September 11, 2026 17:14
@H4ad
H4ad requested a review from a team as a code owner September 11, 2026 17:14
@H4ad H4ad changed the title feat(storybook): park stories on their last frame for capture feat(storybook): still capture, story shots and visual diff Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant