Skip to content

Commit 2f16b23

Browse files
authored
Bump storybook and add breakpoint viewports (#7471)
We lost the viewport toggle at some point, looks like it moved to an addon so I've added it back and mapped it to our breakpoints. This will help us ship updates to opinionated layout components that change margins / paddings / orientation etc...at our different breakpoints ![image](https://screenshot.click/20-58-ggs9m-yjs4r.png) https://user-images.githubusercontent.com/6844391/196984820-4ddbbed1-00e4-4ab0-a1cb-d5a96f049242.mp4
1 parent 4f5f6cf commit 2f16b23

File tree

5 files changed

+291
-311
lines changed

5 files changed

+291
-311
lines changed

.changeset/spotty-maps-search.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris': patch
3+
---
4+
5+
Added viewport addon to storybook and matched values to our breakpoints

polaris-react/.storybook/main.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ module.exports = {
1818
files: '**/*.stories.tsx',
1919
},
2020
],
21-
addons: ['@storybook/addon-a11y', '@storybook/addon-toolbars'],
21+
addons: [
22+
'@storybook/addon-a11y',
23+
'@storybook/addon-toolbars',
24+
'@storybook/addon-viewport',
25+
],
2226
webpackFinal: (config) => {
2327
const extraRules = [
2428
{

polaris-react/.storybook/preview.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import enTranslations from '../locales/en.json';
55
import {GridOverlay} from './GridOverlay';
66
import {RenderPerformanceProfiler} from './RenderPerformanceProfiler';
77
import {gridOptions} from './manager';
8+
import {breakpoints} from '@shopify/polaris-tokens';
89

910
function StrictModeDecorator(Story, context) {
1011
const {strictMode} = context.globals;
@@ -79,6 +80,17 @@ export const globalTypes = {
7980
},
8081
...gridOptions,
8182
};
83+
const viewPorts = Object.entries({
84+
...breakpoints,
85+
'breakpoints-xs': '20rem', // Replace the 0px xs breakpoint with 320px (20rem) for testing small screens
86+
}).map(([key, value]) => {
87+
return {
88+
name: key,
89+
styles: {width: value, height: '100%'},
90+
};
91+
});
92+
93+
export const parameters = {viewport: {viewports: {...viewPorts}}};
8294

8395
export const decorators = [
8496
GridOverlayDecorator,

polaris-react/package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,12 @@
8383
"@shopify/postcss-plugin": "^5.0.1",
8484
"@shopify/react-testing": "^4.1.0",
8585
"@shopify/storybook-a11y-test": "1.0.1",
86-
"@storybook/addon-a11y": "^6.5.9",
87-
"@storybook/addon-toolbars": "^6.5.9",
88-
"@storybook/builder-webpack5": "^6.5.9",
89-
"@storybook/manager-webpack5": "^6.5.9",
90-
"@storybook/react": "^6.5.9",
86+
"@storybook/addon-a11y": "^6.5.12",
87+
"@storybook/addon-toolbars": "^6.5.12",
88+
"@storybook/addon-viewport": "^6.5.12",
89+
"@storybook/builder-webpack5": "^6.5.12",
90+
"@storybook/manager-webpack5": "^6.5.12",
91+
"@storybook/react": "^6.5.12",
9192
"@types/node": "^16.11.11",
9293
"@types/react": "^18.0.15",
9394
"@types/react-dom": "^18.0.6",

0 commit comments

Comments
 (0)