Skip to content

Commit ddbaf97

Browse files
refactor(.storybook/preview): convert viewport widths to pixels
1 parent 1262617 commit ddbaf97

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

.storybook/preview.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import i18n, { baseLocales } from "./i18next"
77

88
const extendedTheme = extendBaseTheme(theme)
99

10-
export const chakraBreakpointArray = Object.entries(extendedTheme.breakpoints)
10+
export const chakraBreakpointArray = Object.entries(
11+
extendedTheme.breakpoints
12+
) as [string, string][]
1113

1214
const preview: Preview = {
1315
globals: {
@@ -35,6 +37,9 @@ const preview: Preview = {
3537
viewports: chakraBreakpointArray.reduce((prevVal, currVal) => {
3638
const [token, key] = currVal
3739

40+
// `key` value is in em. Need to convert to px for Chromatic Story mode snapshots
41+
const emToPx = (Number(key.replace("em", "")) * 16).toString() + "px"
42+
3843
// Replace base value
3944
if (token === "base")
4045
return {
@@ -53,7 +58,7 @@ const preview: Preview = {
5358
[token]: {
5459
name: token,
5560
styles: {
56-
width: key,
61+
width: emToPx,
5762
height: "600px",
5863
},
5964
},

0 commit comments

Comments
 (0)