Style Guide Driven Development
Tags: styleguidedrivendevelopment, livingstyleguide, storybook, angular
Published: 2019-07-23 15:44:57

---
title: Style Guide Driven Development
published: true
description: 
tags: styleguidedrivendevelopment, livingstyleguide, storybook, angular
---

>"We are not designing pages, we are designing systems of components."
~ Stephen Hay

## Style Guide Driven Development (SGDD)
SGDD is about converting static style guide into dynamic style guide from the earliest stages of User Interface (UI) development. The dynamic style guide also known as Living Style Guide.

### Static Style Guide (SSG)
The static style guide is a file that documents typography, colors/palettes, fonts and many more. They also contain details like spacing info (margin and padding). Nowadays designer prefer to use more sketch-friendly tool like [Zeplin](https://zeplin.io/). 

### Living Style Guide (LSG)
Living Style Guide reflects the latest version of the implemented design and includes demos showing interaction and behaviour. Example of the LSG is the extremely popular [Bootstrap](https://getbootstrap.com/)

![](https://blog.getbootstrap.com/assets/img/2017/v4-beta2-theming-docs.png)

All the components placed in the left panel and the right panel contain the view of the component and below it is the code to be used by Developers.

> A design system isn't just a library of assets with some documentation, it's how you collaborate and communicate between teams and disciplines. 
~ Nataly Athree at "cssday"

Before we go to Development life-cycles with SGDD, let's discuss methodology being used in component development. There is plenty of them and my personal choice is [Atomic Design](http://bradfrost.com/blog/post/atomic-web-design/).

> Atomic design is a mental model that allows you to concurrently create both the parts and the whole of a UI design system 
~ Brad Frost

> This methodology analyzes the relationships between the different parts of the system and how they interrelate, using chemistry as an analogy. 
~ Adriana De La Cuadra (Bitovi)

![](http://bradfrost.com/wp-content/uploads/2013/06/atomic-design.png)

#### Atoms
Atoms are the basic building blocks of matter. Applied to web interfaces, atoms are our HTML tags, such as a form label, an input or a button.

#### Molecules
Molecules are groups of atoms bonded together and are the smallest fundamental units of a compound.

#### Organisms
Organisms are groups of molecules joined together to form a relatively complex, distinct section of an interface.

#### Templates
Templates consist mostly of groups of organisms stitched together to form pages.

#### Pages
Pages are specific instances of templates.

![](https://thepracticaldev.s3.amazonaws.com/i/lzmaeya557vyyx86yu18.png)

### SGDD with Atomic Design

![](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ss9hi898riv1qzmhfg0i.png)

#### 1. Design Audit
This is when the designer gathered all the requirements and created SSG.
At this stage the LSG serves as a reference when creating designs. Designer would refer to LSG and considering to reusing or extending the atoms components or create the new atom component. 

#### 2. Component Abstractions
Once the designs are ready to be implemented, designers and developers can use the style guide to discuss how the new features should be broken down into separate components. These is where activity like recomposing the molecules and introducing new component variants happened. 

#### 3. Publish into Living Style-Guide
This is the process where the component development started. With SGDD in mind the development is all about creating the component and documenting it in LSG. In the end, the LSG becomes both a framework and a playground.
- It's a framework because it provides the rules that define how elements should look and behave.
- It's a playground as implementer or application developers can interact and straight away see how the component behaves.

#### 4. Integration
Application developer (library implementor) uses the atoms and molecules components by referring to the LSG for code sample and implementation guide to come up with templates and pages. Its "plug and play" game.

> You've heard of plug-and-play. This is plug, unplug and play. It's so simple to use, it's unbelievable. ~ Steve Jobs

### LSG with Storybook
[Storybook](https://storybook.js.org/) is the most popular UI component development tool for Angular, React and Vue. It helps you develop and design UI components outside your app in an isolated environment.
This article uses Angular as development tool for UI component.

![](https://thepracticaldev.s3.amazonaws.com/i/efemkpkdfdp9h9zrz72c.png)

Basic features of Storybook is Action, Story and Knobs

#### Action
Track any interaction to the component like "click", "mouseover", "double-click" and many more.

![](https://thepracticaldev.s3.amazonaws.com/i/6dv5yfvlyzkjw0ei707r.png)

#### Story
Implementation code that can be copied by developer.

![](https://thepracticaldev.s3.amazonaws.com/i/w2rdf7bcbgfvdltgbfdk.png)

#### Knobs
Knobs allow us to edit the component inputs dynamically.

![](https://thepracticaldev.s3.amazonaws.com/i/4fc0em1mxz9nasq1fiy1.png)

> Storybook is a powerful frontend workshop environment tool that allows teams to design, build, and organize UI components (and even full screens!) without getting tripped up over business logic and plumbing ~ Brad Frost

> Storybook has made developing components more streamlined by allowing us to easily include technical documentation within our design system! ~ Taurie Davis

#### Setting up the Storybook
Its recommended to use the [official guide](https://storybook.js.org/docs/guides/guide-angular/). If everything going smoothly, the command for creating angular-storybook is just one line command:

```cmd
npx -p @storybook/cli sb init --type angular
```

## Summary
One way to bridge the gap between developers and designers is to bring the SGDD into our workflow. Combining SGDD with Atomic Design helps to accelerate the process of creating modular designs. Having Living Style Guide as single truth documentation boosts development time and team communication.