Skip to content

fix: use Storybook viewport globals#339

Merged
AriPerkkio merged 1 commit intomainfrom
kasper/storybook-globals
May 6, 2026
Merged

fix: use Storybook viewport globals#339
AriPerkkio merged 1 commit intomainfrom
kasper/storybook-globals

Conversation

@AriPerkkio
Copy link
Copy Markdown
Member

Issue: Split from #330

What Changed

Emit Storybook 10 viewport globals (globals.viewport as w{width}h{height}, matching the archive snapshot key) so archive stories open in the captured viewport.

[...]

Storybook 10 selects the active viewport through globals.viewport, together with parameters.viewport (available sizes / default). See Defining the viewport for a story.

For archive stories we emit the captured archive viewport key as the story global, e.g.:

{
  "globals": { "viewport": "w1280h720" }
}

That value matches the archive snapshot filename segment, so the renderer can fetch the matching rrweb snapshot. The archive still includes parameters.viewport.viewports and parameters.viewport.defaultViewport so the viewport option is defined for Storybook.

How to test

  • yarn vitest run packages/shared/src/write-archive/stories-files.test.ts packages/shared/src/write-archive/index.test.ts packages/vitest/src/node/commands.test.ts
  • yarn lint
  • Patched @chromatic-com/vitest into a consumer app and confirmed Vitest browser tests + chromatic --vitest complete successfully (expect baseline diffs until snapshots are accepted).

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 5, 2026

⚠️ No Changeset found

Latest commit: 4d39133

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.58%. Comparing base (63b6deb) to head (4d39133).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #339      +/-   ##
==========================================
- Coverage   90.92%   89.58%   -1.34%     
==========================================
  Files          22       22              
  Lines         628      634       +6     
  Branches      116      118       +2     
==========================================
- Hits          571      568       -3     
- Misses         54       62       +8     
- Partials        3        4       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@AriPerkkio AriPerkkio merged commit daebf39 into main May 6, 2026
10 of 12 checks passed
@AriPerkkio AriPerkkio deleted the kasper/storybook-globals branch May 6, 2026 09:55
AriPerkkio added a commit that referenced this pull request May 7, 2026
@github-actions github-actions Bot mentioned this pull request May 7, 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.

3 participants