<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Chroma</title>
    <description>The latest articles on DEV Community by Chroma (@chroma).</description>
    <link>https://dev.to/chroma</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F29%2Fa3ddda79-10ee-4626-b2d3-391b79837af4.png</url>
      <title>DEV Community: Chroma</title>
      <link>https://dev.to/chroma</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/chroma"/>
    <language>en</language>
    <item>
      <title>Introducing LearnStorybook.com</title>
      <dc:creator>Dominic Nguyen</dc:creator>
      <pubDate>Tue, 10 Apr 2018 13:01:01 +0000</pubDate>
      <link>https://dev.to/chroma/introducing-learnstorybookcom-1k6d</link>
      <guid>https://dev.to/chroma/introducing-learnstorybookcom-1k6d</guid>
      <description>&lt;h4&gt;
  
  
  A tutorial that teaches you Storybook by building a working UI
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;TLDR:&lt;/strong&gt; 👋 Dev.to we’re launching &lt;a href="https://www.learnstorybook.com/"&gt;&lt;strong&gt;Learn Storybook&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt; &lt;/strong&gt; — a fast, approachable, and free tutorial to get started with Storybook. Whether you're a new or experienced frontend developer, this tutorial gives you a head start learning the UI component tool used by professional teams. Includes real code commits synced to chapters to make it easy to keep up.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.learnstorybook.com/"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Zr_fQzwS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2Au5fKA8sePfQ8RVJylSPJTg.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you work on the frontend like me you may have heard of Storybook (originally called React Storybook). At first you probably dismissed it. Another day, another dev tool.&lt;/p&gt;

&lt;p&gt;Yet an increasing number of developers and savvy designers use Storybook to build UIs. Teams at Airbnb, Dropbox, IBM, Lonely Planet, and Mozilla rely on it everyday. And Storybook has grown beyond React to support nearly every major view layer. By now, you might be wondering what the hype is all about?&lt;/p&gt;

&lt;h2&gt;
  
  
  A tool for the future of UI development
&lt;/h2&gt;

&lt;p&gt;To make sense of Storybook let’s take a brief detour to the frontend landscape. UI development is undergoing a renaissance inspired by new view layers like React, Vue, and Angular.&lt;/p&gt;

&lt;p&gt;Folks no longer think in pages but in components. Components still output the familiar HTML, CSS, and JavaScript triumvirate, but the means of generating that output has evolved.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--U_N5pOTu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/600/1%2Ag_NWhiyrHR2URLtR12waVg.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--U_N5pOTu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/600/1%2Ag_NWhiyrHR2URLtR12waVg.gif" alt=""&gt;&lt;/a&gt;Throw attributes at a component and watch it render different permutations.&lt;/p&gt;

&lt;p&gt;With React, developers have new tools like &lt;strong&gt;props&lt;/strong&gt; , &lt;strong&gt;context&lt;/strong&gt; , and &lt;strong&gt;state&lt;/strong&gt; to render UI. The core innovation shared by these “modern” view layers is the component construct which makes it easy to break down complex UIs into simple modules.&lt;/p&gt;

&lt;p&gt;Component-oriented development requires new tooling to help developers concentrate on building UI components. Storybook is the most popular and fully featured UI component tool. It’s also the only tool that supports most view layers.&lt;/p&gt;

&lt;h2&gt;
  
  
  OK, but what does Storybook do?
&lt;/h2&gt;

&lt;p&gt;Storybook helps you build durable UIs faster. It runs alongside your app in development mode and provides a “sandbox” to build UI components in isolation of business logic or context from your app. This allows you to focus on clearly defining the component API –the set of inputs a component takes.&lt;/p&gt;

&lt;p&gt;Developers create “stories” by passing a unique set of inputs to a component to yield different variations (similar to specs in unit testing). These stories are indexed and documented in Storybook so you can visually check on them during development or revisit later during testing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RBZA_Lyj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2Ae0qaK7VJ7HnAnMvEit1C0Q.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RBZA_Lyj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2Ae0qaK7VJ7HnAnMvEit1C0Q.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://www.learnstorybook.com/"&gt;Learn Storybook&lt;/a&gt; — a hands-on tutorial
&lt;/h2&gt;

&lt;p&gt;More frontend teams than ever rely on Storybook. But there aren’t many resources on &lt;strong&gt;how to use Storybook from first principles.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://twitter.com/tmeasday"&gt;Tom Coleman&lt;/a&gt; and &lt;a href="http://twitter.com/domyen"&gt;I&lt;/a&gt; created Learn Storybook, a free 9 chapter tutorial, to teach tried-and-true patterns for component development using Storybook.&lt;/p&gt;

