Skip to content

Commit d58ca1c

Browse files
committedSep 1, 2021
feat(stream): convert stories to new format
1 parent ace1a66 commit d58ca1c

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed
 

‎packages/stream/stories/stream.stories.js ‎packages/stream/stories/stream.stories.tsx

+22-18
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
import range from 'lodash/range'
22
import random from 'lodash/random'
3-
import { storiesOf } from '@storybook/react'
3+
import { Meta } from '@storybook/react'
44
import { withKnobs, select } from '@storybook/addon-knobs'
5+
// @ts-ignore
56
import { areaCurvePropKeys } from '@nivo/core'
7+
// @ts-ignore
68
import { Stream } from '../src'
79

10+
export default {
11+
component: Stream,
12+
title: 'Stream',
13+
decorators: [withKnobs],
14+
} as Meta
15+
816
const keys = ['Raoul', 'Josiane', 'Marcel', 'René', 'Paul', 'Jacques']
917

1018
const commonProperties = {
@@ -16,35 +24,31 @@ const commonProperties = {
1624
keys.reduce((layer, key) => {
1725
layer[key] = random(10, 200)
1826
return layer
19-
}, {})
27+
}, {} as any)
2028
),
2129
animate: true,
2230
}
2331

24-
const stories = storiesOf('Stream', module)
25-
26-
stories.addDecorator(withKnobs)
27-
28-
stories.add('default', () => <Stream {...commonProperties} />)
32+
export const Default = () => <Stream {...commonProperties} />
2933

3034
const labelLookup = {
3135
al: 'Alabama',
3236
az: 'Arizona',
3337
nv: 'Nevada',
3438
}
3539

36-
stories.add('custom label', () => (
40+
export const CustomLabel = () => (
3741
<Stream
3842
{...commonProperties}
3943
data={range(16).map(() =>
4044
Object.keys(labelLookup).reduce((layer, key) => {
4145
layer[key] = random(10, 200)
4246
return layer
43-
}, {})
47+
}, {} as any)
4448
)}
4549
keys={Object.keys(labelLookup)}
4650
margin={{ top: 50, right: 110, bottom: 50, left: 60 }}
47-
label={d => labelLookup[d.id]}
51+
label={d => labelLookup[d.id as keyof typeof labelLookup]}
4852
legends={[
4953
{
5054
anchor: 'bottom-right',
@@ -66,28 +70,28 @@ stories.add('custom label', () => (
6670
},
6771
]}
6872
/>
69-
))
73+
)
7074

71-
stories.add('full height (expand offset)', () => (
75+
export const fullHeight = () => (
7276
<Stream
7377
{...commonProperties}
7478
offsetType="expand"
7579
curve={select('curve', areaCurvePropKeys, 'catmullRom')}
7680
/>
77-
))
81+
)
7882

79-
stories.add('regular stacked chart', () => (
83+
export const regularStackedChart = () => (
8084
<Stream
8185
{...commonProperties}
8286
offsetType="none"
8387
axisLeft={{}}
8488
curve={select('curve', areaCurvePropKeys, 'catmullRom')}
8589
/>
86-
))
90+
)
8791

88-
stories.add('custom curve', () => <Stream {...commonProperties} curve="step" />)
92+
export const CustomCurve = () => <Stream {...commonProperties} curve="step" />
8993

90-
stories.add('formatting values', () => (
94+
export const formattingValues = () => (
9195
<Stream
9296
{...commonProperties}
9397
valueFormat={value =>
@@ -96,4 +100,4 @@ stories.add('formatting values', () => (
96100
})} ₽`
97101
}
98102
/>
99-
))
103+
)

0 commit comments

Comments
 (0)
Please sign in to comment.