Skip to content

Commit 6afed41

Browse files
committed
Add more usage examples.
1 parent 95e1b74 commit 6afed41

1 file changed

Lines changed: 88 additions & 32 deletions

File tree

stories/index.js

Lines changed: 88 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
11
import React from 'react';
22
import { storiesOf, setAddon } from '@storybook/react';
3-
import backgrounds from '@storybook/addon-backgrounds';
43
import JSXAddon from 'storybook-addon-jsx';
54
import { RadialProgress } from '../src';
65

76
setAddon(JSXAddon);
87

9-
const myBackgrounds = backgrounds([
10-
{ name: 'white', value: '#fff', default: true },
11-
{ name: 'blue', value: '#ccf' },
12-
{ name: 'black', value: '#000' },
13-
]);
14-
158
const stories = storiesOf('RadialProgress', module);
169

17-
stories.addDecorator(myBackgrounds);
18-
1910
stories.addDecorator(story => (
2011
<div style={{ textAlign: 'center', fontFamily: 'Helvetica, sans-serif' }}>
2112
{story()}
@@ -54,20 +45,6 @@ stories
5445
ringThickness={0.3}
5546
/>
5647
))
57-
.addWithJSX('To 3/10, with colours', () => (
58-
<RadialProgress
59-
step={3}
60-
steps={10}
61-
width={200}
62-
height={200}
63-
ringBgColour="#EDCA8A"
64-
ringFgColour="#674509"
65-
ringIntermediateColour="#AA8239"
66-
backgroundColour="#FFE0A9"
67-
backgroundTransparent={false}
68-
showIntermediateProgress={true}
69-
/>
70-
))
7148
.addWithJSX('From 3/10 to 5/10', () => (
7249
<RadialProgress
7350
startStep={3}
@@ -88,15 +65,43 @@ stories
8865
showIntermediateProgress={true}
8966
/>
9067
))
91-
.addWithJSX('100 steps, no segment gaps', () => (
92-
<RadialProgress
93-
steps={100}
94-
step={100}
95-
width={200}
96-
height={200}
97-
segmented={false}
98-
/>
99-
))
68+
.addWithJSX('Step or sweep', () => {
69+
const steps = 20;
70+
const float = jsx => <div style={{ float: 'left', margin: 10 }}>{jsx}</div>;
71+
return (
72+
<div>
73+
{float(
74+
<RadialProgress
75+
steps={steps}
76+
step={steps}
77+
width={200}
78+
height={200}
79+
text={(steps, percentage) => Math.floor(steps * percentage)}
80+
duration={10000}
81+
ringFgColour="#666666"
82+
ringIntermediateColour="#666666"
83+
segmented={true}
84+
/>
85+
)}
86+
{float(
87+
<RadialProgress
88+
steps={steps}
89+
step={steps}
90+
width={200}
91+
height={200}
92+
segmented={false}
93+
text={(steps, percentage) =>
94+
(Math.floor(steps * percentage * 10) / 10).toFixed(1)
95+
}
96+
duration={10000}
97+
ringFgColour="#666666"
98+
ringIntermediateColour="#666666"
99+
showIntermediateProgress={true}
100+
/>
101+
)}
102+
</div>
103+
);
104+
})
100105
.addWithJSX('5 steps, fast duration', () => (
101106
<RadialProgress
102107
steps={5}
@@ -192,4 +197,55 @@ stories
192197
</div>
193198
</div>
194199
);
200+
})
201+
.addWithJSX('Colours', () => {
202+
const colours = [
203+
{
204+
ringBgColour: '#EDCA8A',
205+
ringFgColour: '#674509',
206+
ringIntermediateColour: '#AA8239',
207+
backgroundColour: '#FFE0A9',
208+
pageBackgroundColour: '#FFE0A9',
209+
},
210+
{
211+
ringBgColour: '#ffffff',
212+
ringFgColour: '#639A88',
213+
ringIntermediateColour: '#91CC7A',
214+
backgroundColour: '#eeeeee',
215+
pageBackgroundColour: '#eeeeee',
216+
},
217+
{
218+
ringBgColour: '#7C90A0',
219+
ringFgColour: '#B5AA9D',
220+
ringIntermediateColour: '#B9B7A7',
221+
backgroundColour: '#747274',
222+
pageBackgroundColour: '#747274',
223+
},
224+
];
225+
return colours.map(options => (
226+
<div
227+
style={{
228+
float: 'left',
229+
width: 100,
230+
height: 100,
231+
padding: 15,
232+
margin: 5,
233+
backgroundColor: options.pageBackgroundColour,
234+
}}
235+
>
236+
<RadialProgress
237+
step={10}
238+
steps={10}
239+
width="100%"
240+
height="100%"
241+
ringBgColour={options.ringBgColour}
242+
ringFgColour={options.ringFgColour}
243+
ringIntermediateColour={options.ringIntermediateColour}
244+
backgroundColour={options.backgroundColour}
245+
backgroundTransparent={false}
246+
showIntermediateProgress={true}
247+
segmented={false}
248+
/>
249+
</div>
250+
));
195251
});

0 commit comments

Comments
 (0)