Skip to content
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

install storybook and add stories #1

Merged
merged 19 commits into from
Feb 17, 2022
Merged

install storybook and add stories #1

merged 19 commits into from
Feb 17, 2022

Conversation

woriwori
Copy link
Owner

@woriwori woriwori commented Feb 17, 2022

Initialize storybook

Install

dependencies will be installed automatically

$ npx sb init

Config

// main.js

module.exports = {
   stories: ['../src/components/**/*.stories.js'], // changes to the location of your story files
    addons: [ /* ... */ ], // a list of the addons you are using
    framework: '@storybook/react', // after running the above script, storybook set up this field automatically
    webpackFinal: /* ... */ // I use this for alias config (it is the same as jsconfig.json)
}
// preview.js 

import '...css'; // must import global css file

module.exports = {
  // ...
  controls: {
    expanded: true, // expand controls tab
    // ...
  }
}

Structure the stories

  • Reference with 10 storybooks best practices
  • stay the story files with its component
    • make component's directory : CommonTable
    • not make components's directory : the other components
  • One storybook file per component with Playground and Default and the others

Add storybook addons

Fix a bug

I got below error message when I run the storybook script

Default PostCSS plugins are deprecated. When switching to '@storybook/addon-postcss'

So, I fixed this error by running below script

$ npx sb upgrade --prerelease

storybookjs/storybook#12668 (comment)

After that, in preview.js, parameter.core.builder was added and two packages (@storybook/builder-webpack5 and @storybook/manger-webpack5) was installed.

Issues

When I set true for parameter.controls.expanded in preview.js, controls tab must read the prop types of the component.
But, it's not working.
I think this is an issue of a current version. (6.4.19)
(Because I checked other project is working with expanded option. and the version of that project was 6.4.18)
So I will continue to check this issue and a new version of storybook.

@woriwori woriwori merged commit 2f1f99d into master Feb 17, 2022
@woriwori woriwori deleted the storybook-v1 branch February 17, 2022 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant