👨🏼‍💻

khriztianmoreno's Blog

Home Tags About |

Posts with tag storybook

Why Storybook? The component development tool used by over 30,000 projects

2022-08-22
javascriptstorybookreact

Storybook is a tool for developing components and user interfaces faster than ever. Storybook is incredibly versatile: you can use it with a variety of JavaScript libraries and frameworks, not just React. It is available for Vue, React, Svelte, Angular, and Ember.js.StorybookIf you have been developing your components the old-fashioned way, in your text editor or IDE, a tool like Storybook allows you to unlock greater productivity when developing components. Next, you will learn what Storybook is, how it works, and if it is suitable for your team.The problems of developing components traditionallyLet's start by looking at the friction involved with the typical component development process:You receive a task to develop a feature: let's say it's a form on the checkout page.Then, you need to set up the development environment: connect to the VPN, run the backend, run the frontend, etc.Finally, you get to the page where the feature will live.It is cumbersome to navigate between multiple pages, fill out forms, and click buttons every time you need to get to where the feature should be. Sometimes, your components have multiple states, for example, loading, success, and error. It is not always easy to replicate all the states of a component, which leads you to modify the component code just to force a specific state.Storybook isolates your components: easier component debuggingYou may have gone through these situations and encountered the pain involved in this type of component development workflow.Most of the time, while developing, you want to focus on the component you are creating, so other elements on a page become noise. Having a way to quickly access any component or feature, and also being able to simulate all use cases, is incredibly beneficial and saves you a lot of time.Storybook provides you with this type of component isolation so you can work only on the component you have in mind, without having to interact with other components.What is Storybook?Storybook is an open-source tool that helps you develop user interface components in isolation. It runs on your codebase, but separately from your application, so it works like a sandbox, allowing developers not to be distracted by incomplete APIs, unstable data, and other external dependencies. It integrates with frameworks like React, Vue, Svelte, Angular, and others.Think of Storybook as a real book, with an index of pages that links to the user interface components. Each component has stories to tell about itself, and these stories represent the different states of the component's user interface. Regardless of the situation, even if you are offline, you will be able to access that page and easily find and play with the components.Due to its productivity and collaboration advantages, Storybook is used by more than 30,000 open-source projects, especially component libraries. However, many tech companies, such as Airbnb, Atlassian, and JetBrains, are among its users.Who is Storybook for?Some people seem to think that Storybook is a tool only for component library developers, and that is certainly not the case.Storybook helps us build from the simplest and most atomic component, like a button or an input, to complex features or entire pages.Since Storybook helps us summarize the user interface of applications, designers and QA can benefit from it. With Storybook, you can facilitate the development of a design system and share a single language with designers. QA can get an overview and test functionalities in isolation. Storybook can even be used to demonstrate functionality to stakeholders, as if it were a demo.Many companies have made their Storybooks public. They are not only an inspiration but also a learning guide for teams new to Storybook, and you can find a list of public Storybooks here.How it worksFrom a technical aspect, Storybook is essentially a React application that runs on your codebase, separately from your main application. You start it by running a CLI command. It will look for files in your codebase that contain a .stories.* extension, gather all those components, and display them in a nice user interface.Suppose you are creating, for example, a restaurant card. You would have a RestaurantCard.stories.tsx file, which represents the component with mocked properties for each scenario.It is important to note that Storybook does not produce any production code. Your .stories.tsx files are used solely for development purposes.I hope this was helpful and/or taught you something new!Profile@khriztianmoren

Systems Design with ReactJS and Storybook

2020-03-05
javascriptreactstorybookdesign-system

Document and test your React components in isolation using Storybook.Storybook ReactStorybook Reacttl;dr: In this post, we will learn how to set up the necessary infrastructure to build a reusable component design system in React, using Storybook.Let's start by understanding that a design system is a series of components that can be reused in different combinations. Design systems allow you to manage design. If we go to designsystemsrepo.com, we can see the design systems used by some of the largest companies and strongest brands, such as Priceline, Apple, IBM, WeWork, GitHub, and even the US government.Design systems can be a significant productivity multiplier in any medium to large-sized project or company, as we can document our components as we develop them, ensuring a consistent look and feel across all screens, and having a continuous workflow between designers and developers.<iframe width="100%" height="315" src="https://www.youtube.com/embed/guteTaeLoys?si=_8X6KwUOZCjQvwan" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>Throughout this video, we will progressively build a very simple design system that contains a single button, but I will show several of the features that Storybook can offer to improve our development experience and project speed.We will learn to set up the StoryBook used in production by everyone from Lonely Planet to Uber, but at the same time, we will keep it as simple as possible, so we can reuse these APIs for our future needs.I hope this has been helpful and/or taught you something new!Profile@khriztianmoreno �