SlideShare a Scribd company logo
Violet Peña
FrontConf 2017
violet.is ✨ vgpena.github.io
Storybook
A React tool for your whole team
Guten Tag
Storybook 💖
Me me me
Violet Peña
Portland, OR, USA
Senior Developer @ Instrument
Violet Peña - Storybook: A React Tool For Your Whole Team
🏎
Efficiency
‣ How easy is it to write code?
‣ How stable is the codebase?
‣ How well does development integrate
with other disciplines?
🛠
🏆
What is
Storybook?
UI Development Environment
React, React Native, Vue
“component sandbox”
Storybook
basics
Plantiful
console
npm install storybook —save-dev
yarn storybook -D
console
yarn storybook
Violet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole Team
✨
✨
✨
✨
✨
Writing
Stories
stories.js
ComponentName
index.js
styles.css
ComponentName
index.js
styles.css
stories.js
Project
.storybook
addons.js
config.js
Let’s make
a Button
Button /index.js
import * as React from 'react';
import PropTypes from 'prop-types';
import './styles.css';
export class Button extends React.Component {
render() {
return (
<button
type="button"
className="button"
onClick={ this.props.function }
>
{ this.props.content }
</button>
);
}
}
Button.propTypes = {
content: PropTypes.string.isRequired,
function: PropTypes.func.isRequired,
};
Button /index.js
export class Button extends React.Component {
render() {
return (
<button
type="button"
onClick={ this.props.function }
>
{ this.props.content }
</button>
);
}
}
Button /index.js
export class Button extends React.Component {
render() {
return (
<button
type="button"
onClick={ this.props.function }
>
{ this.props.content }
</button>
);
}
}
Button /index.js
export class Button extends React.Component {
render() {
return (
<button
type="button"
onClick={ this.props.function }
>
{ this.props.content }
</button>
);
}
}
Button/stories.js
import * as React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { Button } from './';
const stories = storiesOf('Button', {});
stories.add('default', () => {
return (
<Button
content=“Button"
function={ action("clicked default button") }
/>
);
});
Button/stories.js
import * as React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { Button } from './';
const stories = storiesOf('Button', {});
stories.add('default', () => {
return (
<Button
content=“Button"
function={ action("clicked default button") }
/>
);
});
Button/stories.js
import * as React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { Button } from './';
const stories = storiesOf('Button', {});
stories.add('default', () => {
return (
<Button
content=“Button"
function={ action("clicked default button") }
/>
);
});
Button/stories.js
import * as React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { Button } from './';
const stories = storiesOf('Button', {});
stories.add('default', () => {
return (
<Button
content=“Button"
function={ action("clicked default button") }
/>
);
});
😍
😍
😍 😍
😍
Yeah it’s
pretty cool
Button/index.js
export const BUTTON_TYPES = {
DEFAULT: 'button',
POSITIVE: 'button button-save',
DANGER: 'button button-remove',
FUNCTION: 'button button-download',
}
🍰 🍨 🍩 🍫
Yes that
would be
nice
Button/index.js
import * as React from 'react';
import PropTypes from 'prop-types';
import './styles.css';
export const BUTTON_TYPES = {
DEFAULT: 'button',
POSITIVE: 'button button-save',
DANGER: 'button button-remove',
FUNCTION: 'button button-download',
}
export class Button extends React.Component {
render() {
return (
<button
type="button"
className={ this.props.type }
onClick={ this.props.function }
>
{ this.props.content }
</button>
);
}
}
Button.defaultProps = {
type: BUTTON_TYPES.DEFAULT,
};
Button.propTypes = {
content: PropTypes.string.isRequired,
type: PropTypes.oneOf(Object.values(BUTTON_TYPES)),
function: PropTypes.func.isRequired,
};
Button/index.js
export class Button extends React.Component {
render() {
return (
<button
type="button"
className={ this.props.type }
onClick={ this.props.function }
>
{ this.props.content }
</button>
);
}
}
Button/index.js
export class Button extends React.Component {
render() {
return (
<button
type="button"
className={ this.props.type }
onClick={ this.props.function }
>
{ this.props.content }
</button>
);
}
}
Let’s add
more
stories
Button/stories.js
stories.add('danger', () => {
return (
<Button
type={ BUTTON_TYPES.DANGER }
content={ "Remove Plant" }
function={ action("clicked danger button") }
/>
);
});
Violet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole Team
stories ~ props
1. default
2. danger
3. positive
4. functional
What’s so cool
about this?
‣ helps define requirements, scope
‣ illuminates complexity
‣ adds transparency to dev work
Project
managers
understand scope, size,
progress
deeplinking ftw
deeplinking ftw
🔑
Storybook wants
you to know
everything about
your project
But…
Our work is
dynamic
Foo B. Bar
Jr. Developer
Acme Co.
François B. McBarson
Jr. Mobile App Developer
Acme Supply Corporation
How can we
anticipate
dynamic
usage?
🙂
😎 😍 🤓 🤩
Knobs
Pass dynamic, editable props
into your stories
console
yarn add @storybook/addon-knobs -D
Project
.storybook
config.js
addons.js
Button/stories.js
import * as React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { withKnobs, text } from '@storybook/addon-knobs';
import { Button, BUTTON_TYPES } from './';
const stories = storiesOf('Button', {});
stories.addDecorator(withKnobs);
stories.add('default', () => {
return (
<Button
content={ text("Content", "Button") }
function={ action("clicked default button") }
/>
);
});
Button/stories.js
import * as React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { withKnobs, text } from '@storybook/addon-knobs';
import { Button, BUTTON_TYPES } from './';
const stories = storiesOf('Button', {});
stories.addDecorator(withKnobs);
stories.add('default', () => {
return (
<Button
content={ text("Content", "Button") }
function={ action("clicked default button") }
/>
);
});
Button/stories.js
import * as React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { withKnobs, text } from '@storybook/addon-knobs';
import { Button, BUTTON_TYPES } from './';
const stories = storiesOf('Button', {});
stories.addDecorator(withKnobs);
stories.add('default', () => {
return (
<Button
content={ text("Content", "Button") }
function={ action("clicked default button") }
/>
);
});
Button/stories.js
import * as React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { withKnobs, text } from '@storybook/addon-knobs';
import { Button, BUTTON_TYPES } from './';
const stories = storiesOf('Button', {});
stories.addDecorator(withKnobs);
stories.add('default', () => {
return (
<Button
content={ text("Content", "Button") }
function={ action("clicked default button") }
/>
);
});
Violet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole Team
So many
reasons
Developers
Experiment with element
without having to edit code
Project
managers
test without a developer
find edge cases
confirm behavior
mark as done 0
even more
deeplinking
Knobs options
‣ text
‣ dropdown
‣ color picker
‣ date picker
‣ number range
‣ & more
Speaking of
which
1
🤖
Storyshots
structural testing
connect your stories to Jest
snapshot testing
console
yarn add @storybook/addon-storyshots -D
Project
src
Storyshots.test.js
👻
Taking
snapshots
Jest + Enzyme to render output of stories
recorded output = snapshot
Snapshots.test.js.snap
exports[`Storyshots Button default 1`] = `
<button
className="button"
onClick={[Function]}
type="button"
>
Button
</button>
`;
Button/index.js
export class Button extends React.Component {
render() {
return (
<button
type="button"
className={ this.props.type }
onClick={ this.props.function }
>
All buttons have the same text now
</button>
);
}
}
Button/index.js
export class Button extends React.Component {
render() {
return (
<button
type="button"
className={ this.props.type }
onClick={ this.props.function }
>
All buttons have the same text now
</button>
);
}
}
console
yarn test
console
● Storyshots › Button › default
expect(value).toMatchSnapshot()
Received value does not match stored snapshot 1.
- Snapshot
+ Received
<button
className="button"
onClick={[Function]}
type="button"
>
- Button
+ All buttons have the same text now
</button>
at Object.test (node_modules/@storybook/addon-storyshots/dist/test-bodies.js:27:18)
at Object.<anonymous> (node_modules/@storybook/addon-storyshots/dist/index.js:146:28)
at new Promise (<anonymous>)
at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
console
Storyshots
AddPlantForm
✕ default (6ms)
Body
✕ default (1ms)
Button
✕ default (1ms)
✕ positive (1ms)
✕ danger (1ms)
✕ functional (1ms)
Checkboxes
✓ default (1ms)
DropdownInput
✓ default (1ms)
DynamicList
✕ default (1ms)
Full effects
of your code
Super helpful on
large projects
‣ too many components to keep
track of
‣ too many developers to keep
track of
4
Now you know
‣ writing stories
‣ testing manually &
automatically
How to
publish and
share?
🚀
console
yarn build-storybook
Static
Storybook
‣ full functionality
‣ lighter weight
‣ build with CD tools (CircleCI)
‣ deployable to static server
(internal sandbox, Github
pages)
vgpena.github.io/plantiful
Now you’re
an expert
installation
development
testing
publishing
Storybook is
wonderful
‣ understand our work
‣ write better code
‣ share & collaborate with
other disciplines
✨
Violet Peña
FrontConf 2017
violet.is ✨ vgpena.github.io
Happy coding!
github.com/vgpena/plantiful
vgpena.github.io/plantiful/

