-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathprogress-bar-elements.stories.js
More file actions
174 lines (162 loc) · 3.78 KB
/
Copy pathprogress-bar-elements.stories.js
File metadata and controls
174 lines (162 loc) · 3.78 KB
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import React from 'react';
import { ProgressBar } from '../lib/react-progress-bar';
export default {
title: 'Components/Progress Bar/Elements',
component: ProgressBar,
parameters: {
actions: {
disable: true,
},
controls: {
disable: true,
},
previewTabs: {
'storybook/docs/panel': {
hidden: true,
},
},
},
decorators: [
(Story) => (
<div className="sui-box">
<div className="sui-box-body">
<Story />
</div>
</div>
),
],
};
const Title = ({ children }) => {
const customStyles = {
margin: 0,
marginBottom: 10 + 'px',
color: '#333',
fontSize: 14 + 'px',
lineHeight: 22 + 'px',
};
return <h3 style={customStyles}>{children}</h3>;
};
const Description = ({ children }) => {
const customStyles = {
margin: 0,
marginBottom: 10 + 'px',
};
return (
<p className="sui-description" style={customStyles}>
{children}
</p>
);
};
const Code = ({ spaceTop = 5, spaceBottom = 20, children }) => {
const customStyles = {
display: 'block',
margin: 0,
marginTop: spaceTop + 'px',
marginBottom: spaceBottom + 'px',
padding: 5 + 'px ' + 10 + 'px',
};
return <code style={customStyles}>{children}</code>;
};
const Section = ({
title,
description,
code,
code2,
isDefault = false,
isLast = false,
children,
}) => {
return (
<>
{title && '' !== title && (
<Title>
{title}
{isDefault && (
<span
className="sui-tag sui-tag-sm sui-tag-yellow"
style={{ marginLeft: 10 + 'px' }}
aria-hidden="true"
>
Default
</span>
)}
</Title>
)}
{description && '' !== description && <Description>{description}</Description>}
{code && '' !== code && (
<Code {...(code2 && '' !== code2 && { spaceBottom: 5 })}>{code}</Code>
)}
{code2 && '' !== code2 && <Code>{code2}</Code>}
{children}
{!isLast && <hr />}
</>
);
};
export const Loader = () => {
return (
<Section
title="Loading Wheel"
description={
<>
By default, the component shows the loading wheel but you can hide it by setting <code style={{ fontSize: 11 }}>hasLoader</code> property to <code style={{ fontSize: 11 }}>false</code>.
</>
}
isLast={true}
>
<ProgressBar now={30} hasCancel={false} hasLabel={false} />
</Section>
);
};
export const Percent = () => {
return (
<Section
title="Percentage Text"
description={
<>
By default, the component shows the progress value or percentage, but you can hide it by setting <code style={{ fontSize: 11 }}>hasLabel</code> property to <code style={{ fontSize: 11 }}>false</code>.
</>
}
isLast={true}
>
<ProgressBar hasLoader={false} hasCancel={false} now={30} />
</Section>
);
};
export const Cancel = () => {
return (
<Section
title="Cancel Button"
description={
<>
By default, the component shows the cancel button, but you can hide it by setting <code style={{ fontSize: 11 }}>hasCancel</code> property to <code style={{ fontSize: 11 }}>false</code>. You can also pass a function when clicking on it by using the <code style={{ fontSize: 11 }}>cbFunction</code> property.
</>
}
isLast={true}
>
<ProgressBar now={30} hasLoader={false} hasLabel={false} />
</Section>
);
};
export const Legend = () => {
return (
<>
<Section
title="Legend Text"
description={
<>
This text appears below the progress bar and only when <code style={{ fontSize: 11 }}>hasFrame</code> and <code style={{ fontSize: 11 }}>hasLegend</code> properties are set to <code style={{ fontSize: 11 }}>true</code>. You can edit the text using <code style={{ fontSize: 11 }}>sourceLang</code> property.
</>
}
isLast={true}
>
<ProgressBar
hasLoader={false}
hasCancel={false}
now={30}
hasLabel={false}
hasFrame={true}
/>
</Section>
</>
);
};