Skip to content

Commit

Permalink
feat(storybook): add ability to publish storybook to gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphaël Benitte committed Aug 9, 2017
1 parent e056aa0 commit b5bfda2
Show file tree
Hide file tree
Showing 11 changed files with 313 additions and 57 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ node_modules
/lib
/es
/coverage
/storybook-static
2 changes: 1 addition & 1 deletion .storybook/addons.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */

import '@storybook/addon-actions/register'
import '@storybook/addon-links/register'
import '@storybook/addon-knobs/register'
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"recompose": "^0.24.0"
},
"devDependencies": {
"@storybook/addon-knobs": "^3.2.0",
"@storybook/react": "^3.2.3",
"babel-cli": "^6.24.1",
"babel-jest": "^20.0.3",
Expand All @@ -57,7 +58,9 @@
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-plugin-transform-react-jsx": "^6.24.1",
"cross-env": "^5.0.2",
"gh-pages": "^1.0.0",
"husky": "^0.14.3",
"import": "^0.0.6",
"jest": "^20.0.4",
"lint-staged": "^4.0.2",
"mocha": "^3.5.0",
Expand Down Expand Up @@ -90,7 +93,8 @@
"precommit": "lint-staged",
"commitmsg": "validate-commit-msg",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
"storybook:build": "build-storybook",
"storybook:publish": "npm run storybook:build && gh-pages -d storybook-static -r [email protected]:plouc/nivo.git -b gh-pages -e storybook"
},
"lint-staged": {
"*.js": [
Expand Down
4 changes: 2 additions & 2 deletions src/components/charts/line/Line.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export const LineDefaultProps = {
// axes & grid
axisBottom: {},
axisLeft: {},
enableGridX: false,
enableGridX: true,
enableGridY: true,

// markers
Expand All @@ -237,7 +237,7 @@ export const LineDefaultProps = {

// theming
theme: {},
colors: Nivo.defaults.colorRange,
colors: 'nivo',
colorBy: 'id',

// motion
Expand Down
3 changes: 2 additions & 1 deletion src/components/charts/radar/RadarGridLevels.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const RadarGridLevels = ({
if (animate !== true) {
return (
<g>
{range(radii).map((radius, i) =>
{radii.map((radius, i) =>
<path
key={`level.${i}`}
fill="none"
Expand All @@ -86,6 +86,7 @@ const RadarGridLevels = ({
</g>
)
}

return (
<TransitionMotion {...levelsTransitionProps}>
{interpolatedStyles =>
Expand Down
16 changes: 4 additions & 12 deletions stories/charts/bar.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react'

import { storiesOf } from '@storybook/react'
import { generateDrinkStats } from 'nivo-generators'
import '../style.css'
import { Bar } from '../../src'

const commonProperties = {
Expand All @@ -14,20 +15,11 @@ const commonProperties = {

storiesOf('Bar', module)
.addDecorator(story =>
<div
style={{
position: 'absolute',
width: '100%',
height: '100%',
top: 0,
left: 0,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<div className="wrapper">
{story()}
</div>
)
.add('stacked', () => <Bar {...commonProperties} />)
.add('grouped', () => <Bar {...commonProperties} groupMode="grouped" />)
.add('using data serie color', () => <Bar {...commonProperties} colorBy={d => d.serie.color} />)
.add('using data datum color', () => <Bar {...commonProperties} colorBy={d => d.color} />)
77 changes: 77 additions & 0 deletions stories/charts/line.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import React from 'react'
import { storiesOf } from '@storybook/react'
import { withKnobs, boolean, select } from '@storybook/addon-knobs'
import { generateDrinkStats } from 'nivo-generators'
import '../style.css'
import { Line } from '../../src'

const commonProperties = {
width: 900,
height: 360,
margin: { top: 60, right: 80, bottom: 60, left: 80 },
data: generateDrinkStats(18),
animate: true,
}

const curveOptions = ['linear', 'monotoneX']

const stories = storiesOf('Line', module)

stories
.addDecorator(story =>
<div className="wrapper">
{story()}
</div>
)
.addDecorator(withKnobs)

stories.add('default', () =>
<Line {...commonProperties} curve={select('curve', curveOptions, 'linear')} />
)

stories.add('stacked', () =>
<Line {...commonProperties} stacked={true} curve={select('curve', curveOptions, 'linear')} />
)

stories.add('with custom curve', () =>
<Line {...commonProperties} stacked={true} curve="monotoneX" />
)

stories.add('with markers label', () =>
<Line
{...commonProperties}
stacked={boolean('stacked', true)}
curve={select('curve', curveOptions, 'linear')}
enableMarkersLabel={true}
markersSize={10}
markersBorderColor="#fff"
markersBorderWidth={2}
/>
)

stories.add('abusing markers label', () =>
<Line
{...commonProperties}
stacked={boolean('stacked', true)}
curve={select('curve', curveOptions, 'monotoneX')}
enableMarkersLabel={true}
markersSize={26}
markersLabelYOffset={3}
axisLeft={{
tickSize: 10,
}}
/>
)

stories.add('using data colors', () =>
<Line
{...commonProperties}
stacked={boolean('stacked', true)}
curve={select('curve', curveOptions, 'linear')}
colorBy={d => d.color}
enableMarkersLabel={true}
markersSize={10}
markersBorderColor="#fff"
markersBorderWidth={2}
/>
)
66 changes: 49 additions & 17 deletions stories/charts/radar.stories.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,70 @@
import React from 'react'

import { storiesOf } from '@storybook/react'
import { withKnobs, select } from '@storybook/addon-knobs'
import { generateSerie, randColor } from 'nivo-generators'
import '../style.css'
import { Radar } from '../../src'

const commonProperties = {
width: 600,
height: 600,
margin: { top: 60, right: 60, bottom: 60, left: 60 },
margin: { top: 80, right: 80, bottom: 80, left: 80 },
facets: ['fruity', 'bitter', 'heavy', 'strong', 'sunny'],
//colors: 'nivo',
data: ['chardonay', 'carmenere', 'syrah'].map(id => ({
id,
color: randColor(),
data: generateSerie(5),
})),
animate: true,
}

storiesOf('Radar', module)
const curveOptions = ['linearClosed', 'basisClosed', 'catmullRomClosed', 'cardinalClosed']

const stories = storiesOf('Radar', module)

stories
.addDecorator(story =>
<div
style={{
position: 'absolute',
width: '100%',
height: '100%',
top: 0,
left: 0,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<div className="wrapper">
{story()}
</div>
)
.add('default', () => <Radar {...commonProperties} />)
.add('linear grid shape', () => <Radar {...commonProperties} gridShape="linear" />)
.addDecorator(withKnobs)

stories.add('default', () => <Radar {...commonProperties} />)

stories.add('with custom curve', () =>
<Radar {...commonProperties} gridShape="linear" curve="catmullRomClosed" />
)

stories.add('linear grid shape', () =>
<Radar
{...commonProperties}
gridShape="linear"
curve={select('curve', curveOptions, 'linearClosed')}
/>
)

stories.add('with markers label', () =>
<Radar
{...commonProperties}
curve={select('curve', curveOptions, 'linearClosed')}
gridShape="linear"
markersSize={10}
markersBorderColor="#fff"
markersBorderWidth={2}
enableMarkersLabel={true}
gridLabelOffset={36}
/>
)

stories.add('abusing markers label', () =>
<Radar
{...commonProperties}
curve={select('curve', curveOptions, 'catmullRomClosed')}
markersSize={32}
markersLabelYOffset={3}
enableMarkersLabel={true}
gridLabelOffset={36}
/>
)
13 changes: 0 additions & 13 deletions stories/index.js

This file was deleted.

14 changes: 14 additions & 0 deletions stories/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
svg text {
font-family: 'Consolas', monospace;
}

.wrapper {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
display: flex;
align-items: center;
justify-content: center;
}
Loading

0 comments on commit b5bfda2

Please sign in to comment.