More Related Content

PDF
Design for succcess with react and storybook.js
PPTX
React native tour
PDF
Fewd week6 slides
PPTX
What's New in Android
PPTX
PHPUnit with Mocking and Crawling
PDF
Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]
PDF
Everything You (N)ever Wanted to Know about Testing View Controllers
PDF
Rails 3: Dashing to the Finish
Design for succcess with react and storybook.js
React native tour
Fewd week6 slides
What's New in Android
PHPUnit with Mocking and Crawling
Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]
Everything You (N)ever Wanted to Know about Testing View Controllers
Rails 3: Dashing to the Finish

What's hot (20)

PPT
Beginning iphone 4_devlopement_chpter7_tab_b
PDF
Technology and Science News - ABC News
PDF
Avinash Kundaliya: Javascript and WordPress
PDF
KISS Automation.py
PDF
Technology and Science News - ABC News
PDF
You do not need automation engineer - Sqa Days - 2015 - EN
PDF
Technology and Science News - ABC News
KEY
SproutCore is Awesome - HTML5 Summer DevFest
PDF
What's new in iOS9
PDF
Android L02 - Activities and Adapters
PDF
Polyglot automation - QA Fest - 2015
PDF
Web ui tests examples with selenide, nselene, selene & capybara
PDF
How to build an AngularJS backend-ready app WITHOUT BACKEND
ODP
Android training day 5
PDF
Make XCUITest Great Again
PDF
Health News & Articles | Healthy Living
PPT
PPTX
iOS Automation: XCUITest + Gherkin
PDF
Controller Testing: You're Doing It Wrong
KEY
TwitterKitではじめる OAuthスピードクッキング
Beginning iphone 4_devlopement_chpter7_tab_b
Technology and Science News - ABC News
Avinash Kundaliya: Javascript and WordPress
KISS Automation.py
Technology and Science News - ABC News
You do not need automation engineer - Sqa Days - 2015 - EN
Technology and Science News - ABC News
SproutCore is Awesome - HTML5 Summer DevFest
What's new in iOS9
Android L02 - Activities and Adapters
Polyglot automation - QA Fest - 2015
Web ui tests examples with selenide, nselene, selene & capybara
How to build an AngularJS backend-ready app WITHOUT BACKEND
Android training day 5
Make XCUITest Great Again
Health News & Articles | Healthy Living
iOS Automation: XCUITest + Gherkin
Controller Testing: You're Doing It Wrong
TwitterKitではじめる OAuthスピードクッキング
Ad

