-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogress.html
More file actions
265 lines (242 loc) · 8.26 KB
/
progress.html
File metadata and controls
265 lines (242 loc) · 8.26 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<!DOCTYPE html>
<html lang="en">
<head>
<title>Progress</title>
<style type="text/css">
/*Progress Indicator Styles*/
.wrapper {
width: 100%;
}
.steps {
list-style:none; /*Removes the bullets*/
align-items: flex-start; /* Align to the top of the line */
display: flex; /*Creates the positioning rule for a flexbox*/
flex-direction: row; /*Positions the list items in a row*/
padding: 0;
}
.step-container {
display: flex;
flex-direction: column; /* Stacks circle and text */
align-items: center; /* Centers them horizontally */
width: 100px; /* Give it enough room for text */
}
.step-circle {
height: 40px;
width: 40px;
background-color: #3C66FA;
color: #FFF;
border-radius: 50%;
text-align: center;
line-height: 40px;
flex-shrink: 0;
}
.step-label {
margin-top: 8px;
font-size: 14px;
text-align: center;
color: #333;
}
.separator {
margin-top: 20px; /* Half the height of the circle to center the line */
border-top: 2px solid #3C66FA;
flex-grow: 1;
}
.active {
background-color: #FFF;
border: 1px solid;
border-color: #3C66FA;
color: #3C66FA;
}
.unvisited {
background-color: #E8E8E8;
border: 1px solid;
border-color: #3C66FA;
color: #000;
}
/*Progress Bar Styles*/
progress {
border-radius: 7px;
width: 200px;
height: 20px;
box-shadow: 1px 1px 4px rgba( 0, 0, 0, 0.2 );
}
progress::-webkit-progress-bar {
background-color: #E6E6E6; /*The background color of the non-active section*/
border: 1px solid; /*For increased contrast*/
border-radius: 7px; /*Curve those corners*/
}
progress::-webkit-progress-value {
background-color: #1DBA1A; /*Sets the color of the progress section*/
border-radius: 7px; /*More curved corners*/
box-shadow: 1px 0px 3px 1px #1DBA1A; /* Sets the shadow/hue around the progress bar */
}
progress::-moz-progress-bar {
/* style rules */
}
.progress-wrapper {
display: flex;
align-items: center; /* Vertically centers the items */
gap: 10px; /* Adds space between the label, bar, and text */
}
.percentage {
font-weight: bold;
color: #333;
}
footer {
margin-top: 50px;
}
pre {
width: 50%;
}
</style>
</head>
<body>
<h1 style="text-align: center;">Progress Components</h1>
<h2>Progress Indicator</h2>
<p>Makes use of the <code>aria-current="step"</code> state (<a href="https://www.w3.org/TR/wai-aria-1.2/#aria-current">Docs</a>) to programmatically indicate the current step instead of relying on color/styling.</p>
<div class="wrapper">
<ul class="steps">
<li class="step-container">
<div class="step-circle">1</div>
<p class="step-label">Completed step</p>
</li>
<span class="separator"></span>
<li class="step-container" aria-current="step">
<div class="step-circle active">2</div>
<p class="step-label">Active Step</p>
</li>
<span class="separator"></span>
<li class="step-container">
<div class="step-circle unvisited">3</div>
<p class="step-label">Unvisited Step</p>
</li>
</ul>
</div>
<p>The CSS:</p>
<pre class="prettyprint">
/*Progress Indicator Styles*/
.wrapper {
width: 100%; /* Sets the width of the component */
}
.steps {
list-style:none; /*Removes the bullets*/
align-items: flex-start; /* Aligns to the top of the line */
display: flex; /*Creates the positioning rule for a flexbox*/
flex-direction: row; /*Positions the list items in a row*/
padding: 0;
}
.step-container {
display: flex; /* Allows for flex positioning of the number and label text */
flex-direction: column; /* Stacks circle and text */
align-items: center; /* Centers them horizontally */
width: 100px; /* Give it enough room for text */
}
.step-circle { /* Draws the circles around the step number*/
height: 40px;
width: 40px;
background-color: #3C66FA;
color: #FFF;
border-radius: 50%;
text-align: center;
line-height: 40px;
flex-shrink: 0; /* Keeps the circles from squishing into ovals when resizing */
}
.step-label { /* The label text beneath the step count */
margin-top: 8px;
font-size: 14px;
text-align: center;
color: #333;
}
.separator { /* The lines between the steps */
margin-top: 20px; /* Half the height of the circle to center the line */
border-top: 2px solid #3C66FA;
flex-grow: 1;
}
.active { /* Stling for the active step number */
background-color: #FFF;
border: 1px solid;
border-color: #3C66FA;
color: #3C66FA;
}
.unvisited { /* Styling for the unvisited step circles */
background-color: #E8E8E8;
border: 1px solid;
border-color: #3C66FA;
color: #000;
}
</pre>
<p>The HTML:</p>
<pre class="prettyprint">
<div class="wrapper">
<ul class="steps">
<li class="step-container">
<div class="step-circle">1</div>
<p class="step-label">Completed step</p>
</li>
<span class="separator"></span>
<li class="step-container" aria-current="step">
<div class="step-circle active">2</div>
<p class="step-label">Active Step</p>
</li>
<span class="separator"></span>
<li class="step-container">
<div class="step-circle unvisited">3</div>
<p class="step-label">Unvisited Step</p>
</li>
</ul>
</div>
</pre>
<h2>Progress Bar</h2>
<p>Styles the HTML5 <code><progress></code> element.</p>
<div class="progress-wrapper">
<label for="progressBar">File progress:</label>
<progress id="progressBar" max="100" value="70"></progress>
<span class="percentage">70%</span>
</div>
<p><strong>Note:</strong> the JAWS screen reader announces the progress bar role and the "70" as the value. The <span> with the percentage is not necessary for screen reader users but I added it for cognitive benefits. There are users who may not easily identify the percentage represented as changing colors so a textual representation is always good.</p>
<p>The CSS:</p>
<pre class="prettyprint">
/*Progress Bar Styles*/
progress {
border-radius: 7px;
width: 200px;
height: 20px;
box-shadow: 1px 1px 4px rgba( 0, 0, 0, 0.2 );
}
progress::-webkit-progress-bar {
background-color: #E6E6E6; /*The background color of the non-active section*/
border: 1px solid; /*For increased contrast*/
border-radius: 7px; /*Curve those corners*/
}
progress::-webkit-progress-value {
background-color: #1DBA1A; /*Sets the color of the progress section*/
border-radius: 7px; /*More curved corners*/
box-shadow: 1px 0px 3px 1px #1DBA1A; /* Sets the shadow/hue around the progress bar */
}
progress::-moz-progress-bar {
/* style rules */
}
.progress-wrapper {
display: flex;
align-items: center; /* Vertically centers the items */
gap: 10px; /* Adds space between the label, bar, and text */
}
.percentage {
font-weight: bold;
color: #333;
}
</pre>
<p>The HTML:</p>
<pre class="prettyprint">
<div class="progress-wrapper">
<label for="progressBar">File progress:</label>
<progress id="progressBar" max="100" value="70"></progress>
<span class="percentage">70%</span>
</div>
</pre>
<footer>
<a href="http://robertjmccaffery.com/examples.html">Back to Examples</a> | <a href="http://robertjmccaffery.com/">Home</a>
</footer>
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js?skin=sunburst"></script>
</body>
</html>