Link: https://www.youtube.com/watch?v=BySFuXgG-ow&list=PLC3y8-rFHvwhC-j3x3t9la8-GQJGViDQk&index=1
- A development environment and playground for UI components
- Create components independently
- Showcase those components interactively in an isolated development environment
- Ability to view the different components that have already been developed
- View what are the different props that those developed components accept
- Ability to visually showcase those components to your stakeholders for feedback
- Dynamically change props, accessibility score.
- create a new react project
npx create-react-app react-storybook-v6
- add storybook
npx sb init
-
by running
npx sb init
- it adds
.storybook
folder in project root. There are 2 js files in this foldermain.js
- from this js we export object with 2 propertiesstories
addons
- addons are additional features, which get used while developing stories
preview.js
- contains configurations for the stories
- it adds
stories
folder in src- this folder contains boiler-plate code for stories
- it adds
-
To run storybook
npm storybook
- Same as 2.1, but for storybook v5
-
A storybook is , basically, a collection of stories. and each story represents a single vision of component.
-
As part of the story writing process, we will have 3 files
- component itself
- styles related to component
- story related to component
- command checks in
.storybook/main.js
for pattern and pickup the appropriate stories - It sees that any file with
*.stories.js
has to be picked up.