-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
storybook: add markdown support #91817
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅ ✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #91817 +/- ##
==========================================
- Coverage 87.64% 85.26% -2.39%
==========================================
Files 10350 10344 -6
Lines 586527 585977 -550
Branches 22574 22531 -43
==========================================
- Hits 514068 499605 -14463
- Misses 72013 85926 +13913
Partials 446 446 |
export const PalettePanel = styled(Panel)` | ||
margin-bottom: 0; | ||
`; | ||
|
||
export const PalettePanelItem = styled(PanelItem)` | ||
flex-direction: column; | ||
gap: ${space(0.5)}; | ||
|
||
&:first-child { | ||
border-radius: ${p => p.theme.borderRadius} ${p => p.theme.borderRadius} 0 0; | ||
} | ||
&:last-child { | ||
border-radius: 0 0 ${p => p.theme.borderRadius} ${p => p.theme.borderRadius}; | ||
} | ||
&:first-child:last-child { | ||
border-radius: ${p => p.theme.borderRadius}; | ||
} | ||
|
||
background: ${p => p.theme[p.color]}; | ||
color: ${p => p.theme[p.text]}; | ||
`; | ||
|
||
export const ExampleImg = styled('img')` | ||
border: 1px solid ${p => p.theme.border}; | ||
border-radius: ${p => p.theme.borderRadius}; | ||
max-width: 400px; | ||
`; | ||
|
||
export const PositiveLabel = styled(({className}) => ( | ||
<div className={className}> | ||
<IconCheckmark /> | ||
DO | ||
</div> | ||
))` | ||
color: ${p => p.theme.green400}; | ||
align-items: center; | ||
display: flex; | ||
font-weight: ${p => p.theme.fontWeightBold}; | ||
gap: ${space(0.5)}; | ||
`; | ||
|
||
export const NegativeLabel = styled(({className}) => ( | ||
<div className={className}> | ||
<IconClose color="red400" /> | ||
DON'T | ||
</div> | ||
))` | ||
color: ${p => p.theme.red400}; | ||
align-items: center; | ||
display: flex; | ||
font-weight: ${p => p.theme.fontWeightBold}; | ||
gap: ${space(0.5)}; | ||
`; | ||
|
||
export const ExampleCardGrid = styled('figcaption')` | ||
display: grid; | ||
grid-template-columns: 1fr 2fr; | ||
align-items: flex-start; | ||
color: ${p => p.theme.subText}; | ||
padding: ${space(1)} ${space(1)} 0; | ||
`; | ||
|
||
export const ExampleCard = ({imgSrc, text, isPositive}) => ( | ||
<figure> | ||
<ExampleImg src={imgSrc} /> | ||
<ExampleCardGrid> | ||
{isPositive ? <PositiveLabel /> : <NegativeLabel />} | ||
<span>{text}</span> | ||
</ExampleCardGrid> | ||
</figure> | ||
); | ||
|
||
export const ColorPalette = ({name, palette}) => { | ||
const theme = useTheme(); | ||
|
||
return ( | ||
<SideBySideList> | ||
{palette.map((section, i) => { | ||
return ( | ||
<li key={`${name}-${i}`}> | ||
<PalettePanel typeof="ul"> | ||
{section.map((color, index) => { | ||
return ( | ||
<PalettePanelItem | ||
key={`${name}-${color.color}-${index}`} | ||
color={color.color} | ||
text={color.text} | ||
> | ||
<strong>{color.color}</strong> | ||
{theme[color.color]} | ||
</PalettePanelItem> | ||
); | ||
})} | ||
</PalettePanel> | ||
</li> | ||
); | ||
})} | ||
</SideBySideList> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be great to move these local components out of this file... would these make more sense in the stories file where other helpers are?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will open a PR and just move all of these story components to a single file or directory I think. They are all kinda spread around the codebase, and I never actually know where to find anything.
test: /\.mdx?$/, | ||
use: [ | ||
{ | ||
loader: 'builtin:swc-loader', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nightmare of subdependencies but looks good
Long term, the plan is very likely to move this out of the codebase entirely. Unfortunately, before we are able to do that, we need to untangle the module graph, and that is quite the undertaking 😅 By adding this loader, we can essentially focus on writing the docs, which is the bulk of the value, before we ultimately lift it out |
Add mdx support for stories. This allows us to write mdx compliant markup which is commonly supported by documentation framework and friendlier to write than jsx. The mdx loader also conveniently exports a default export which means that we can omit the concept of storybook entirely
Add mdx support for stories. This allows us to write mdx compliant markup which is commonly supported by documentation framework and friendlier to write than jsx.
The mdx loader also conveniently exports a default export which means that we can omit the concept of storybook entirely