@stackoverflow/stacks 3.0.0-beta.20 → 3.0.0-beta.21
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.
- package/dist/css/stacks.css +72 -41
- package/dist/css/stacks.min.css +1 -1
- package/lib/components/banner/banner.less +11 -10
- package/lib/components/button/button.less +37 -29
- package/lib/components/notice/notice.less +14 -8
- package/lib/components/toast/toast.less +3 -0
- package/lib/test/visual-test-utils.ts +42 -10
- package/package.json +1 -1
|
@@ -5,6 +5,13 @@
|
|
|
5
5
|
--_no-ty-offset: 0;
|
|
6
6
|
--_no-ty: var(--theme-topbar-height, calc(var(--su-static48) + var(--su-static8)));
|
|
7
7
|
.construct-notice-component(s-banner);
|
|
8
|
+
|
|
9
|
+
&--icon {
|
|
10
|
+
//Remove the icon backgound color
|
|
11
|
+
--_no-icon-bg: transparent;
|
|
12
|
+
margin-right: var(--su8);
|
|
13
|
+
align-self: flex-start;
|
|
14
|
+
}
|
|
8
15
|
|
|
9
16
|
&[aria-hidden="true"] { // If you want to hide and reveal the banner
|
|
10
17
|
--_no-ty-offset: -1;
|
|
@@ -27,18 +34,12 @@
|
|
|
27
34
|
padding-top: 93px;
|
|
28
35
|
}
|
|
29
36
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
position: relative;
|
|
34
|
-
width: 100%;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
border-width: 0 0 var(--su-static1);
|
|
37
|
+
display: flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
padding: var(--su16);
|
|
38
40
|
inset: 0 0 auto 0;
|
|
39
|
-
padding: var(--su12);
|
|
40
41
|
position: fixed;
|
|
41
42
|
transform: translate3d(0, calc(var(--_no-ty) * var(--_no-ty-offset)), 0);
|
|
42
43
|
width: 100%;
|
|
43
44
|
z-index: calc(var(--zi-navigation-fixed) - 1); // Tuck below topbar
|
|
44
|
-
}
|
|
45
|
+
}
|
|
@@ -6,20 +6,24 @@
|
|
|
6
6
|
--_bu-g: var(--su8);
|
|
7
7
|
--_bu-px: var(--su16);
|
|
8
8
|
--_bu-py: calc(var(--su8) + var(--su2)); // 10px
|
|
9
|
+
--_bu-badge-fs: var(--fs-caption);
|
|
10
|
+
--_bu-badge-px: var(--su6);
|
|
11
|
+
--_bu-badge-py: var(--su2);
|
|
9
12
|
--_bu-dropdown-bw: var(--su-static4);
|
|
10
13
|
|
|
11
14
|
// VARIANTS
|
|
12
15
|
// Base
|
|
13
16
|
&:not(&__danger):not(&__featured):not(&__tonal):not(&__link):not(&__unset):not(&__facebook):not(&__github):not(&__google) { // Exclude default styles from impacting these variants
|
|
14
17
|
--_bu-bg: var(--theme-button-color, var(--theme-secondary));
|
|
15
|
-
--_bu-bg-disabled: var(--
|
|
18
|
+
--_bu-bg-disabled: var(--black-350);
|
|
16
19
|
--_bu-bg-hover: var(--theme-button-hover-background-color, var(--theme-secondary-500));
|
|
17
20
|
--_bu-fc: var(--white);
|
|
21
|
+
--_bu-fc-disabled: var(--black-050);
|
|
18
22
|
--_bu-fc-hover: var(--theme-button-hover-color, var(--white));
|
|
19
|
-
--_bu-badge-bg: var(--theme-secondary-
|
|
20
|
-
--_bu-badge-fc: var(--
|
|
21
|
-
--_bu-badge-bg-disabled: var(--
|
|
22
|
-
--_bu-badge-fc-disabled: var(--
|
|
23
|
+
--_bu-badge-bg: var(--theme-secondary-500);
|
|
24
|
+
--_bu-badge-fc: var(--white);
|
|
25
|
+
--_bu-badge-bg-disabled: var(--black-250);
|
|
26
|
+
--_bu-badge-fc-disabled: var(--black-050);
|
|
23
27
|
|
|
24
28
|
&.s-btn__clear {
|
|
25
29
|
--_bu-bg: transparent;
|
|
@@ -29,10 +33,10 @@
|
|
|
29
33
|
--_bu-fc: var(--theme-secondary-600);
|
|
30
34
|
--_bu-fc-disabled: var(--theme-secondary-300);
|
|
31
35
|
--_bu-fc-hover: var(--_bu-fc);
|
|
32
|
-
--_bu-badge-bg: var(--theme-secondary-
|
|
33
|
-
--_bu-badge-fc: var(--
|
|
34
|
-
--_bu-badge-bg-disabled: var(--
|
|
35
|
-
--_bu-badge-fc-disabled: var(--
|
|
36
|
+
--_bu-badge-bg: var(--theme-secondary-100);
|
|
37
|
+
--_bu-badge-fc: var(--theme-secondary-500);
|
|
38
|
+
--_bu-badge-bg-disabled: var(--black-100);
|
|
39
|
+
--_bu-badge-fc-disabled: var(--black-350);
|
|
36
40
|
|
|
37
41
|
.highcontrast-mode({
|
|
38
42
|
--_bu-bc: var(--theme-secondary-600);
|
|
@@ -44,13 +48,14 @@
|
|
|
44
48
|
--_bu-bg: var(--red-400);
|
|
45
49
|
--_bu-fc: var(--white);
|
|
46
50
|
--_bu-bg-disabled: var(--red-200);
|
|
51
|
+
--_bu-fc-disabled: var(--black-050);
|
|
47
52
|
--_bu-bg-hover: var(--red-500);
|
|
48
53
|
--_bu-bg-selected: var(--red-500);
|
|
49
54
|
--_bu-fc-selected: var(--_bu-fc);
|
|
50
|
-
--_bu-badge-bg: var(--red-
|
|
51
|
-
--_bu-badge-fc: var(--
|
|
52
|
-
--_bu-badge-bg-disabled: var(--
|
|
53
|
-
--_bu-badge-fc-disabled: var(--
|
|
55
|
+
--_bu-badge-bg: var(--red-500);
|
|
56
|
+
--_bu-badge-fc: var(--black-050);
|
|
57
|
+
--_bu-badge-bg-disabled: var(--red-300);
|
|
58
|
+
--_bu-badge-fc-disabled: var(--black-100);
|
|
54
59
|
|
|
55
60
|
&.s-btn__clear {
|
|
56
61
|
--_bu-bg: transparent;
|
|
@@ -61,11 +66,10 @@
|
|
|
61
66
|
--_bu-fc-disabled: var(--red-200);
|
|
62
67
|
--_bu-fc-hover: var(--red-500);
|
|
63
68
|
--_bu-fc-selected: var(--red-500);
|
|
64
|
-
--_bu-badge-bg: var(--red-
|
|
65
|
-
--_bu-badge-
|
|
66
|
-
--_bu-badge-
|
|
67
|
-
--_bu-badge-
|
|
68
|
-
--_bu-badge-fc-disabled: var(--white);
|
|
69
|
+
--_bu-badge-bg: var(--red-100);
|
|
70
|
+
--_bu-badge-fc: var(--red-500);
|
|
71
|
+
--_bu-badge-bg-disabled: var(--red-100);
|
|
72
|
+
--_bu-badge-fc-disabled: var(--red-300);
|
|
69
73
|
|
|
70
74
|
.highcontrast-mode({
|
|
71
75
|
--_bu-bc: var(--red-600);
|
|
@@ -81,10 +85,10 @@
|
|
|
81
85
|
--_bu-bg-selected: var(--purple-500);
|
|
82
86
|
--_bu-fc: var(--white);
|
|
83
87
|
--_bu-fc-selected: var(--_bu-fc);
|
|
84
|
-
--_bu-badge-bg: var(--purple-
|
|
85
|
-
--_bu-badge-fc: var(--
|
|
86
|
-
--_bu-badge-bg-disabled: var(--
|
|
87
|
-
--_bu-badge-fc-disabled: var(--
|
|
88
|
+
--_bu-badge-bg: var(--purple-500);
|
|
89
|
+
--_bu-badge-fc: var(--black-050);
|
|
90
|
+
--_bu-badge-bg-disabled: var(--purple-300);
|
|
91
|
+
--_bu-badge-fc-disabled: var(--black-100);
|
|
88
92
|
}
|
|
89
93
|
|
|
90
94
|
&&__tonal {
|
|
@@ -94,10 +98,10 @@
|
|
|
94
98
|
--_bu-fc: var(--black);
|
|
95
99
|
--_bu-fc-disabled: var(--black-300);
|
|
96
100
|
--_bu-fc-selected: var(--_bu-fc);
|
|
97
|
-
--_bu-badge-bg: var(--black-
|
|
98
|
-
--_bu-badge-fc: var(--
|
|
99
|
-
--_bu-badge-bg-disabled: var(--black-
|
|
100
|
-
--_bu-badge-fc-disabled: var(--
|
|
101
|
+
--_bu-badge-bg: var(--black-200);
|
|
102
|
+
--_bu-badge-fc: var(--black-600);
|
|
103
|
+
--_bu-badge-bg-disabled: var(--black-100);
|
|
104
|
+
--_bu-badge-fc-disabled: var(--black-350);
|
|
101
105
|
|
|
102
106
|
.highcontrast-mode({
|
|
103
107
|
--_bu-bc: var(--black-300);
|
|
@@ -229,15 +233,15 @@
|
|
|
229
233
|
}
|
|
230
234
|
|
|
231
235
|
// CHILD ELEMENTS
|
|
232
|
-
// TODO SHINE fine-tune badge styles
|
|
233
236
|
& &--badge {
|
|
234
237
|
background-color: var(--_bu-badge-bg);
|
|
235
238
|
border-radius: var(--br-pill);
|
|
236
239
|
display: inline-block;
|
|
237
|
-
font-size: var(--fs
|
|
240
|
+
font-size: var(--_bu-badge-fs);
|
|
238
241
|
line-height: inherit;
|
|
239
242
|
opacity: var(--_bu-badge-o);
|
|
240
|
-
padding: var(--
|
|
243
|
+
padding: var(--_bu-badge-py) var(--_bu-badge-px);
|
|
244
|
+
margin-block: calc(var(--_bu-badge-py) * -1);
|
|
241
245
|
}
|
|
242
246
|
|
|
243
247
|
& &--number {
|
|
@@ -264,6 +268,9 @@
|
|
|
264
268
|
&&__sm {
|
|
265
269
|
--_bu-lh: var(--lh-sm);
|
|
266
270
|
--_bu-px: var(--su12);
|
|
271
|
+
--_bu-badge-fs: var(--fs-fine);
|
|
272
|
+
--_bu-badge-py: var(--su1);
|
|
273
|
+
--_bu-badge-px: calc(var(--su2) + var(--su1)); // 3px
|
|
267
274
|
}
|
|
268
275
|
&&__xs {
|
|
269
276
|
--_bu-g: var(--su4);
|
|
@@ -279,6 +286,7 @@
|
|
|
279
286
|
--_bu-fs: var(--fs-body2);
|
|
280
287
|
--_bu-px: var(--su24);
|
|
281
288
|
--_bu-py: calc(var(--su12) + var(--su1)); // 13px
|
|
289
|
+
--_bu-badge-py: calc(var(--su2) + var(--su1)); // 3px
|
|
282
290
|
}
|
|
283
291
|
|
|
284
292
|
// INTERACTION
|
|
@@ -27,8 +27,9 @@
|
|
|
27
27
|
/**
|
|
28
28
|
* Generate styles for a notice-based component
|
|
29
29
|
*
|
|
30
|
-
* Usage
|
|
30
|
+
* Usage examples:
|
|
31
31
|
* .construct-notice-component(s-banner);
|
|
32
|
+
* .construct-notice-component(s-notice);
|
|
32
33
|
*
|
|
33
34
|
* @baseClass - The base class name for the notice component
|
|
34
35
|
*/
|
|
@@ -110,7 +111,6 @@
|
|
|
110
111
|
&__warning {
|
|
111
112
|
&:not(.@{baseClass}__important) {
|
|
112
113
|
.generate-variant-variables(yellow);
|
|
113
|
-
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
&.@{baseClass}__important {
|
|
@@ -164,16 +164,26 @@
|
|
|
164
164
|
background-color: var(--_no-fc);
|
|
165
165
|
color: var(--_no-bg);
|
|
166
166
|
}
|
|
167
|
+
color: var(--_no-fc);
|
|
167
168
|
}
|
|
168
169
|
|
|
169
|
-
|
|
170
|
+
&--actions {
|
|
171
|
+
display: flex;
|
|
172
|
+
margin-left: auto;
|
|
173
|
+
align-self: flex-start;
|
|
170
174
|
padding-left: var(--su24);
|
|
171
|
-
|
|
175
|
+
color: var(--_no-fc);
|
|
172
176
|
gap: calc(var(--su24) - var(--su2)); //22px
|
|
177
|
+
|
|
173
178
|
//Fix css issue caused by svelte-sonner-toast in the NoticeAction svelte component
|
|
174
179
|
overflow-wrap: initial !important;
|
|
175
180
|
}
|
|
176
181
|
|
|
182
|
+
//Fix notice action color for __important variant
|
|
183
|
+
&--actions > .s-link:not(&--dismiss) {
|
|
184
|
+
color: var(--_no-fc);
|
|
185
|
+
}
|
|
186
|
+
|
|
177
187
|
// STYLES MODIFIED BY COMPONENT-SPECIFIC CUSTOM PROPERTIES
|
|
178
188
|
background: var(--_no-bg);
|
|
179
189
|
color: var(--_no-fc);
|
|
@@ -195,10 +205,6 @@
|
|
|
195
205
|
margin-right: var(--su12);
|
|
196
206
|
align-self: stretch;
|
|
197
207
|
|
|
198
|
-
//Position the svg icon
|
|
199
|
-
display: flex;
|
|
200
|
-
align-items: top;
|
|
201
|
-
|
|
202
208
|
//Negative margin to make up for s-notice's padding
|
|
203
209
|
margin-top: calc(var(--_no-pd) * -1);
|
|
204
210
|
margin-bottom: calc(var(--_no-pd) * -1);
|
|
@@ -23,6 +23,7 @@ const scheduleVisualTest = ({
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
let retryAttempts = 3;
|
|
26
|
+
let lastError: Error | null = null;
|
|
26
27
|
|
|
27
28
|
do {
|
|
28
29
|
await fixture(element);
|
|
@@ -37,21 +38,22 @@ const scheduleVisualTest = ({
|
|
|
37
38
|
return;
|
|
38
39
|
} catch (error) {
|
|
39
40
|
const e = error as Error;
|
|
40
|
-
|
|
41
|
-
//
|
|
42
|
-
if (
|
|
43
|
-
retryAttempts > 0 &&
|
|
44
|
-
!e.message.includes("Visual diff failed.")
|
|
45
|
-
) {
|
|
46
|
-
retryAttempts--;
|
|
47
|
-
continue;
|
|
48
|
-
} else {
|
|
41
|
+
lastError = e;
|
|
42
|
+
// if the error is a visual diff failure, fail immediately
|
|
43
|
+
if (e.message.includes("Visual diff failed.")) {
|
|
49
44
|
throw e;
|
|
50
45
|
}
|
|
46
|
+
// otherwise retry (to prevent flaky tests due to snapshot capturing)
|
|
47
|
+
retryAttempts--;
|
|
51
48
|
} finally {
|
|
52
49
|
el.remove();
|
|
53
50
|
}
|
|
54
51
|
} while (retryAttempts > 0);
|
|
52
|
+
|
|
53
|
+
// If we exhausted all retries without success, throw the last error
|
|
54
|
+
if (lastError) {
|
|
55
|
+
throw lastError;
|
|
56
|
+
}
|
|
55
57
|
});
|
|
56
58
|
};
|
|
57
59
|
|
|
@@ -60,4 +62,34 @@ const runVisualTests = (args: VisualTestArgs) => {
|
|
|
60
62
|
testVariations.forEach(scheduleVisualTest);
|
|
61
63
|
};
|
|
62
64
|
|
|
63
|
-
|
|
65
|
+
const replaceHtml = (
|
|
66
|
+
componentTemplateResult: unknown,
|
|
67
|
+
textToReplace: string,
|
|
68
|
+
replacementHtml: string
|
|
69
|
+
) => {
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
71
|
+
const component = componentTemplateResult as any;
|
|
72
|
+
if (!Array.isArray(component.strings) || !Array.isArray(component.values)) {
|
|
73
|
+
throw new Error("Expected Lit TemplateResult type");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Replace placeholder with actual icon in the Lit template
|
|
77
|
+
const originalStrings = component.strings;
|
|
78
|
+
const updatedStrings = originalStrings.map((str: string) =>
|
|
79
|
+
str.replace(textToReplace, replacementHtml)
|
|
80
|
+
);
|
|
81
|
+
// Create a proper TemplateStringsArray with raw property
|
|
82
|
+
Object.defineProperty(updatedStrings, "raw", {
|
|
83
|
+
value: updatedStrings.map((str: string) => str),
|
|
84
|
+
enumerable: false,
|
|
85
|
+
});
|
|
86
|
+
// Reconstruct the template with updated strings and original values
|
|
87
|
+
const updatedComponent = {
|
|
88
|
+
...component,
|
|
89
|
+
strings: updatedStrings,
|
|
90
|
+
values: component.values,
|
|
91
|
+
};
|
|
92
|
+
return updatedComponent;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export { runVisualTests, replaceHtml };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackoverflow/stacks",
|
|
3
3
|
"description": "Stack Overflow’s CSS and Design Pattern Library. Stacks is an atomic CSS library with classes and components for rapidly building Stack Overflow.",
|
|
4
|
-
"version": "3.0.0-beta.
|
|
4
|
+
"version": "3.0.0-beta.21",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
7
7
|
"lib",
|