Similar to Violet Peña - Storybook: A React Tool For Your Whole Team (20)

PPTX
Test driven development with react
PDF
React storybook
PDF
Workshop 23: ReactJS, React & Redux testing
PDF
2018 05-16 Evolving Technologies: React, Babel & Webpack
PDF
Intro to react_v2
PDF
Using React, Redux and Saga with Lottoland APIs
PPTX
React & Redux for noobs
PDF
React new features and intro to Hooks
PPTX
React JS Lecture 10.pptx Our clg lecture
PDF
Workshop React.js
PPTX
React advance
PDF
react-hooks.pdf
PDF
Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...
PDF
Introduction to React for Frontend Developers
PDF
The virtual DOM and how react uses it internally
PDF
Radoslav Stankov - React Refactoring Patterns
PPTX
React mini lecture
PPTX
ReactJS.pptx
PDF
Linux conf-2018-fp-miniconf-slideshare
PDF
Master React in 20 Days !.pdf used for react
Test driven development with react
React storybook
Workshop 23: ReactJS, React & Redux testing
2018 05-16 Evolving Technologies: React, Babel & Webpack
Intro to react_v2
Using React, Redux and Saga with Lottoland APIs
React & Redux for noobs
React new features and intro to Hooks
React JS Lecture 10.pptx Our clg lecture
Workshop React.js
React advance
react-hooks.pdf
Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...
Introduction to React for Frontend Developers
The virtual DOM and how react uses it internally
Radoslav Stankov - React Refactoring Patterns
React mini lecture
ReactJS.pptx
Linux conf-2018-fp-miniconf-slideshare
Master React in 20 Days !.pdf used for react
Ad

Recently uploaded (20)

PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
PPTX
Patient Appointment Booking in Odoo with online payment
PDF
Types of Token_ From Utility to Security.pdf
PPTX
Custom Software Development Services.pptx.pptx
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
chapter 5 systemdesign2008.pptx for cimputer science students
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
iTop VPN Crack Latest Version Full Key 2025
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PPTX
"Secure File Sharing Solutions on AWS".pptx
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PPTX
Trending Python Topics for Data Visualization in 2025
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
PDF
Salesforce Agentforce AI Implementation.pdf
PDF
Digital Systems & Binary Numbers (comprehensive )
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PPTX
Cybersecurity: Protecting the Digital World
PDF
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
Weekly report ppt - harsh dattuprasad patel.pptx
Patient Appointment Booking in Odoo with online payment
Types of Token_ From Utility to Security.pdf
Custom Software Development Services.pptx.pptx
Computer Software and OS of computer science of grade 11.pptx
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
wealthsignaloriginal-com-DS-text-... (1).pdf
chapter 5 systemdesign2008.pptx for cimputer science students
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
iTop VPN Crack Latest Version Full Key 2025
Why Generative AI is the Future of Content, Code & Creativity?
"Secure File Sharing Solutions on AWS".pptx
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
Trending Python Topics for Data Visualization in 2025
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
Salesforce Agentforce AI Implementation.pdf
Digital Systems & Binary Numbers (comprehensive )
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
Cybersecurity: Protecting the Digital World
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025

Violet Peña - Storybook: A React Tool For Your Whole Team