Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addon-viewports: Add back default viewports #7448

Merged
merged 2 commits into from
Aug 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@

## From version 5.1.x to 5.2.x

### default viewports

The default viewports have been reduced to a smaller set, we think is enough for most usecases.
You can get the old default back by adding the following to your `config.js`:

```js
import { INITIAL_VIEWPORTS } from '@storybook/addon-viewport';

addParameters({
options: {
viewports: INITIAL_VIEWPORTS,
},
});
```

### Grid toolbar-feature

The grid feature in the toolbar has been relocated to [addon-background](https://github.com/storybookjs/storybook/tree/next/addons/backgrounds), follow the setup intructions on that addon to get the feature again.
Expand Down
9 changes: 6 additions & 3 deletions addons/viewport/src/Tool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Icons, IconButton, WithTooltip, TooltipLinkList } from '@storybook/comp

import { useParameter, useAddonState } from '@storybook/api';
import { PARAM_KEY, ADDON_ID } from './constants';
import { MINIMAL_VIEWPORTS } from './defaults';
import { ViewportAddonParameter, ViewportMap, ViewportStyles, Styles } from './models';

interface ViewportItem {
Expand Down Expand Up @@ -122,7 +123,7 @@ export const ViewportTool: FunctionComponent<{}> = React.memo(
const { viewports, defaultViewport, disable } = useParameter<ViewportAddonParameter>(
PARAM_KEY,
{
viewports: {},
viewports: MINIMAL_VIEWPORTS,
defaultViewport: responsiveViewport.id,
}
);
Expand Down Expand Up @@ -195,13 +196,15 @@ export const ViewportTool: FunctionComponent<{}> = React.memo(
},
[`#${wrapperId}`]: {
padding: theme.layoutMargin,
display: 'grid',
alignContent: 'center',
alignItems: 'center',
justifyContent: 'center',
Copy link
Member

Choose a reason for hiding this comment

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

if its not a flex container do we still need justify content and align items?

Copy link
Member Author

Choose a reason for hiding this comment

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

display: grid

justifyItems: 'center',
overflow: 'auto',
gridTemplateColumns: 'minmax(0, 1fr)',

display: 'grid',
gridTemplateColumns: '100%',
gridTemplateRows: '100%',
},
}}
/>
Expand Down
27 changes: 27 additions & 0 deletions addons/viewport/src/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,30 @@ export const INITIAL_VIEWPORTS: ViewportMap = {
},
};
export const DEFAULT_VIEWPORT = 'responsive';

export const MINIMAL_VIEWPORTS: ViewportMap = {
mobile1: {
name: 'Small mobile',
styles: {
height: '568px',
width: '320px',
},
type: 'mobile',
},
mobile2: {
name: 'Large mobile',
styles: {
height: '896px',
width: '414px',
},
type: 'mobile',
},
tablet: {
name: 'Tablet',
styles: {
height: '1112px',
width: '834px',
},
type: 'tablet',
},
};