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
Storybook: Convert stories to CSF 3 #435
Conversation
🦋 Changeset detectedLatest commit: 945a8d9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
size-limit report 📦
|
import { | ||
ArgsTable, | ||
Description, | ||
Primary, | ||
PRIMARY_STORY, | ||
Stories, | ||
Subtitle, | ||
Title, | ||
} from '@storybook/addon-docs'; | ||
|
||
import { GuidelineLink } from '@config/GuidelineLink'; | ||
|
||
export const configureDocsPage = (componentName) => { | ||
return () => ( | ||
<> | ||
<Title /> | ||
<Subtitle /> | ||
<Description /> | ||
{componentName && <GuidelineLink path={componentName} />} | ||
<Primary /> | ||
<ArgsTable story={PRIMARY_STORY} /> | ||
<Stories /> | ||
</> | ||
); | ||
}; |
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.
This is a noteworthy file; I extracted the common ordering of items for the Docs tab of each component into a reusable piece. This was previously specified implicitly in each story using MDX, but now gets added in the parameters.docs.page
configuration of the default export for each component.
features: { | ||
previewCsfV3: true, | ||
}, |
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.
This allows us to use Component Story Format (CSF) version 3 in the stories, and will become the default in Storybook v7.
This necessitated getting rid of dynamic component titles, namely for showing e.g. "Pharos 12.13.0" in the left nav. I opted instead to inject the version as the title of the intro page. I had to wrestle with MDX a bit to do this; it appears the "components" and "props" features documented on their site are v2 features, but our Storybook is still using v1. I attemped to enable the v2 preview, but HTML comments cause a parsing error currently and we need them for our README setup to function properly.
* develop: Tabs: fix initial tab selection in more cases (#449) Storybook: add eslint-plugin-storybook and fix issues (#446) feat(storybook): install Measure and Outline addons (#445) Docs: update copy for Button's on-background usage (#444) Storybook: Convert stories to CSF 3 (#435) feat(tabs): fire event when tab selected programmatically (#442) ToggleButton: indicate toggle button state on underlying button elements (#438) Tooltip, DropdownMenu: replace popperjs with floating-ui (#434) Site: improve imports (#433)
* feat(storybook): try CSF for Alert stories * chore(storybook): convert alert WC story to CSF 3 * chore(storybook): convert alert React story to CSF 3 * chore(storybook): extract DocsPage config and convert breadcrumb to CSF3 * chore(storybook): convert Button stories to CSF 3 * chore(storybook): convert Checkbox stories to CSF 3 * chore(storybook): convert CheckboxGroup stories to CSF 3 * chore(storybook): convert Combobox stories to CSF 3 * chore(storybook): convert DropdownMenu stories to CSF 3 * chore(storybook): convert DropdownMenuNav stories to CSF 3 * chore(storybook): convert Footer stories to CSF 3 * chore(storybook): convert Header stories to CSF 3 * chore(storybook): convert Heading stories to CSF 3 * chore(storybook): convert Icon stories to CSF 3 * chore(storybook): convert ImageCard stories to CSF 3 * chore(storybook): convert InputGroup stories to CSF 3 * chore(storybook): convert Layout stories to CSF 3 * chore(storybook): convert Link stories to CSF 3 * chore(storybook): convert LoadingSpinner stories to CSF 3 * chore(storybook): convert Modal stories to CSF 3 * chore(storybook): convert Pagination stories to CSF 3 * chore(storybook): convert ProgressBar stories to CSF 3 * chore(storybook): convert RadioButton stories to CSF 3 * chore(storybook): convert RadioButtonGroup stories to CSF 3 * chore(storybook): convert Select stories to CSF 3 * chore(storybook): convert Sidenav stories to CSF 3 * chore(storybook): convert Tabs stories to CSF 3 * chore(storybook): convert TextInput stories to CSF 3 * chore(storybook): convert Textarea stories to CSF 3 * chore(storybook): convert Toast stories to CSF 3 * chore(storybook): convert ToggleButtonGroup stories to CSF 3 * chore(storybook): convert Tooltip stories to CSF 3 * chore(storybook): convert Page stories to CSF 3 * chore(storybook): convert Styles stories to CSF 3 * fix(storybook): make diverged stories consistent * chore(storybook): clean up imports * fix: add type declarations and remove console log * chore: add changeset * fix(storybook): fix React Storybook build * feat(storybook): enable new build options This necessitated getting rid of dynamic component titles, namely for showing e.g. "Pharos 12.13.0" in the left nav. I opted instead to inject the version as the title of the intro page. I had to wrestle with MDX a bit to do this; it appears the "components" and "props" features documented on their site are v2 features, but our Storybook is still using v1. I attemped to enable the v2 preview, but HTML comments cause a parsing error currently and we need them for our README setup to function properly. * fix(storybook): update webpack config to fix GitHub Actions * fix(storybook): remove new Babel config to fix build * fix(storybook): remove inline render to try fixing build * fix(storybook): remove story store v7 to fix build
This change: (check at least one)
Is this a breaking change? (check one)
Is the: (complete all)
What does this change address?
Resolves #244
How does this change work?
Convert
Alert
stories from MDX to CSF.Compare the new page to the current page.
Notable improvements:
source: { type: 'code' } }
from the React story configuration so that the Code option below examples shows copy/pastable code instead of some raw story code. This is how the web component stories already work.defaultArgs
and theargTypes
extracted to astoryArgs
module so both the web component and the React component story can make use of them.Some things to look out for:
argTypes
, but now it's all of them unless otherwise specified in a story'sinclude/exclude
parameters. Maybe this is fine; more stories end up being something you can fiddle with and link to for collaborative purposes, which is useful.addon-storysource
has not yet caught up to CSF 3 and doesn't display any code in the Story panel when using the Canvas. The code block on the Docs tab does still work, however.Additional context
The two story files look more similar than ever—the only difference is really that one uses e.g. the
<pharos-alert>
web component while the other uses e.g. the<PharosAlert>
React component.