Skip to content

Commit

Permalink
Migrate Chromatic Viewports
Browse files Browse the repository at this point in the history
Chromatic has changed the way they handle viewports for stories.
https://www.chromatic.com/docs/storybook/viewports/#migration-from-viewports-legacy-to-modes
  • Loading branch information
JacobArrow committed Nov 4, 2024
1 parent 70ef6ec commit 0a6030c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
9 changes: 9 additions & 0 deletions .storybook/modes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Set the viewport widths that Chromatic tests with globally.
export const allModes = {
xs: {
viewport: "xs",
},
xl: {
viewport: "xl",
},
};
18 changes: 14 additions & 4 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,23 @@ export const parameters = {
date: /Date$/,
},
},
viewport: {
viewports: {
xs: { name: "XSmall", styles: { width: "400px", height: "900px" } },
sm: { name: "Small", styles: { width: "640px", height: "900px" } },
md: { name: "Medium", styles: { width: "768px", height: "900px" } },
lg: { name: "Large", styles: { width: "1024px", height: "900px" } },
xl: { name: "XL", styles: { width: "1200px", height: "900px" } },
"2xl": { name: "2XL", styles: { width: "1536px", height: "900px" } },
},
},
chromatic: {
// Notifies Chromatic to pause the animations when they finish at a global level
// This is because Chromatic doesn't show the cover image when the animation starts with opacity 0
pauseAnimationAtEnd: true,
// Set the viewport widths that Chromatic tests with globally.
// 400 lies between our screen-xs & screen-s variables.
// 1200 is the chromatic viewport we were using as default before adding an extra one for phones.
viewports: [400, 1200],
modes: {
"400px": allModes["xs"],
"1200px": allModes["xl"],
},
},
};

0 comments on commit 0a6030c

Please sign in to comment.