-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathActivityRings.stories.tsx
154 lines (143 loc) · 4.52 KB
/
ActivityRings.stories.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import React from 'react';
import {ActivityRings} from '../index';
import type {Meta, StoryObj} from '@storybook/react';
import type {ActivityRing} from '../types';
const meta: Meta<typeof ActivityRings> = {
title: 'Example/ActivityRings',
component: ActivityRings,
};
export default meta;
type Story = StoryObj<typeof ActivityRings>;
const Template: Story = {
render: (args) => <ActivityRings rings={args.rings} options={args.options} />,
};
export const SimpleThreeRings: Story = {
...Template,
args: {
rings: [
{filledPercentage: 0.5, color: '#fa0e5a'},
{filledPercentage: 0.75, color: '#afff02'},
{filledPercentage: 0.25, color: '#00fff8'},
],
options: {
containerHeight: '75vh',
},
},
};
export const SimpleTwoRings: Story = {
...Template,
args: {
rings: [
{filledPercentage: 0.5, color: '#fa0e5a'},
{filledPercentage: 0.75, color: '#afff02'},
],
options: {
containerHeight: '75vh',
backgroundOpacity: 0.3,
},
},
};
export const SimpleALotOfRings: Story = {
...Template,
args: {
rings: [
{filledPercentage: 0.5, color: '#fa0e5a'},
{filledPercentage: 0.75, color: '#afff02'},
{filledPercentage: 0.25, color: '#00fff8'},
{filledPercentage: 0.1, color: '#b91c1c'},
{filledPercentage: 1, color: '#00FF00'},
{filledPercentage: 0.5, color: '#0284c7'},
{filledPercentage: 0.25, color: '#f123ff'},
{filledPercentage: 0.1, color: '#FF0000'},
{filledPercentage: 0.75, color: '#0000FF'},
],
options: {
containerHeight: '75vh',
},
},
};
export const CustomizedThreeRings: Story = {
args: {
rings: [
{filledPercentage: 0.5, color: '#fa0e5a'},
{filledPercentage: 0.75, color: '#afff02'},
{filledPercentage: 0.25, color: '#00fff8'},
],
options: {
containerHeight: '75vh',
animationTimingFunction: 'cubic-bezier(.47,1.64,.36,-0.19)',
animationDurationMillis: 2000,
backgroundOpacity: 0.2,
},
},
};
export const CustomBackgroundColor: Story = {
parameters: {
backgrounds: {
default: 'Gray',
},
},
args: {
rings: [
{filledPercentage: 0.5, color: '#dd0e39', backgroundColor: '#f3f3f4'},
{filledPercentage: 0.75, color: '#03897c', backgroundColor: '#f3f3f4'},
{filledPercentage: 0.25, color: '#0586aa', backgroundColor: '#f3f3f4'},
],
options: {
containerHeight: '75vh',
backgroundOpacity: 1,
},
},
};
export const CustomRingWidth: Story = {
...Template,
args: {
rings: [
{filledPercentage: 0.5, color: '#fa0e5a', ringWidth: 3},
{filledPercentage: 0.75, color: '#afff02', ringWidth: 12},
{filledPercentage: 0.25, color: '#00fff8', ringWidth: 3},
],
options: {
containerHeight: '75vh',
},
},
};
export const Gallery = () => {
return (
<>
<ActivityRings rings={[
{filledPercentage: 0.5, color: '#fa0e5a'},
{filledPercentage: 0.75, color: '#afff02'},
{filledPercentage: 0.25, color: '#00fff8'},
]} options={{containerWidth: '10vw'}} />
<ActivityRings rings={[
{filledPercentage: 0.6, color: '#F1337F'},
{filledPercentage: 0.65, color: '#00FFF8'},
]} options={{containerWidth: '10vw'}} />
<ActivityRings rings={[
{filledPercentage: 0.15, color: '#00FF00'},
{filledPercentage: 0.66, color: '#0284c7'},
{filledPercentage: 1, color: '#f123ff'},
{filledPercentage: 0.25, color: '#FF0000'},
]} options={{containerWidth: '10vw'}} />
<ActivityRings rings={[
{filledPercentage: 0.6, color: '#F00'},
{filledPercentage: 0.65, color: '#0F0'},
{filledPercentage: 0.7, color: '#00F'},
]} options={{containerWidth: '10vw'}} />
</>
);
};
export const RandomGallery = () => {
const generateRingData = (amount: number) => {
return Array<ActivityRing>(amount).fill({filledPercentage: 0, color: ''}).map(() => ({filledPercentage: Math.min(Math.random()+0.1, 1), color: `rgb(${Math.random()*254}, ${Math.random()*254}, ${Math.random()*254})`}));
};
return (
<>
<ActivityRings rings={generateRingData(Math.ceil(Math.random()*4+2))} options={{containerWidth: '10vw'}} />
<ActivityRings rings={generateRingData(Math.ceil(Math.random()*4+2))} options={{containerWidth: '10vw'}} />
<ActivityRings rings={generateRingData(Math.ceil(Math.random()*4+2))} options={{containerWidth: '10vw'}} />
<ActivityRings rings={generateRingData(Math.ceil(Math.random()*4+2))} options={{containerWidth: '10vw'}} />
</>
);
};