-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Storybook: Addon to wrap stories in max-width div (#45134)
- Loading branch information
1 parent
eded26a
commit cdbbcb0
Showing
2 changed files
with
54 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import styled from '@emotion/styled'; | ||
|
||
/** | ||
* A Storybook decorator to wrap a story in a div applying a max width and | ||
* padding. This can be used to simulate real world constraints on components | ||
* such as being located within the WordPress editor sidebars. | ||
*/ | ||
|
||
const Wrapper = styled.div` | ||
max-width: 248px; | ||
`; | ||
|
||
const Indicator = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 32px; | ||
background: #e0e0e0; | ||
text-transform: uppercase; | ||
font-size: 11px; | ||
font-weight: 500; | ||
color: #757575; | ||
margin-top: 24px; | ||
`; | ||
|
||
export const WithMaxWidthWrapper = ( Story, context ) => { | ||
if ( context.globals.maxWidthWrapper === 'none' ) { | ||
return <Story { ...context } />; | ||
} | ||
|
||
return ( | ||
<Wrapper> | ||
<Story { ...context } /> | ||
<Indicator>Max-Width Wrapper - 248px</Indicator> | ||
</Wrapper> | ||
); | ||
}; |
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