Storybook With Angular
Image source Google

Storybook With Angular

Have you heard about the Storybook?

Let me explain what is Storybook. A storybook is a tool for UI development. It makes development faster and easier. Storybook will provide us with a user-friendly interface for the developer of the component which has been created with the configuration options. Also, the storybook helps to visualize the component in different devices and themes. Storybook helps us document components for reuse and automatically visually test your components to prevent bugs. Once your component is ready you can create a storybook file with the configuration options available for the user. Storybook provides different configurations to update the component based on the developer's need as well as he can copy the component code from the documentation.

Installing Storybook In angular

Installing Storybook to an Angular project is simple and easy we just need to run this command. npx sb init. On our package.json we can see that some scripts have been added. Note: I have updated the script default script may vary. To run Storybook locally, we can just run the command npm run storybook.  

We just have to create components in the angular application and we have to add the appropriate inputs which we need as a configuration parameter. Then we have to create a story for the component. We can create multiple stories in the project. In each story, we have to bind the component, and then we have to create a template. After creating the template object we have to bind that to a story and we need to pass arguments to that story. Please refer to the button story

What is the story? 

A story captures the rendered state of a UI component. We can write multiple stories per component that describe all the “interesting” states.

Sample Code

https://github.com/harshal77/storybook-web-components/tree/development

要查看或添加评论,请登录

Harshal S.的更多文章

  • Unit Testing In Angular

    Unit Testing In Angular

    What & Why Unit Testing? Unit testing your #Angular application helps you check that your application is working as you…

  • Micro Frontend With Angular & React Using Module Federation

    Micro Frontend With Angular & React Using Module Federation

    I have already explained how micro frontend work please check out this link if you are aware of it (Micro Frontend)…

    9 条评论
  • Create Your First NPM package using Angular

    Create Your First NPM package using Angular

    NPM:- ( Node Package Manager). NPM is the package manager for the Node JavaScript platform.

    2 条评论
  • Micro Frontend with Module Federation

    Micro Frontend with Module Federation

    I have already explained how micro frontend work please check out this link if you are aware of it (Micro Frontend) Now…

    10 条评论
  • The simple explanation of Microfrontend

    The simple explanation of Microfrontend

    Modern web apps are more complicated, and some of them are managed by multiple teams. When you want to put one of the…

    11 条评论
  • Send emails using Node.js, Nodemailer, and Angular and verify user account

    Send emails using Node.js, Nodemailer, and Angular and verify user account

    This code sends a simple HTML email using the free SMTP testing service and after getting the verification mail user…

    3 条评论

社区洞察

其他会员也浏览了