Upgrade storybook to v6 - #47777
Conversation
This reverts commit ce74acc.
7af6159 to
3f09e55
Compare
|
|
||
| render() { | ||
| const rendered = markdownToReact.processSync(this.props.markdown).contents; | ||
| const rendered = markdownToReact.processSync(this.props.markdown).result; |
There was a problem hiding this comment.
note about this change: the unified library was upgraded with storybook, and the structure of the object returned from processSync changed with that upgrade. there are unit/UI tests that cover this and i manually tested components to make sure nothing changed
| // } | ||
| // }, | ||
| features: { | ||
| babelModeV7: true |
There was a problem hiding this comment.
details about this feature: https://storybook.js.org/docs/react/configure/babel#v7-mode
| ### Seeing your development version of Apps in Dashboard | ||
|
|
||
| 1. To make your changes show up in dashboard, do the following after the first time you build apps: | ||
| - Set `use_my_apps: true` to your locals.yml config file. |
There was a problem hiding this comment.
my editor reformatted some extra stuff in this file when i made changes, sorry 🤷🏻♀️
bencodeorg
left a comment
There was a problem hiding this comment.
A couple notes/questions, but excited about this!
| buttonLink: 'to a new page', | ||
| dismissible: false | ||
| }; | ||
| InfoCallToActionButton.storyName = 'Information - call-to-action button'; |
There was a problem hiding this comment.
When do you add a storyName vs not?
There was a problem hiding this comment.
i only renamed stories when i thought it made more sense for organization/readability purposes. in this file, i thought
Information - call-to-action-button
Information - two buttons and a link
Information
was more readable in the storybook panel than
Information Call To Action Button
Information Two Buttons And A Link
Information
| // STORIES | ||
| // | ||
|
|
||
| export const HalfFull = Template.bind({}); |
There was a problem hiding this comment.
Found this in docs if anyone is curious what's going on here:
Template.bind({}) is a standard JavaScript technique for making a copy of a function. We copy the Template so each exported story can set its own properties on it.
| "start:craft": "DEV=1 grunt dev --app=craft --watch-notify;", | ||
| "test-audio": "echo \"Open your browser to http://127.0.0.1:8080/test/audio/audio_test.html\" && http-server .", | ||
| "prestorybook": "curl -o build/package/css/application.css http://localhost-studio.code.org:3000/assets/application.css || curl -o build/package/css/application.css https://code-dot-org.github.io/cdo-styleguide/css/application.css", | ||
| "storybook": "start-storybook -p 9001 -s build/package/,../dashboard/public,../,../pegasus/sites.v3/code.org/public", |
There was a problem hiding this comment.
These are now in apps/.storybook/main.js if anyone's curious where they ended up :)
| ], | ||
| addons: ['@storybook/addon-actions', '@storybook/addon-options'], | ||
| framework: '@storybook/react', | ||
| // TODO: Add webpack5 configuration below when we upgrade to webpack 5. |
There was a problem hiding this comment.
Is this written down somewhere so we don't forget? Or will Storybook fully not work without this line uncommented
There was a problem hiding this comment.
it won't work! i have it written down personally since i'll be shipping the webpack upgrade (hopefully, unless something horrible comes up...) right after this is merged
| }); | ||
| // Customize webpack config for storybook. | ||
| // @param {Object} sbConfig - Webpack configuration from storybook library. | ||
| function storybookConfig(sbConfig) { |
There was a problem hiding this comment.
For my understanding, how does this work differently now? Did storybook not provide webpack config previously?
There was a problem hiding this comment.
i think storybook always provided some webpack configuration and would try to merge theirs with ours (previously provided by apps/.storybook/webpack.config.js) and it caused bugs and annoying confusion. so now there is a config function that supplies the storybook config and you can pick-and-choose what you want or just overwrite it (although i think that might break some storybook features if you just ignored their config)
There was a problem hiding this comment.
For my understanding, how did you decide where to include sbConfig when building the returned object? eg, no ...sbConfig.resolve.alias in resolve.alias?
There was a problem hiding this comment.
mostly guess-and-check 😅 i knew which configurations we cared about from our original storybookConfig options, so i tested out which options we needed from storybook and which we could overwrite/exclude without breaking anything
| } | ||
|
|
||
| function testStorybookFile(file) { | ||
| const {default: defaultExport, ...stories} = file; |
There was a problem hiding this comment.
What is defaultExport? A JS thing, Storybook?
There was a problem hiding this comment.
just JS. you can access the default export from the file object this way, but you can't name a variable named "default," so i'm renaming it here
|
@bencodeorg is this okay to merge, or do you want to take another look? |
bencodeorg
left a comment
There was a problem hiding this comment.
Some of the config stuff is over my head, but LGTM generally
| }); | ||
| // Customize webpack config for storybook. | ||
| // @param {Object} sbConfig - Webpack configuration from storybook library. | ||
| function storybookConfig(sbConfig) { |
There was a problem hiding this comment.
For my understanding, how did you decide where to include sbConfig when building the returned object? eg, no ...sbConfig.resolve.alias in resolve.alias?
Upgrades all packages within the
@storybook/scope to latest.As part of this upgrade, Storybook has a new API (e.g., the
storiesOfformat we are using is deprecated and no longer works in this version of Storybook; see "storiesOf (Legacy) API" for details). This means we need to refactor all stories to use the new CSF format. Storybook has an automated tool for this, but it worked on 0/226 of our Storybook files 😢 so we have to do this refactor manually. I estimate the average Storybook file will take 5-10 minutes to refactor.Implications of this upgrade:
Meter.story.jsxandNotification.story.jsxin this PR as examples.storiesOfAPI will be ignored by Storybook. If you runyarn storybookand your stories don't show up, that's probably why! Our unit test harness still supports the old API, so we do not lose any test coverage during this migration.I've added a README in
apps/.storybook/that outlines how Storybook should be used and documents this migration. This migration is also tracked in Storybook Files to Refactor (internal Google Doc) and PP-186.Resources: