-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Storybook: Convert stories to CSF 3 (#435)
* 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
- Loading branch information
Showing
162 changed files
with
7,715 additions
and
9,013 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,5 @@ | ||
--- | ||
'@ithaka/pharos': patch | ||
--- | ||
|
||
Update Storybook stories to Component Story Format (CSF) version 3 |
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,25 @@ | ||
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 /> | ||
</> | ||
); | ||
}; |
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 |
---|---|---|
@@ -1,4 +1,7 @@ | ||
module.exports = { | ||
features: { | ||
previewCsfV3: true, | ||
}, | ||
core: { | ||
builder: 'webpack5', | ||
}, | ||
|
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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
let config = require('../main'); | ||
|
||
config.stories.push('../../packages/pharos/**/*.@(react|docs|pages).stories.@(js|mdx|tsx)'); | ||
config.stories.push({ | ||
directory: '../../packages/pharos', | ||
files: '**/*.@(react|docs|pages).stories.@(js|jsx|mdx|tsx)', | ||
}); | ||
|
||
module.exports = config; |
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 |
---|---|---|
|
@@ -14,8 +14,5 @@ export const parameters = { | |
components: { | ||
Canvas: Canvas, | ||
}, | ||
source: { | ||
type: 'code', | ||
}, | ||
}, | ||
}; |
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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
let config = require('../main'); | ||
|
||
config.stories.push('../../packages/pharos/**/*.@(wc|docs|pages).stories.@(js|mdx|ts)'); | ||
config.stories.push({ | ||
directory: '../../packages/pharos', | ||
files: '**/*.@(wc|docs|pages).stories.@(js|jsx|mdx|ts)', | ||
}); | ||
|
||
module.exports = config; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
<div class="hide-in-storybook"> | ||
|
||
# Pharos Web Components | ||
|
||
</div> | ||
|
||
<!-- toc --> | ||
|
||
- [Installation](#installation) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { Meta } from '@storybook/addon-docs'; | ||
import Intro from '../CHANGELOG.md'; | ||
import PHAROS_TITLE from '../../../.storybook/pharosTitle'; | ||
|
||
<Intro /> | ||
import Changelog from '../CHANGELOG.md'; | ||
|
||
<Meta title={`${PHAROS_TITLE}/Changelog`} /> | ||
<Meta title="Pharos/Changelog" /> | ||
|
||
<Changelog /> |
77 changes: 77 additions & 0 deletions
77
packages/pharos/src/components/alert/PharosAlert.react.stories.jsx
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,77 @@ | ||
import { PharosAlert, PharosLink } from '../../react-components'; | ||
import { configureDocsPage } from '@config/docsPageConfig'; | ||
import { defaultArgs, argTypes } from './storyArgs'; | ||
|
||
export default { | ||
title: 'Components/Alert', | ||
component: PharosAlert, | ||
parameters: { | ||
docs: { | ||
page: configureDocsPage('alert'), | ||
}, | ||
}, | ||
argTypes, | ||
}; | ||
|
||
const Base = { | ||
render: ({ status, text, closable }) => ( | ||
<PharosAlert status={status} closable={closable}> | ||
{text} | ||
</PharosAlert> | ||
), | ||
args: defaultArgs, | ||
}; | ||
|
||
export const Info = { | ||
...Base, | ||
args: { | ||
status: 'info', | ||
text: 'There will be maintenance tomorrow.', | ||
}, | ||
}; | ||
|
||
export const Success = { | ||
...Base, | ||
args: { | ||
status: 'success', | ||
text: 'Success!', | ||
}, | ||
}; | ||
|
||
export const Warning = { | ||
render: ({ status, text, closable }) => ( | ||
<PharosAlert status={status} closable={closable}> | ||
<p className="alert-example__content">{text}</p> | ||
<p className="alert-example__content"> | ||
See <PharosLink href="#">how to fix this</PharosLink>. | ||
</p> | ||
</PharosAlert> | ||
), | ||
args: { | ||
status: 'warning', | ||
text: 'Your profile is incomplete.', | ||
}, | ||
}; | ||
|
||
export const Error = { | ||
render: ({ status, text, closable }) => ( | ||
<PharosAlert status={status} closable={closable}> | ||
<p className="alert-example__content">{text}</p> | ||
<p className="alert-example__content"> | ||
For more information, <pharos-link href="#">read the documentation</pharos-link>. | ||
</p> | ||
</PharosAlert> | ||
), | ||
args: { | ||
status: 'error', | ||
text: "Your password didn't meet the minimum requirements.", | ||
}, | ||
}; | ||
|
||
export const Closable = { | ||
...Error, | ||
args: { | ||
...Error.args, | ||
closable: true, | ||
}, | ||
}; |
100 changes: 0 additions & 100 deletions
100
packages/pharos/src/components/alert/PharosAlert.react.stories.mdx
This file was deleted.
Oops, something went wrong.
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
71 changes: 71 additions & 0 deletions
71
packages/pharos/src/components/alert/pharos-alert.wc.stories.jsx
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,71 @@ | ||
import { html } from 'lit'; | ||
import { configureDocsPage } from '@config/docsPageConfig'; | ||
import { defaultArgs, argTypes } from './storyArgs'; | ||
|
||
export default { | ||
title: 'Components/Alert', | ||
component: 'pharos-alert', | ||
parameters: { | ||
docs: { | ||
page: configureDocsPage('alert'), | ||
}, | ||
}, | ||
argTypes, | ||
}; | ||
|
||
const Base = { | ||
render: ({ status, text, closable }) => | ||
html`<pharos-alert status=${status} ?closable=${closable}>${text}</pharos-alert>`, | ||
args: defaultArgs, | ||
}; | ||
|
||
export const Info = { | ||
...Base, | ||
args: { | ||
status: 'info', | ||
text: 'There will be maintenance tomorrow.', | ||
}, | ||
}; | ||
|
||
export const Success = { | ||
...Base, | ||
args: { | ||
status: 'success', | ||
text: 'Success!', | ||
}, | ||
}; | ||
|
||
export const Warning = { | ||
render: ({ status, text, closable }) => | ||
html` <pharos-alert status=${status} ?closable=${closable}> | ||
<p class="alert-example__content">${text}</p> | ||
<p class="alert-example__content">See <pharos-link href="#">how to fix this</pharos-link>.</p> | ||
</pharos-alert>`, | ||
args: { | ||
status: 'warning', | ||
text: 'Your profile is incomplete.', | ||
}, | ||
}; | ||
|
||
export const Error = { | ||
render: ({ status, text, closable }) => | ||
html` <pharos-alert status=${status} ?closable=${closable}> | ||
<p class="alert-example__content">${text}</p> | ||
<p class="alert-example__content"> | ||
For more information, | ||
<pharos-link href="#">read the documentation</pharos-link>. | ||
</p> | ||
</pharos-alert>`, | ||
args: { | ||
status: 'error', | ||
text: "Your password didn't meet the minimum requirements.", | ||
}, | ||
}; | ||
|
||
export const Closable = { | ||
...Error, | ||
args: { | ||
...Error.args, | ||
closable: true, | ||
}, | ||
}; |
Oops, something went wrong.