-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow setting custom default viewport per story
- Loading branch information
1 parent
7cd29fa
commit f212451
Showing
9 changed files
with
254 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
examples/official-storybook/stories/__snapshots__/addon-viewport.stories.storyshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Storyshots Addons|Viewport default 1`] = ` | ||
<div | ||
style="font-family:-apple-system, \\".SFNSText-Regular\\", \\"San Francisco\\", BlinkMacSystemFont, \\"Segoe UI\\", \\"Roboto\\", \\"Oxygen\\", \\"Ubuntu\\", \\"Cantarell\\", \\"Fira Sans\\", \\"Droid Sans\\", \\"Helvetica Neue\\", \\"Lucida Grande\\", \\"Arial\\", sans-serif;color:#444;-webkit-font-smoothing:antialiased" | ||
> | ||
I don't have problems being rendered using the default viewport. | ||
</div> | ||
`; | ||
|
||
exports[`Storyshots Addons|Viewport.Custom Default (Kindle Fire 2) Inherited 1`] = ` | ||
<div | ||
style="font-family:-apple-system, \\".SFNSText-Regular\\", \\"San Francisco\\", BlinkMacSystemFont, \\"Segoe UI\\", \\"Roboto\\", \\"Oxygen\\", \\"Ubuntu\\", \\"Cantarell\\", \\"Fira Sans\\", \\"Droid Sans\\", \\"Helvetica Neue\\", \\"Lucida Grande\\", \\"Arial\\", sans-serif;color:#444;-webkit-font-smoothing:antialiased" | ||
> | ||
I've inherited | ||
<b> | ||
Kindle Fire 2 | ||
</b> | ||
viewport from my parent. | ||
</div> | ||
`; | ||
|
||
exports[`Storyshots Addons|Viewport.Custom Default (Kindle Fire 2) Overridden 1`] = ` | ||
<div | ||
style="font-family:-apple-system, \\".SFNSText-Regular\\", \\"San Francisco\\", BlinkMacSystemFont, \\"Segoe UI\\", \\"Roboto\\", \\"Oxygen\\", \\"Ubuntu\\", \\"Cantarell\\", \\"Fira Sans\\", \\"Droid Sans\\", \\"Helvetica Neue\\", \\"Lucida Grande\\", \\"Arial\\", sans-serif;color:#444;-webkit-font-smoothing:antialiased" | ||
> | ||
I respect my parents but I should be looking good on | ||
<b> | ||
iPhone 6 | ||
</b> | ||
. | ||
</div> | ||
`; |
27 changes: 27 additions & 0 deletions
27
examples/official-storybook/stories/addon-viewport.stories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
import { baseFonts } from '@storybook/components'; | ||
|
||
import { withViewport, Viewport } from '@storybook/addon-viewport'; | ||
|
||
// eslint-disable-next-line react/prop-types | ||
const Panel = ({ children }) => <div style={baseFonts}>{children}</div>; | ||
|
||
storiesOf('Addons|Viewport', module).add('default', () => ( | ||
<Panel>I don't have problems being rendered using the default viewport.</Panel> | ||
)); | ||
|
||
storiesOf('Addons|Viewport.Custom Default (Kindle Fire 2)', module) | ||
.addDecorator(withViewport('kindleFire2')) | ||
.add('Inherited', () => ( | ||
<Panel> | ||
I've inherited <b>Kindle Fire 2</b> viewport from my parent. | ||
</Panel> | ||
)) | ||
.add('Overridden', () => ( | ||
<Viewport name="iphone6"> | ||
<Panel> | ||
I respect my parents but I should be looking good on <b>iPhone 6</b>. | ||
</Panel> | ||
</Viewport> | ||
)); |