&lt;p&gt;You’ll walk through essential UI component techniques while building a UI from the ground up in Storybook (great for project-based learners).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4QFQnpog--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A4IrlYDsMEI2LgV20_FVB-g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4QFQnpog--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A4IrlYDsMEI2LgV20_FVB-g.png" alt=""&gt;&lt;/a&gt;Build Taskbox, a task management UI&lt;/p&gt;

&lt;h3&gt;
  
  
  What you’ll learn
&lt;/h3&gt;

&lt;p&gt;You’ll learn best practices sourced from professional teams, core maintainers, and the fantastic Storybook community. In addition, get the wider context to understand why those best practices exist. Each chapter walks through different aspects of using Storybook and is synced to a &lt;strong&gt;real commit&lt;/strong&gt; in a working demo app.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🏗 Setup the development environment&lt;/li&gt;
&lt;li&gt;🔨 Build a simple component in isolation&lt;/li&gt;
&lt;li&gt;🛠 Assemble a composite component out of simple components&lt;/li&gt;
&lt;li&gt;💡 Wire in data with containers&lt;/li&gt;
&lt;li&gt;💻 Construct a screen&lt;/li&gt;
&lt;li&gt;🚦 Test a UI component library&lt;/li&gt;
&lt;li&gt;🚀 Deploy Storybook&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Who this is great for
&lt;/h3&gt;

&lt;p&gt;Storybook should be approachable to everyone whether you’re senior, junior, developer, or designer. If you follow along, you’ll grasp the core concepts of isolated UI component development and build a full UI in Storybook without a problem. It’s great for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;👩‍💻 Experienced developers&lt;/strong&gt; who have heard of Storybook and want an efficient tutorial that highlights key features and workflow&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;👩‍🎓 New developers&lt;/strong&gt; who want to learn a tool used by professional teams at Github, Artsy, and Priceline.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;👩‍🎨 Product designers&lt;/strong&gt; interested in UI components and the nuts &amp;amp; bolts of building component libraries.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I hope &lt;a href="https://www.learnstorybook.com/"&gt;&lt;strong&gt;Learn Storybook&lt;/strong&gt;&lt;/a&gt; helps you, well, learn Storybook!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LN20Ka4f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/64/1%2AGtyOd4Uan21s07cExngbrg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LN20Ka4f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/64/1%2AGtyOd4Uan21s07cExngbrg.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Contributors welcome
&lt;/h2&gt;

&lt;p&gt;Learn Storybook is &lt;a href="https://github.com/hichroma/learnstorybook.com/"&gt;open source&lt;/a&gt;. Our goal is to introduce Storybook to the world. We’re looking for &lt;a href="https://www.learnstorybook.com/contribute/"&gt;Vue and Angular contributors&lt;/a&gt; (the example code is currently React) and help &lt;a href="https://github.com/hichroma/learnstorybook.com/issues/3"&gt;translating the tutorial&lt;/a&gt; to other languages. Also report bugs!&lt;/p&gt;

&lt;p&gt;Originally published at &lt;a href="https://blog.hichroma.com/introducing-learnstorybook-com-2a43cd33edf5"&gt;Chroma&lt;/a&gt;&lt;/p&gt;




</description>
      <category>react</category>
      <category>components</category>
      <category>storybook</category>
      <category>styleguide</category>
    </item>
    <item>
      <title>Beyond Bootstrap –moving from UI toolkit to component library</title>
      <dc:creator>Dominic Nguyen</dc:creator>
      <pubDate>Tue, 06 Jun 2017 15:01:01 +0000</pubDate>
      <link>https://dev.to/chroma/beyond-bootstrap-moving-from-ui-toolkit-to-component-library</link>
      <guid>https://dev.to/chroma/beyond-bootstrap-moving-from-ui-toolkit-to-component-library</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F986%2F1%2AUMdYa8Cvv7nncxtz6CwB-w.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F986%2F1%2AUMdYa8Cvv7nncxtz6CwB-w.jpeg"&gt;&lt;/a&gt;Image: &lt;a href="http://www.spatialagency.net/database/haus-rucker-co" rel="noopener noreferrer"&gt;Haus-Rucker-Co&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first factory predates the industrial revolution by hundreds of years. &lt;a href="https://en.wikipedia.org/wiki/Venetian_Arsenal" rel="noopener noreferrer"&gt;Venice’s Arsenal&lt;/a&gt; pioneered assembling naval ships out of standardized parts. Engineers of the time discovered that it was quicker and easier to &lt;em&gt;assemble&lt;/em&gt; complex things from their constituent parts rather than &lt;em&gt;build&lt;/em&gt; them from scratch. Today, we’re seeing this idea of &lt;a href="https://blog.hichroma.com/prefabricated-components-2932bfc992ba" rel="noopener noreferrer"&gt;prefabrication&lt;/a&gt; and assembly take hold in a different sphere of engineering: building user interfaces.&lt;/p&gt;

&lt;p&gt;User interfaces are increasingly assembled from standardized parts. &lt;strong&gt;UI toolkits&lt;/strong&gt; like &lt;a href="https://getbootstrap.com" rel="noopener noreferrer"&gt;Bootstrap&lt;/a&gt; were among the first to provide a generic collection of parts for web UIs. These toolkits enabled developers to easily find and apply patterns in their apps.&lt;/p&gt;

&lt;p&gt;Companies too recognized the value of having their own UI toolkit. They created &lt;strong&gt;living styleguides&lt;/strong&gt; to match the look and feel of their brands. However, building a styleguide requires significant resources so only larger teams tended to invest in them.&lt;/p&gt;

&lt;p&gt;A key change in the industry has come with the advent of &lt;strong&gt;UI&lt;/strong&gt;  &lt;strong&gt;components&lt;/strong&gt; â€Š–â€Šbuilding blocks of user interface akin to Legos. Components simplify building custom UI toolkits because they encapsulate design patterns in modular standardized units.&lt;/p&gt;

&lt;p&gt;This paradigm shift allows teams of any size to create “ &lt;strong&gt;component libraries&lt;/strong&gt;  tailored to their exact needs and brand. Today, I’ll walk through how we got here and the process of creating your own component library.&lt;/p&gt;

&lt;h2&gt;
  
  
  User interface assembly
&lt;/h2&gt;

&lt;p&gt;Frontend developers build the same user interfaces over and over. There aren’t many &lt;em&gt;functional&lt;/em&gt; differences between them. You’ll usually find the standard combination of header, sidebar, lists, and forms.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F600%2F1%2AHUUqhC5phoYZFWR4n8VDWg.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F600%2F1%2AHUUqhC5phoYZFWR4n8VDWg.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Throughout history people have found that it’s more productive if people assemble new products from existing parts. User interface engineering is no exception. Composing new views out of existing UI parts is faster than building them from the ground up.&lt;/p&gt;

&lt;p&gt;At first these patterns took the form of ad hoc code snippets. They lived in text files stashed somewhere on developers’ machines (pre-Github). Albeit not very shareable, these bits of UI code had enormous utility to the frontend developer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bootstrap and UI toolkits
&lt;/h2&gt;

&lt;p&gt;Bootstrap came along and consolidated these pieces of UI code into a single well-documented collection. The key idea of UI toolkits was to provide an inventory of generic/universal &lt;strong&gt;design patterns&lt;/strong&gt; (with accompanying code).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AKG74W9pMhj29IfkNoCZAwA.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AKG74W9pMhj29IfkNoCZAwA.jpeg"&gt;&lt;/a&gt;Bootstrap’s designÂ patterns&lt;/p&gt;

&lt;p&gt;At the time, the workflow was revolutionary in its simplicity. You copy–pasted markup and got workable user interfaces. UI toolkits made it trivial to scaffold simple sites and line-of-business apps.&lt;/p&gt;

&lt;p&gt;The concept of UI toolkits had an enormous impact on design and development. It proved that designers could ensure user interface consistency throughout the development process. It also highlighted how easy it could be to create UIs using a toolkit to developers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Living styleguides
&lt;/h2&gt;

&lt;p&gt;Living styleguides are organization-specific UI toolkits. Teams saw the inherent value in UI toolkits, but often had specific look and feel requirements. They couldn’t just adopt Bootstrap, Foundation, or Semantic.&lt;/p&gt;

&lt;p&gt;The classic downside of something like Bootstrap is that you must adhere to its prescribed idioms and styles. Sites that rely on popular toolkits tend to look the same. You can probably see why this isn’t ideal for a company looking to stand out in the market.&lt;/p&gt;

&lt;p&gt;Like Bootstrap, living styleguides provided a similar inventory of design patterns along with code, but these patterns reflected the particulars of company branding and design.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://walmartlabs.github.io/web-style-guide/#buttons" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2Apfc0_uCd1d1DpdK3-EtUXg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At the scale of &lt;a href="https://www.yelp.com/styleguide#buttons" rel="noopener noreferrer"&gt;Yelp&lt;/a&gt;, &lt;a href="https://walmartlabs.github.io/web-style-guide/#buttons" rel="noopener noreferrer"&gt;Walmart&lt;/a&gt; or the &lt;a href="http://codeforamerica.clearleft.com/" rel="noopener noreferrer"&gt;US government&lt;/a&gt;, reusing existing design patterns yielded massive efficiency gains. Living styleguides made it easy for big companies to create a consistent look and feel &lt;em&gt;across&lt;/em&gt; their web properties.&lt;/p&gt;

