-
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: Add margin checker tool (#43223)
- Loading branch information
Showing
2 changed files
with
55 additions
and
1 deletion.
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 show a div before and after the story to check for unwanted margins. | ||
*/ | ||
|
||
const Bumper = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 32px; | ||
background-image: repeating-linear-gradient( | ||
45deg, | ||
transparent, | ||
transparent 2px, | ||
#e0e0e0 2px, | ||
#e0e0e0 14px | ||
); | ||
text-transform: uppercase; | ||
font-size: 11px; | ||
font-weight: 500; | ||
color: #757575; | ||
`; | ||
|
||
export const WithMarginChecker = ( Story, context ) => { | ||
if ( context.globals.marginChecker === 'hide' ) { | ||
return <Story { ...context } />; | ||
} | ||
|
||
return ( | ||
<> | ||
<Bumper>Margin Checker</Bumper> | ||
<Story { ...context } /> | ||
<Bumper>Margin Checker</Bumper> | ||
</> | ||
); | ||
}; |
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