@stackoverflow/stacks 1.5.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,330 +1,269 @@
1
- //
2
- // STACK OVERFLOW
3
- // PROGRESS BARS
4
- //
5
- // This CSS comes from Stacks, our CSS & Pattern library for rapidly building
6
- // Stack Overflow. For documentation of all these classes and how to contribute,
7
- // visit https://stackoverflow.design/
8
- //
9
- // TABLE OF CONTENTS
10
- // • BASE STYLE
11
- // • VARIATION PROGRESS BACKGROUNDS
12
- // • BADGES
13
- // • STEPPED
14
-
15
- // ============================================================================
16
- // $ BASE STYLE
17
- // ----------------------------------------------------------------------------
18
- .s-progress,
19
- .s-progress--bar {
20
- position: relative;
21
- min-height: var(--su-static4);
22
- min-width: var(--su-static6);
23
- border-radius: var(--br-sm);
24
- }
25
-
26
- // $$ PROGRESS WRAPPER
27
- // ----------------------------------------------------------------------------
28
1
  .s-progress {
29
- width: 100%;
30
- background-color: var(--black-200);
31
- }
32
-
33
- // $$ BAR
34
- // ----------------------------------------------------------------------------
35
- .s-progress--bar {
36
- height: 100%;
37
- background-color: var(--green-400);
38
- }
39
-
40
- // $$ LABEL
41
- // For when there's descriptive, label copy within the progress bar
42
- // ----------------------------------------------------------------------------
43
- .s-progress--label {
44
- position: absolute;
45
- width: 100%;
46
- height: 100%;
47
- border-radius: var(--br-md);
48
- border: 1px solid transparent;
49
- font-size: var(--fs-caption);
50
- line-height: var(--lh-xs);
51
- color: var(--fc-dark);
52
- z-index: calc(var(--zi-base) + 2);
53
- }
54
-
55
- // ===========================================================================
56
- // $ VARIATION PROGRESS BACKGROUNDS
57
- // ---------------------------------------------------------------------------
58
- .s-progress__brand .s-progress--bar {
59
- background-color: var(--orange-500);
60
- }
61
-
62
- .s-progress__info .s-progress--bar {
63
- background-color: var(--blue-500);
64
- }
65
-
66
- .s-progress__privilege {
67
- .s-progress--bar {
68
- background-color: var(--green-050);
69
-
70
- .highcontrast-mode({
71
- background-color: var(--green-200);
72
- });
2
+ // BASE COMPONENT-SPECIFIC CUSTOM PROPERTIES
3
+ --_pr-bar: var(--br-sm);
4
+ --_pr-bg: var(--black-200);
5
+ --_pr-h: unset;
6
+ --_pr-size: unset;
7
+ --_pr-w: 100%;
8
+ --_pr-hmn: var(--su-static4);
9
+ --_pr-bar-bar: var(--br-sm);
10
+ --_pr-bar-bg: var(--green-400);
11
+ --_pr-bar-hmn: var(--su-static4);
12
+ --_pr-label-ai: unset;
13
+ --_pr-label-bc: transparent;
14
+ --_pr-label-d: unset;
15
+ --_pr-label-g: unset;
16
+ --_pr-label-jc: unset;
17
+ --_pr-label-px: unset;
18
+
19
+ // MODIFIERS
20
+ &&__brand {
21
+ --_pr-bar-bg: var(--orange-500);
73
22
  }
74
- .s-progress--label {
75
- border-color: var(--green-400);
76
- display: flex;
77
- gap: var(--su4);
78
- align-items: center;
79
- justify-content: center;
23
+ &&__bronze {
24
+ --_pr-bar-bg: var(--bronze-lighter);
25
+ --_pr-label-bc: var(--bronze-darker);
26
+ }
27
+ &&__gold {
28
+ --_pr-bar-bg: var(--gold-lighter);
29
+ --_pr-label-bc: var(--gold-darker);
30
+ }
31
+ &&__info {
32
+ --_pr-bar-bg: var(--blue-500);
33
+ }
34
+ &&__silver {
35
+ --_pr-bar-bg: var(--silver-lighter);
36
+ --_pr-label-bc: var(--silver-darker);
80
37
  }
81
- }
82
-
83
- // ===========================================================================
84
- // $ BADGE PROGRESS BARS
85
- // ===========================================================================
86
- .s-progress__privilege,
87
- .s-progress__privilege .s-progress--bar,
88
- .s-progress__badge,
89
- .s-progress__badge .s-progress--bar {
90
- min-height: 2em;
91
- border-radius: var(--br-md);
92
- }
93
-
94
- .s-progress__privilege,
95
- .s-progress__badge {
96
- background-color: transparent;
97
- }
98
38
 
99
- .s-progress__badge {
100
- .s-progress--label {
101
- display: flex;
102
- gap: var(--su4);
103
- align-items: center;
104
- padding-left: 1em;
105
- padding-right: 1em;
39
+ // VARIANTS
40
+ &&__badge,
41
+ &&__privilege {
42
+ --_pr-bar: var(--br-md);
43
+ --_pr-bg: transparent;
44
+ --_pr-hmn: 2em;
45
+ --_pr-bar-bar: var(--br-md);
46
+ --_pr-bar-hmn: 2em;
47
+ --_pr-label-d: flex;
48
+ --_pr-label-g: var(--su4);
49
+ }
50
+ &&__badge {
51
+ --_pr-label-ai: center;
52
+ --_pr-label-px: 1em;
106
53
 
107
- .s-badge--label {
108
- text-align: center;
109
- flex-grow: 1;
54
+ .s-progress--label {
55
+ .s-badge--label {
56
+ flex-grow: 1;
57
+ text-align: center;
58
+ }
110
59
  }
111
60
  }
112
- }
61
+ &&__circular {
62
+ --_pr-bg: transparent;
63
+ --_pr-size: var(--su-static32);
64
+ --s-progress-value: 0;
65
+ @s-progress-circle-circumference: (2 * pi() * 14); // 2πr, r = 14.
66
+
67
+ &.s-progress {
68
+ &__sm {
69
+ --_pr-size: var(--su-static24);
70
+ }
71
+ &__md {
72
+ --_pr-size: var(--su-static48);
73
+ }
74
+ &__lg {
75
+ --_pr-size: var(--su-static64);
76
+ }
77
+ }
78
+ // TODO: consider renaming to `.s-progress--bar`
79
+ .s-progress-bar { // It may necessitate wrapping element in a `&:not(&__circular)`
80
+ circle {
81
+ &:nth-of-type(1) {
82
+ opacity: 0.4;
83
+ stroke: currentColor;
84
+ }
85
+ &:nth-of-type(2) {
86
+ stroke: currentColor;
87
+ stroke-dasharray: @s-progress-circle-circumference; // [1]
88
+ stroke-dashoffset: calc(((1 - var(--s-progress-value)) * @s-progress-circle-circumference) * 1px); // Multiply everything by 1px since Safari and Firefox require these to be in pixels
89
+ }
90
+
91
+ fill: none;
92
+ stroke-linecap: round;
93
+ stroke-width: var(--su-static4);
94
+ }
113
95
 
114
- // $$ GOLD
115
- // ---------------------------------------------------------------------------
116
- .s-progress__gold {
117
- .s-progress--bar {
118
- background-color: var(--gold-lighter);
119
- }
120
- .s-progress--label {
121
- border-color: var(--gold-darker);
96
+ transform: rotate(270deg); // Make everything originate from the top of the circle
97
+ }
122
98
  }
123
- }
99
+ &&__privilege {
100
+ --_pr-bar-bg: var(--green-050);
101
+ --_pr-label-ai: center;
102
+ --_pr-label-bc: var(--green-400);
103
+ --_pr-label-jc: center;
124
104
 
125
- // $$ SILVER
126
- // ---------------------------------------------------------------------------
127
- .s-progress__silver {
128
- .s-progress--bar {
129
- background-color: var(--silver-lighter);
130
- }
131
- .s-progress--label {
132
- border-color: var(--silver-darker);
105
+ .highcontrast-mode({ --_pr-bar-bg: var(--green-200); });
133
106
  }
134
- }
107
+ // TODO move `.s-progress__stepped` to entirely separate component (or consider deprecating)
108
+ &&__stepped { // There's so little overlap with the base .s-progress that it doesn't make sense as a variant
109
+ background: transparent;
110
+ display: flex;
135
111
 
136
- // $$ BRONZE
137
- // ---------------------------------------------------------------------------
138
- .s-progress__bronze {
139
- .s-progress--bar {
140
- background-color: var(--bronze-lighter);
141
- }
142
- .s-progress--label {
143
- border-color: var(--bronze-darker);
112
+ .s-progress {
113
+ &--bar {
114
+ &.s-progress--bar {
115
+ &__left {
116
+ left: 0;
117
+ right: 50%;
118
+ }
119
+ &__right {
120
+ left: 50%;
121
+ right: 0;
122
+ }
123
+ }
124
+
125
+ background: var(--black-300);
126
+ border-radius: 0;
127
+ height: var(--su-static6);
128
+ position: absolute;
129
+ top: calc(var(--su-static8) + var(--su-static1));
130
+ z-index: var(--zi-base);
131
+ }
132
+ &--label { // Override a ton of properties
133
+ border: 0;
134
+ border-radius: 0;
135
+ color: var(--black-500);
136
+ display: block;
137
+ font-size: var(--fs-body1);
138
+ height: auto;
139
+ padding: var(--su12) var(--su6) 0 var(--su6);
140
+ position: static;
141
+ text-align: center;
142
+ width: auto;
143
+ z-index: var(--zi-base);
144
+ }
145
+ &--step {
146
+ &.is-active {
147
+ .s-progress {
148
+ &--bar.s-progress--bar__left {
149
+ background: var(--theme-secondary-400);
150
+ }
151
+ &--label {
152
+ color: var(--fc-dark);
153
+ }
154
+ &--stop {
155
+ background: var(--theme-secondary-400);
156
+ box-shadow: 0 0 0 var(--su-static6) var(--focus-ring);
157
+ }
158
+ }
159
+ }
160
+ &.is-complete {
161
+ .s-progress {
162
+ &--bar,
163
+ &--stop {
164
+ background: var(--theme-secondary-400);
165
+ }
166
+ &--label {
167
+ color: var(--fc-dark);
168
+ }
169
+ }
170
+ }
171
+
172
+ align-items: center;
173
+ display: flex;
174
+ flex-basis: 0;
175
+ flex-direction: column;
176
+ flex-grow: 1;
177
+ flex-shrink: 1;
178
+ position: relative;
179
+ }
180
+ &--stop {
181
+ .highcontrast-mode({
182
+ color: var(--white);
183
+ });
184
+
185
+ align-items: center;
186
+ background: var(--black-300);
187
+ border-radius: 100%;
188
+ color: @white;
189
+ display: flex;
190
+ height: var(--su-static24);
191
+ justify-content: center;
192
+ position: relative;
193
+ width: var(--su-static24);
194
+ z-index: var(--zi-selected);
195
+ }
196
+ }
144
197
  }
145
- }
146
198
 
147
- // ===========================================================================
148
- // $ SEGMENTED
149
- // ---------------------------------------------------------------------------
150
- .s-progress.s-progress__segmented {
151
- position: relative;
199
+ // CHILD ELEMENTS
200
+ & &--bar {
201
+ background-color: var(--_pr-bar-bg);
202
+ border-radius: var(--_pr-bar);
203
+ min-height: var(--_pr-hmn);
152
204
 
153
- .s-progress--segments {
154
- margin: 0;
155
- padding: 0;
205
+ height: 100%;
206
+ min-width: var(--su-static6);
207
+ position: relative;
208
+ }
209
+ & &--label {
210
+ align-items: var(--_pr-label-ai);
211
+ border: var(--su-static1) solid var(--_pr-label-bc);
212
+ display: var(--_pr-label-d);
213
+ gap: var(--_pr-label-g);
214
+ justify-content: var(--_pr-label-jc);
215
+ padding-left: var(--_pr-label-px);
216
+ padding-right: var(--_pr-label-px);
217
+
218
+ border-radius: var(--br-md);
219
+ color: var(--fc-dark);
220
+ font-size: var(--fs-caption);
221
+ height: 100%;
222
+ line-height: var(--lh-xs);
156
223
  position: absolute;
157
- top: 0;
158
224
  width: 100%;
159
- height: 100%;
160
- display: flex;
161
- justify-content: space-between;
162
- list-style: none;
163
-
225
+ z-index: calc(var(--zi-base) + 2);
226
+ }
227
+ & &--segments { // DEPRECATED: AFAICT, this is unused in core (as well as it's intended parent variant class `.s-progress__segmented`)
164
228
  li {
165
- display: block;
166
- padding-top: 4px;
167
- position: relative;
168
- text-align: center;
169
-
170
229
  &:not(:first-child):not(:last-child):before {
171
- display: block;
230
+ background-color: var(--white);
172
231
  content: "";
232
+ display: block;
173
233
  height: 100%;
174
- width: 4px;
234
+ left: calc(var(--su-static) * -1); // -1px
175
235
  position: absolute;
176
236
  top: 0;
177
- left: -1px;
178
- background-color: var(--white);
237
+ width: var(--su-static4);
179
238
  }
180
- }
181
- }
182
- }
183
-
184
- // ===========================================================================
185
- // $ STEPPED
186
- // ---------------------------------------------------------------------------
187
- .s-progress.s-progress__stepped {
188
- background: transparent;
189
- display: flex;
190
-
191
- .s-progress--step {
192
- display: flex;
193
- flex-grow: 1;
194
- flex-shrink: 1;
195
- flex-basis: 0;
196
- flex-direction: column;
197
- align-items: center;
198
- position: relative;
199
- }
200
239
 
201
- .s-progress--label {
202
- // Override a ton of properties
203
- position: static;
204
- display: block;
205
- width: auto;
206
- height: auto;
207
- font-size: var(--fs-body1);
208
- border: 0;
209
- border-radius: 0;
210
- padding: var(--su12) var(--su6) 0 var(--su6);
211
- text-align: center;
212
- color: var(--black-500);
213
- z-index: var(--zi-base);
214
- }
240
+ display: block;
241
+ padding-top: var(--su-static4);
242
+ position: relative;
243
+ text-align: center;
244
+ }
215
245
 
216
- .s-progress--stop {
217
- position: relative;
218
246
  display: flex;
219
- align-items: center;
220
- justify-content: center;
221
- background: var(--black-300);
222
- border-radius: 100%;
223
- width: var(--su-static24);
224
- height: var(--su-static24);
225
- z-index: var(--zi-selected);
226
- color: @white;
227
-
228
- .highcontrast-mode({
229
- color: var(--white);
230
- });
231
- }
232
-
233
- .s-progress--bar {
247
+ height: 100%;
248
+ justify-content: space-between;
249
+ list-style: none;
250
+ margin: 0;
251
+ padding: 0;
234
252
  position: absolute;
235
- top: calc(var(--su-static8) + var(--su-static1));
236
- height: var(--su-static6);
237
- background: var(--black-300);
238
- z-index: var(--zi-base);
239
- border-radius: 0;
240
-
241
- &.s-progress--bar__left {
242
- left: 0;
243
- right: 50%;
244
- }
245
-
246
- &.s-progress--bar__right {
247
- right: 0;
248
- left: 50%;
249
- }
250
- }
251
-
252
- .s-progress--step.is-active {
253
- .s-progress--bar.s-progress--bar__left {
254
- background: var(--theme-secondary-400);
255
- }
256
-
257
- .s-progress--stop {
258
- background: var(--theme-secondary-400);
259
- box-shadow: 0 0 0 var(--su-static6) var(--focus-ring);
260
- }
261
-
262
- .s-progress--label {
263
- color: var(--fc-dark);
264
- }
253
+ top: 0;
254
+ width: 100%;
265
255
  }
266
256
 
267
- .s-progress--step.is-complete {
268
- .s-progress--bar,
269
- .s-progress--stop {
270
- background: var(--theme-secondary-400);
271
- }
257
+ background-color: var(--_pr-bg);
258
+ border-radius: var(--_pr-bar);
259
+ height: var(--_pr-size, var(--_pr-h));
260
+ min-height: var(--_pr-hmn);
272
261
 
273
- .s-progress--label {
274
- color: var(--fc-dark);
275
- }
276
- }
262
+ min-width: var(--su-static6);
263
+ position: relative;
264
+ width: var(--_pr-size, var(--_pr-w));
277
265
  }
278
266
 
279
- // ===========================================================================
280
- // $ CIRCULAR
281
- // ---------------------------------------------------------------------------
282
- .s-progress__circular {
283
- --s-progress-value: 0;
284
- @s-progress-circle-circumference: (2 * pi() * 14); // 2πr, r = 14.
285
-
286
- background: none;
287
- width: var(--su-static32);
288
- height: var(--su-static32);
289
-
290
- .s-progress-bar {
291
- // Make everything originate from the top of the circle
292
- transform: rotate(270deg);
293
-
294
- circle {
295
- stroke-width: var(--su-static4);
296
- fill: none;
297
- stroke-linecap: round;
298
- }
299
-
300
- circle:nth-of-type(1) {
301
- stroke: currentColor;
302
- opacity: 0.4;
303
- }
304
-
305
- circle:nth-of-type(2) {
306
- stroke: currentColor;
307
- stroke-dasharray: @s-progress-circle-circumference;
308
-
309
- // Multiply the circle circumference by an the opposite percentage of what we want to display
310
- // For example 70%, represented as a decimal is 0.7
311
- // The opposite of that is 0.3 so ( 1 - 0.7 )
312
- stroke-dashoffset: calc(((1 - var(--s-progress-value)) * @s-progress-circle-circumference) * 1px); // Multiply everything by 1px since Safari and Firefox require these to be in pixels
313
- }
314
- }
315
-
316
- &.s-progress__sm {
317
- width: var(--su-static24);
318
- height: var(--su-static24);
319
- }
320
-
321
- &.s-progress__md {
322
- width: var(--su-static48);
323
- height: var(--su-static48);
324
- }
325
-
326
- &.s-progress__lg {
327
- width: var(--su-static64);
328
- height: var(--su-static64);
329
- }
330
- }
267
+ // [1] Multiply the circle circumference by an the opposite percentage of what we want to display
268
+ // For example 70%, represented as a decimal is 0.7
269
+ // The opposite of that is 0.3 so ( 1 - 0.7 )