&lt;p&gt;However, creating a living styleguide is a significant undertakingâ€Š–â€Šoften requiring coordination from the top down. There are countless UI permutations to design, build, and maintain accompanied by the daunting task of getting buy-in from everyone on the team. Realistically, the luxury of living styleguides was reserved only for large teams.&lt;/p&gt;

&lt;h2&gt;
  
  
  Component libraries
&lt;/h2&gt;

&lt;p&gt;Component libraries are a pragmatic way for teams –large &lt;em&gt;and&lt;/em&gt; small– to get the ease of Bootstrap, the customizability of living styleguides, and the flexibility of modern view layer technology.&lt;/p&gt;

&lt;p&gt;The widespread adoption of view layers like React, Angular, and Vue compel teams to decompose UIs into simple components. These components serve as the building blocks of apps; the collection of components is the basis of a component library.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AUsivbxsBxiiltJ2dYjniqA.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AUsivbxsBxiiltJ2dYjniqA.gif"&gt;&lt;/a&gt;A self-contained &lt;a href="http://airbnb.io/react-dates/" rel="noopener noreferrer"&gt;DatePicker&lt;/a&gt; component&lt;/p&gt;

&lt;h3&gt;
  
  
  Components: self-contained functionality
&lt;/h3&gt;

&lt;p&gt;As a construct, components are more powerful &lt;em&gt;and&lt;/em&gt; easier to use abstractions than raw code. They are self-contained pieces of functionality that have well-defined inputs and outputs.&lt;/p&gt;

&lt;p&gt;Self-containment encourages developers to scope functionality, markup, and styling(this area is &lt;a href="https://medium.com/seek-blog/a-unified-styling-language-d0c208de2660" rel="noopener noreferrer"&gt;rapidly evolving&lt;/a&gt;) at the component-level. No need to rely on toolkit-level JavaScript or stylesheets, with UI components all of this can be encapsulated in the component.&lt;/p&gt;

&lt;h3&gt;
  
  
  Small teams can build component libraries
&lt;/h3&gt;

&lt;p&gt;The focus on components –the user interface equivalent to Legos– makes it easy for small teams and individuals to start building their own inventory of custom design patterns &lt;strong&gt;piecemeal&lt;/strong&gt;. Since you progressively accumulate UI components, the startup cost of a component library turns out to be less than building a living styleguide (which often requires much forethought and planning).&lt;/p&gt;

&lt;p&gt;In addition, flexibility is inherent to component libraries. Each component can be added, updated, or replaced without affecting the integrity of the library. This means that you’re not constrained to one UI toolkit at a time, you can mix, match, and customize components from around the web as needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do I get started?
&lt;/h2&gt;

&lt;p&gt;Whether you have an existing app with components or are building one anew, starting to accrue the benefits of a component library is easy. Since you’re able to add components individually and the tools to build libraries tend to be &lt;em&gt;development-only&lt;/em&gt; by default, the cost to try a component library is close to nil. Let’s see how to get started in 4-steps.&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Get a place to “store your components.
&lt;/h4&gt;

&lt;p&gt;Components are often buried inside apps. This isn’t ideal because people have to scour through directories and screens to see components in action. What you want is a central place to catalog and visualize your components. You can find these library-like features in a &lt;a href="https://blog.hichroma.com/the-crucial-tool-for-modern-frontend-engineers-fb849b06187a" rel="noopener noreferrer"&gt;component explorer&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F992%2F1%2AjTl0e2sNMfJQX3znZULmEA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F992%2F1%2AjTl0e2sNMfJQX3znZULmEA.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  Component explorers
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;React:&lt;/strong&gt; &lt;a href="https://github.com/storybooks/storybook" rel="noopener noreferrer"&gt;Storybook&lt;/a&gt;, &lt;a href="https://github.com/react-cosmos/react-cosmos" rel="noopener noreferrer"&gt;Cosmos&lt;/a&gt;, &lt;a href="https://github.com/carteb/carte-blanche" rel="noopener noreferrer"&gt;Carte Blanche&lt;/a&gt;, &lt;a href="https://react-styleguidist.js.org/" rel="noopener noreferrer"&gt;Styleguidist&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Angular:&lt;/strong&gt; &lt;a href="https://github.com/ui-storybook/sb" rel="noopener noreferrer"&gt;UI Storybook&lt;/a&gt;, &lt;a href="http://www.angularplayground.it/" rel="noopener noreferrer"&gt;Playground&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vue:&lt;/strong&gt; &lt;a href="https://github.com/vue-play/vue-play" rel="noopener noreferrer"&gt;Vue play&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ember:&lt;/strong&gt; &lt;a href="https://chrislopresto.github.io/ember-freestyle/" rel="noopener noreferrer"&gt;Freestyle&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clojure:&lt;/strong&gt; &lt;a href="https://github.com/bhauman/devcards" rel="noopener noreferrer"&gt;Devcards&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Meteor:&lt;/strong&gt; &lt;a href="https://github.com/meteor/chromatic/" rel="noopener noreferrer"&gt;Chromatic&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  2. Index existing components
&lt;/h4&gt;

&lt;p&gt;Once you get a component explorer, it’s time to index your app’s existing components so they can be found.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AzmoiFngqTlycnY7k4IK-VQ.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AzmoiFngqTlycnY7k4IK-VQ.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Start by importing the component explorer tool at the top of your component file (the exact syntax varies between component explorersâ€Š–â€ŠI’m simplifying for readability).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;import { specsOf } from â€˜@component-explorer/explorer’;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Next, write your first “test states for that component as specs. For instance a Toggle component might have default and active state.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;specsOf(â€˜Toggle’) 
  .add(â€˜default’, () =&amp;gt; &amp;lt;Toggle active={false} /&amp;gt;) 
  .add(â€˜active’, () =&amp;gt; &amp;lt;Toggle active={true} /&amp;gt;)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then checkout the component in action via the component explorer. Repeat this process to index other components and grow your library.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F900%2F1%2AAw8z6q9HDZVQRNWcq8GK4A.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F900%2F1%2AAw8z6q9HDZVQRNWcq8GK4A.gif"&gt;&lt;/a&gt;A toggle component in Storybook&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Browse thousands of open source components
&lt;/h4&gt;

&lt;p&gt;There are plenty of readymade UI components available from organizations like &lt;a href="https://medium.com/u/e7b0f31549dd" rel="noopener noreferrer"&gt;Salesforce&lt;/a&gt;, &lt;a href="https://medium.com/u/ebe93072cafd" rel="noopener noreferrer"&gt;AirbnbEng&lt;/a&gt;, and &lt;a href="https://medium.com/u/991272e72e68" rel="noopener noreferrer"&gt;Google&lt;/a&gt;. Familiar UI toolkits like Bootstrap and Foundation have also been converted to UI components. For complex components like graphs, I suggest browsing what is already available before building something from scratch.&lt;/p&gt;

&lt;h4&gt;
  
  
  4. Add open source components to your library.
&lt;/h4&gt;

&lt;p&gt;Once you’ve found something you like, it’s time to put it in the component explorer (as we did in step 2). This gives you an isolated playground to tweak the readymade component before integrating it into your app.&lt;/p&gt;

&lt;p&gt;Let’s simulate the process of adding an example LineGraph component to the library.&lt;/p&gt;

&lt;p&gt;Installing via NPM: &lt;code&gt;npm install linegraph&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Create a new file to import the component, the component explorer, and record the test states as specs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { specsOf } from â€˜@component-explorer/explorer’;
import LineGraph from 'linegraph';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add a few test states to adjust the look and feel in isolation with your component explorer. Here’s how the component would look with a default and active state:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;specsOf('LineGraph')  
  .add('Default', () =&amp;gt; 
    &amp;lt;LineGraph data={latencies.map(latency =&amp;gt; ({    
      latency,
      count: 5000 + Math.random() * 15000,  
  }))} /&amp;gt;)

.add('Active', () =&amp;gt; 
    &amp;lt;LineGraph active={true} data={latencies.map(latency =&amp;gt; ({    
      latency,
      count: 5000 + Math.random() * 15000,  
  }))} /&amp;gt;)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F980%2F1%2AoCsBsPX1QtvQPSWKaBnrLQ.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F980%2F1%2AoCsBsPX1QtvQPSWKaBnrLQ.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you’ve adjusted the specs to match your needs, it’s simple to add the component wherever you need it in your app and use similar specs to achieve the intended appearance.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2ADTzw9Ci4Q2_aM_gWNzwtXw.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2ADTzw9Ci4Q2_aM_gWNzwtXw.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Beyond Bootstrap
&lt;/h2&gt;

&lt;p&gt;Bootstrap pioneered the use of readymade user interfaces. People could pull interface elements off the shelf to rapidly build UIs. However, it required adherence to prescribed idioms and styles.&lt;/p&gt;

&lt;p&gt;Living styleguides allowed organizations to offer the same rapid development experience as Bootstrap with a custom look and feel. The challenge was that these styleguides required significant effort.&lt;/p&gt;

&lt;p&gt;A component library is a practical middle ground that enables rapid development and customization without needing much in the form of organizational momentum. Here at Chroma, we are big proponents of component libraries because they tend to guide teams into reuse and UI consistency without being authoritarian about it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/media/c066cf834200d80e25b62a6de730a4a6/href" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="https://medium.com/media/c066cf834200d80e25b62a6de730a4a6/href" rel="noopener noreferrer"&gt;https://medium.com/media/c066cf834200d80e25b62a6de730a4a6/href&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Learn more about UI components:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://blog.hichroma.com/prefabricated-components-2932bfc992ba" rel="noopener noreferrer"&gt;Why you should build UI components in isolation Â»&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blog.hichroma.com/ui-component-playbook-fd3022d00590" rel="noopener noreferrer"&gt;5-step guide to creating modular frontends Â»&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;This post was originally published on &lt;a href="https://blog.hichroma.com/beyond-bootstrap-moving-from-ui-toolkit-to-component-library-f0a34f05e98b" rel="noopener noreferrer"&gt;blog.hichroma.com&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ui</category>
      <category>componentlibraries</category>
      <category>react</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Prefabricated components –the case for building UI components in isolation</title>
      <dc:creator>Tom Coleman</dc:creator>
      <pubDate>Tue, 16 May 2017 17:17:51 +0000</pubDate>
      <link>https://dev.to/chroma/prefabricated-components-the-case-for-building-ui-components-in-isolation-447</link>
      <guid>https://dev.to/chroma/prefabricated-components-the-case-for-building-ui-components-in-isolation-447</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2Av0v4Hn8m5itjSUP5qeWC5w.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2Av0v4Hn8m5itjSUP5qeWC5w.jpeg"&gt;&lt;/a&gt;Y:Cube by &lt;a href="https://www.rsh-p.com/projects/ycube/" rel="noopener noreferrer"&gt;Rogers Stirk Harbour +Â Partners&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One of my favourite TV shows is “Grand Designs”. It’s a British homebuilding show where host Kevin McCloud observes people building a wide variety of homes. If you’ve been following the show, as I have, there is a trend that’s hard to ignore.&lt;/p&gt;

&lt;p&gt;Housing projects, especially less expensive and quicker ones, are increasingly using prefabricated (“prefab”) materials. The idea of prefab is to construct &lt;strong&gt;components&lt;/strong&gt; of a house in a factory before shipping them to the job site where they are joined together. It replaces the traditional method of constructing a home from raw materials on the building site (hammering together wood, setting concrete, etc.).&lt;/p&gt;

&lt;p&gt;Costs can be further cut if you use &lt;strong&gt;off-the-shelf&lt;/strong&gt; prefab materials like wall panels in certain “commodity sizes. Anyone who has built an Ikea kitchen is probably familiar with the idea.&lt;/p&gt;

&lt;p&gt;Why is prefab such a transformative concept? It’s not hard to understand that building one piece at a time in controlled conditions like a factory, makes &lt;a href="http://gph.is/2b1DIJW" rel="noopener noreferrer"&gt;construction quick and easy&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;What does all this have to do with building software user interfaces (UIs)? Prefab parallels the process of developing UIs from components. We just need a “factory to construct our components “off-site”. That factory is the &lt;strong&gt;Component Explorer&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AVzVs2p6NvmfAWTb2smZiiQ.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AVzVs2p6NvmfAWTb2smZiiQ.jpeg"&gt;&lt;/a&gt;Building &lt;em&gt;apartment housing &lt;/em&gt;in isolation (Capsys)&lt;/p&gt;

&lt;h3&gt;
  
  
  Component Explorers
&lt;/h3&gt;

&lt;p&gt;A &lt;a href="https://blog.hichroma.com/the-crucial-tool-for-modern-frontend-engineers-fb849b06187a" rel="noopener noreferrer"&gt;component explorer&lt;/a&gt; is a tool which allows you to work with a single component from your app in &lt;strong&gt;isolation&lt;/strong&gt;. So rather than building a component “on-site of the app screen where it is first used, you use a tool that isolates the one component.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AxI4ULfnT3i19RdcU0LbUaw.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AxI4ULfnT3i19RdcU0LbUaw.gif"&gt;&lt;/a&gt;Component explorers help you build components in isolation&lt;/p&gt;

&lt;p&gt;In order to do this, you must document the states of the component that you are interested in. This means rather than manipulating your development app into the right configuration to see your component, you explicitly write down the state you care about.&lt;/p&gt;

&lt;p&gt;The component explorer is the factory for components.&lt;/p&gt;

&lt;h3&gt;
  
  
  Building on-site vs prefabricating: a case study
&lt;/h3&gt;

&lt;p&gt;The idea of prefabrication is to frame, insulate, wire, plaster and paint a wall in a factory rather than on-site in unpredictable conditions. You don’t need a lot of construction experience to see why this approach makes sense. In fact, if you are like me (and most software engineers, I reckon) you are probably now thinking it’s crazy to do it any other way.&lt;/p&gt;

&lt;p&gt;If you don’t have the same reaction to the idea of prefabricating a UI component, perhaps we need to look a little closer at the two methodologies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let’s consider a case study:&lt;/strong&gt; building a complex histogram for an analytics product, used in various contexts to display various latency distributions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2A_k5Oj-0ODdt9adWaE9fu6Q.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2A_k5Oj-0ODdt9adWaE9fu6Q.jpeg"&gt;&lt;/a&gt;&lt;strong&gt;Our example histogram component&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  On-site
&lt;/h4&gt;

&lt;p&gt;If I’m building the histogram “onsite”, then I’ll start with one of the screens where it’s used.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1&lt;/strong&gt; I’ll start by thinking about the most obvious use-case for the component then fill my database with some typical-looking data. I’ll build the component directly on screen where it’s supposed to live.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (i = 20; i &amp;lt;= 120; i+= 10) {
  db.latencyCounts.insert({
    queryId: 'abc-123',
    latency: i,
    count: 5000 * Math.random() * 15000,
  });
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2A2jblc8K8-A3hsO9MGBaQhw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2A2jblc8K8-A3hsO9MGBaQhw.jpeg"&gt;&lt;/a&gt;A query to generate some test data; what that data looks likeÂ in-situ&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2&lt;/strong&gt; Now, I might think about a different style of data, perhaps an new user with a limited set of measurements. I’ll delete some data from my database and tweak the component to make sure it still looks OK.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (i = 20; i &amp;lt;= 120; i+= 10) {
  if (i !== 110) {
    db.latencyCounts.update({
      queryId: 'abc-123',
      latency: i,
    },
    {
      $set: {
        count: Math.random() * 1000,
      }
    });
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AKZw-bEb9pPDaTido4PBZQw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AKZw-bEb9pPDaTido4PBZQw.jpeg"&gt;&lt;/a&gt;&lt;strong&gt;Low data resolution&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I’d better check the data I created in step 1 to ensure my changes didn’t adversely affect my original implementation, though.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3&lt;/strong&gt; What about when there’s no data at all? Let’s try that (making sure we check any implementation changes against steps 1 and 2’s data).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.latencyCounts.remove({ queryId: 'abc-123' });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AT6AhAgeAzOdAz9aawWwMdQ.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AT6AhAgeAzOdAz9aawWwMdQ.jpeg"&gt;&lt;/a&gt;&lt;strong&gt;No data&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4&lt;/strong&gt; Let’s get this thing out to QA, we’ll deploy to a staging server. Oh! We noticed it doesn’t render well in the loading state. How can we see that locally? Maybe we need to hack our server to “hang so we can work on the loading state. Better check our changes against steps 1–3 too.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AB6cierqXZt_s4b9OyXadGA.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AB6cierqXZt_s4b9OyXadGA.jpeg"&gt;&lt;/a&gt;&lt;strong&gt;Loading&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5&lt;/strong&gt; Design has come back with a bunch of fiddly visual tweaks based on their testing (are we sure they tested all the states we worked on? Here’s hoping!). Let’s make those changes then ensure they don’t break the states from steps 1–4&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2ACifScw824hLaziFG4CWolw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2ACifScw824hLaziFG4CWolw.jpeg"&gt;&lt;/a&gt;&lt;strong&gt;With last minute designÂ tweaks&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6&lt;/strong&gt; After deploying to production, a user reports the graph looks bad for their unique, unusual data set! Better (anonymously) import that data into our local db and fix it. Oh, and we should run through states from steps 1–5 again.&lt;/p&gt;

&lt;p&gt;This process happens over extended time periods so it may not be easy (or fun) to remember the commands to reproduce step 1 by the time we get to step 6. Let’s be honest, there’s probably a good chance we won’t actually check it!&lt;/p&gt;

&lt;p&gt;We write tests to encode known use cases and avoid regressionsâ€Š–â€Šbut &lt;a href="https://blog.hichroma.com/visual-testing-the-pragmatic-way-to-test-uis-18c8da617ecf" rel="noopener noreferrer"&gt;writing tests for UIs is hard&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Regressions happen when use cases are forgotten or ignored.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Prefab
&lt;/h4&gt;

&lt;p&gt;When prefabricating a component, instead of indirectly maneuvering our component into the state we want to work on, we carefully detail the exact states we are interested in. The component explorer is a tool that allows us to experience the component in each of these states &lt;strong&gt;in isolation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Typically, this means that each step is simpler; rather than messing with the database or carefully tailoring our development account to contain the right information, we just document the state we want to experiment with.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { storiesOf } from '@kadira/storybook';
import Histogram from './Histogram';

const latencies = [];
for (var i = 20; i &amp;lt;= 120; i += 20) {
  latencies.push(i);
}

storiesOf('Histogram')
  .add('Typical', () =&amp;gt; &amp;lt;Histogram data={latencies.map(latency =&amp;gt; ({
    latency,
    count: 5000 + Math.random() * 15000,
  }))} /&amp;gt;)
  .add('Low data', () =&amp;gt; &amp;lt;Histogram data={latencies.map(latency =&amp;gt; ({
    latency,
    count: latency === 110 ? 5000 + Math.random() * 15000 : Math.random() * 1000,
  }))} /&amp;gt;)
  .add('No data', () =&amp;gt; &amp;lt;Histogram data={latencies.map(latency =&amp;gt; ({latency, count: 0}))} /&amp;gt;)
  .add('Loading', () =&amp;gt; &amp;lt;Histogram loading={true} /&amp;gt;);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Listing the states up front helps us to think clearly about the states that the histogram supports. &lt;strong&gt;Each time you work on a new state, you encode a permanent version of it.&lt;/strong&gt; Every time we need to check back a state we previously worked on, it’s simply a matter of clicking back in the component explorer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AodZ7Yu2GXPh-wq9PIyBfVQ.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AodZ7Yu2GXPh-wq9PIyBfVQ.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Like a set of tests, this is an accruing set of artifacts in our project that will enable us to maintain quality over time and avoid regressions. We can also show each state to our designer for refinement –and we get it for free! In most cases it is &lt;strong&gt;easier&lt;/strong&gt;  &lt;strong&gt;to build out a state than to maneuver the app into the right configuration.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Barriers to prefabricating
&lt;/h3&gt;

&lt;p&gt;Just like folks in the construction industry who may object to prefabrication (“that’s not how we do things”), developers sometimes resist building components in isolation. There are a variety of common worries; here’s a short list (let me know if you have others!), and some reasons why they’re less problematic than you may think.&lt;/p&gt;

&lt;h4&gt;
  
  
  Too much work
&lt;/h4&gt;

&lt;p&gt;Building states feels like writing tests. It’s something that many developers think they “should do but when under time pressure, put off.&lt;/p&gt;

&lt;p&gt;As I mentioned, like tests, component states are an accruing benefit. However, in our and many others’ experience, developing in isolation is usually less –often &lt;em&gt;far&lt;/em&gt; less– work than developing in context. There’s just less fussing around.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Don’t assume the job is done after step 1 of our case study above!&lt;/strong&gt; Although it might feel like you can build the component quickly, it’s rarely the case that you don’t have to keep revisiting it, and to do that properly, you need to check all the states that you’ve considered in the past.&lt;/p&gt;

&lt;h4&gt;
  
  
  Hard to isolate components
&lt;/h4&gt;

&lt;p&gt;Some coding patterns, or just time constraints, lead to components that are hard to render on their own. They require some kind of application context (“environment”) which makes them difficult to separate out in a component explorer.&lt;/p&gt;

&lt;p&gt;Developing in isolation will naturally steer you away from writing components like this. Aside from being &lt;a href="https://blog.hichroma.com/hidden-in-plain-site-the-levels-of-component-reuse-ee9b0d7b1bd2" rel="noopener noreferrer"&gt;easier to reuse&lt;/a&gt;, and simpler to test, such environment-independent components are generally good practice to develop.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F468%2F1%2A2at8wthhIE7RwdXU_Y_kUQ.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F468%2F1%2A2at8wthhIE7RwdXU_Y_kUQ.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;I’m confident that once you start working on components in isolation, you’ll soon be prefabricating the essentials of your appâ€Š–â€Šperhaps even entire screens!&lt;/p&gt;

&lt;p&gt;If you’re just dipping your toes, the best place to experiment with isolation is on your next &lt;em&gt;complicated&lt;/em&gt; component build. The histogram above is a good example because it has many different inputs that all need to be checked for correctness. So next time you start working on a doozie, &lt;a href="https://blog.hichroma.com/the-crucial-tool-for-modern-frontend-engineers-fb849b06187a" rel="noopener noreferrer"&gt;give a component explorer a try&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;There are many other benefits of isolating components using component explorers like communication within the team and visual testing. Here at Chroma we are huge proponents of developing in this fashion (we call it “&lt;a href="https://blog.hichroma.com/component-driven-development-ce1109d56c8e" rel="noopener noreferrer"&gt;Component-Driven Development&lt;/a&gt;”), and if you want to hear more about the benefits, signup to our mailing list. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/media/e6ea71d37dd27a6a941e5c78ec8d8bf4/href" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="https://medium.com/media/e6ea71d37dd27a6a941e5c78ec8d8bf4/href" rel="noopener noreferrer"&gt;https://medium.com/media/e6ea71d37dd27a6a941e5c78ec8d8bf4/href&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This post was originally published on &lt;a href="https://blog.hichroma.com/prefabricated-components-2932bfc992ba" rel="noopener noreferrer"&gt;blog.hichroma.com&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>frontend</category>
      <category>components</category>
      <category>react</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
