Skip to content

Conversation

@beaesguerra
Copy link
Member

@beaesguerra beaesguerra commented Nov 26, 2025

Summary:

While creating new stories that used Storybook viewports, I found that our existing configuration was no longer working. In this PR, we update how we configure viewports in Storybook and in specific stories

Issue: WB-XXXX

Test plan:

Verify Chromatic snapshots and the stories that were updated

For example, ?path=/story/packages-tabs-navigationtabs-testing-navigationtabs-snapshots--scenarios-small-screen has a small screen viewport when the story is viewed

@changeset-bot
Copy link

changeset-bot bot commented Nov 26, 2025

⚠️ No Changeset found

Latest commit: 10e2b1e

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

@github-actions
Copy link
Contributor

github-actions bot commented Nov 26, 2025

Size Change: 0 B

Total Size: 109 kB

ℹ️ View Unchanged
Filename Size
packages/wonder-blocks-accordion/dist/es/index.js 3 kB
packages/wonder-blocks-announcer/dist/es/index.js 1.74 kB
packages/wonder-blocks-badge/dist/es/index.js 2.02 kB
packages/wonder-blocks-banner/dist/es/index.js 2.01 kB
packages/wonder-blocks-birthday-picker/dist/es/index.js 1.92 kB
packages/wonder-blocks-breadcrumbs/dist/es/index.js 755 B
packages/wonder-blocks-button/dist/es/index.js 4.25 kB
packages/wonder-blocks-card/dist/es/index.js 1.06 kB
packages/wonder-blocks-cell/dist/es/index.js 2.19 kB
packages/wonder-blocks-clickable/dist/es/index.js 2.66 kB
packages/wonder-blocks-core/dist/es/index.js 2.48 kB
packages/wonder-blocks-data/dist/es/index.js 5.48 kB
packages/wonder-blocks-dropdown/dist/es/index.js 19.4 kB
packages/wonder-blocks-form/dist/es/index.js 6.2 kB
packages/wonder-blocks-grid/dist/es/index.js 1.24 kB
packages/wonder-blocks-icon-button/dist/es/index.js 3.16 kB
packages/wonder-blocks-icon/dist/es/index.js 1.91 kB
packages/wonder-blocks-labeled-field/dist/es/index.js 3.48 kB
packages/wonder-blocks-layout/dist/es/index.js 1.63 kB
packages/wonder-blocks-link/dist/es/index.js 1.52 kB
packages/wonder-blocks-modal/dist/es/index.js 7.06 kB
packages/wonder-blocks-pill/dist/es/index.js 1.31 kB
packages/wonder-blocks-popover/dist/es/index.js 4.3 kB
packages/wonder-blocks-progress-spinner/dist/es/index.js 1.48 kB
packages/wonder-blocks-search-field/dist/es/index.js 1.1 kB
packages/wonder-blocks-styles/dist/es/index.js 464 B
packages/wonder-blocks-switch/dist/es/index.js 1.55 kB
packages/wonder-blocks-tabs/dist/es/index.js 3.71 kB
packages/wonder-blocks-testing-core/dist/es/index.js 3.25 kB
packages/wonder-blocks-testing/dist/es/index.js 978 B
packages/wonder-blocks-theming/dist/es/index.js 384 B
packages/wonder-blocks-timing/dist/es/index.js 1.37 kB
packages/wonder-blocks-tokens/dist/es/index.js 5.01 kB
packages/wonder-blocks-toolbar/dist/es/index.js 906 B
packages/wonder-blocks-tooltip/dist/es/index.js 6.4 kB
packages/wonder-blocks-typography/dist/es/index.js 1.57 kB

compressed-size-action

@github-actions
Copy link
Contributor

github-actions bot commented Nov 26, 2025

A new build was pushed to Chromatic! 🚀

https://5e1bf4b385e3fb0020b7073c-dkcifydeap.chromatic.com/

Chromatic results:

Metric Total
Captured snapshots 0
Tests with visual changes 0
Total stories 741
Inherited (not captured) snapshots [TurboSnap] 441
Tests on the build 441

},
viewport: {
viewports: wbViewports,
options: wbViewports,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to options based on the Storybook viewport docs: https://storybook.js.org/docs/essentials/viewport

},
},
},
globals: {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating how we configure the default viewport for a story using: https://storybook.js.org/docs/essentials/viewport#defining-the-viewport-for-a-story

Comment on lines -61 to -64
viewport: {
viewports: customViewports,
defaultViewport: "desktop",
},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the viewport configuration for stories that already have modes configured since both can't be used: https://www.chromatic.com/docs/modes/viewports/#can-i-use-viewports-and-modes-simultaneously

(Preferring the modes configuration since that also configures theming)

Applied this change to the other stories in the modal package.

Lmk if there are any concerns with this!

Comment on lines 58 to 59
small: allModes.small,
large: allModes.large,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the modal stories didn't have modes set up, so I configured it to use modes too

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know if this has some effect in the snapshots? or is it just for storybook rendering in the browser? mentioning this as the expectation is not to take snapshots for the stories in this file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, this is for Chromatic snapshots! We were already using the viewport config to generate multiple snapshots for these stories, and I switched it over to use modes instead.

Before, it was generating a snapshot for each custom viewport (phone, tablet, and desktop), and now it's configured to generate a snapshot for just small and large screens (this is what the newer modal stories were doing so I did the same for this set of stories!)

Let me know if we'd rather keep the old viewport config for Chromatic snapshots! It's still supported if we don't use it with modes at the same time!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah got it! What I mean is that we are disabling snapshots for this file (see the line below), so can just probably get rid of both viewport and modes in this file.

If you look at the Chromatic build, there are no snapshots associated to ModalDialog.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhh yes good point! 😄 I removed setting modes for the files that disable snapshots!

@beaesguerra beaesguerra marked this pull request as ready for review November 26, 2025 23:49
@khan-actions-bot khan-actions-bot requested a review from a team November 26, 2025 23:50
@khan-actions-bot
Copy link
Contributor

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to .storybook/preview.tsx, __docs__/wonder-blocks-birthday-picker/birthday-picker.stories.tsx, __docs__/wonder-blocks-modal/drawer-launcher-testing-snapshots.stories.tsx, __docs__/wonder-blocks-modal/drawer-launcher.stories.tsx, __docs__/wonder-blocks-modal/flexible-dialog.stories.tsx, __docs__/wonder-blocks-modal/modal-dialog.stories.tsx, __docs__/wonder-blocks-modal/modal-footer.stories.tsx, __docs__/wonder-blocks-modal/modal-header.stories.tsx, __docs__/wonder-blocks-modal/modal-launcher.stories.tsx, __docs__/wonder-blocks-modal/modal-panel.stories.tsx, __docs__/wonder-blocks-modal/one-pane-dialog.stories.tsx, __docs__/wonder-blocks-tabs/navigation-tabs-testing-snapshots.stories.tsx

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

Copy link
Member

@jandrade jandrade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks for cleaning up and get things in the right track 👏 :shipit:

defaultViewport: "desktop",
},
chromatic: {
modes: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Could you please remove it here as well? (sorry I forgot to add a comment next to disableSnapshot).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes good catch! Removed :)

@beaesguerra beaesguerra merged commit c6b38e2 into main Nov 27, 2025
15 checks passed
@codecov
Copy link

codecov bot commented Nov 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (8a84567) to head (10e2b1e).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@     Coverage Diff      @@
##   main   #2879   +/-   ##
============================
============================

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8a84567...10e2b1e. Read the comment docs.

🚀 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants