Skip to content

Commit e0da077

Browse files
authored
feat(tags): Update designs for project SHINE (#2038)
* remove xs and md tag sizes * adjust tests and other usages * moar fixes * implement new designs * Create cold-kids-matter.md * fix a11y AAA contrast violation for high contrast mode and ignored tags * add log to debug failing test * fix old post summary for now * update visual test baselines * test a patch for flakiness * test * semicolon * log time * try moving pointer * test * cleanup * lint space
1 parent c0be7e7 commit e0da077

File tree

347 files changed

+773
-746
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

347 files changed

+773
-746
lines changed

.changeset/cold-kids-matter.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
"@stackoverflow/stacks": minor
3+
"@stackoverflow/stacks-svelte": minor
4+
---
5+
6+
feat(tags): updates tag component designs for project SHINE
7+
8+
BREAKING CHANGES
9+
10+
Tag sizes `xs` and `md` have been removed.

MIGRATION_GUIDE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
#### Popover
2828
- The new popovers no longer include an arrow element. The `s-popover--arrow` css class has been removed, and any markup using it (e.g. `<div class="s-popover--arrow"></div>`) should be deleted from the codebases as part of the migration.
2929

30+
#### Tags
31+
- `.s-tag__xs` removed
32+
- `.s-tag__md` removed
33+
3034
# Migrating from Stacks Svelte v0 to v1
3135

3236
Coming soon…

packages/stacks-classic/lib/components/post-summary/post-summary.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676

7777
background-color: var(--_ps-meta-tags-tag-bg);
7878
color: var(--black-500);
79+
border-color: var(--black-300);
7980
}
8081
}
8182
}

packages/stacks-classic/lib/components/tag/tag.less

Lines changed: 60 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,53 @@
11
.s-tag {
22
// Base
3-
--_ta-bc: var(--theme-tag-border-color, var(--_ta-bg));
3+
--_ta-bc: var(--theme-tag-border-color, var(--black-300));
44
--_ta-bg: var(--theme-tag-background-color, var(--black-150));
5-
--_ta-fc: var(--theme-tag-color, var(--black-500));
5+
--_ta-fc: var(--theme-tag-color, var(--black-600));
66
// Hover
7-
--_ta-bc-hover: var(--theme-tag-hover-border-color, var(--_ta-bg-hover));
7+
--_ta-bc-hover: var(--theme-tag-hover-border-color, var(--black-300));
88
--_ta-bg-hover: var(--theme-tag-hover-background-color, var(--black-200));
99
--_ta-fc-hover: var(--theme-tag-hover-color, var(--black-600));
1010
// Other
11-
--_ta-br: var(--br-md);
12-
--_ta-fs: var(--fs-caption);
13-
--_ta-lh: 1.846153846;
14-
--_ta-pl: var(--_ta-px);
15-
--_ta-pr: var(--_ta-px);
16-
--_ta-px: var(--su4);
17-
--_ta-dismiss-padding: calc(var(--_ta-px) - var(--su-static1));
11+
--_ta-fs: var(--fs-caption); //13px
12+
--_ta-lh: 126%;
13+
--_ta-pl: var(--su8);
14+
--_ta-pr: var(--su8);
15+
--_ta-pt: var(--su4);
16+
--_ta-pb: var(--su4);
17+
--_ta-fc-disabled: var(--black-400);
18+
--_ta-dismiss-padding-x: var(--su2);
19+
--_ta-dismiss-padding-y: var(--su1);
20+
--_ta-br: var(--su2);
21+
--_ta-before-pl: var(--su8);
22+
1823

1924
// CONTEXTUAL STYLES
2025
.highcontrast-mode({
21-
&:not(&__moderator):not(&__required) {
22-
--_ta-bc: var(--theme-tag-border-color, var(--black-300));
23-
--_ta-bc-hover: var(--theme-tag-hover-border-color, var(--black-300));
24-
}
26+
border-width: var(--su1);
27+
--_ta-fc-disabled: var(--black-500); //Fixes contrast issues
2528
});
2629

2730
// MODIFIERS
2831
// Sizes
29-
&&__xs {
30-
.size-styles(xs; ta; @styles: fs);
31-
--_ta-lh: 1.4;
32-
--_ta-px: var(--su2);
33-
}
3432
&&__sm {
35-
.size-styles(sm; ta; @styles: fs);
36-
--_ta-lh: 1.5;
33+
--_ta-fs: var(--fs-fine); //12px
34+
--_ta-pl: var(--su4);
35+
--_ta-pr: var(--su4);
36+
--_ta-pt: var(--su1);
37+
--_ta-pb: var(--su1);
38+
39+
// Reduce close button padding for a better fit
40+
--_ta-dismiss-padding-y: var(--su0);
41+
--_ta-before-pl: var(--su4);
3742
}
38-
&&__md {
39-
--_ta-px: var(--su6);
40-
--_ta-fs: var(--fs-body2);
41-
--_ta-lh: 1.733333333;
43+
44+
&&__sm&&__ignored,
45+
&&__sm&&__watched {
46+
--_ta-pl: calc(var(--su-static24) - var(--su-static2)); //22px
4247
}
48+
4349
&&__lg {
44-
--_ta-br: calc(var(--br-md) + var(--su-static1));
45-
--_ta-fs: var(--fs-subheading);
46-
--_ta-lh: 1.684210526;
47-
--_ta-px: var(--su6);
50+
--_ta-fs: var(--fs-body1); //14px
4851
}
4952

5053
// VARIANTS
@@ -53,10 +56,10 @@
5356
&&__ignored,
5457
&__watched, // TODO: remove all single `&` watched styles once core no longer requires them
5558
&&__watched {
56-
--_ta-pl: calc(var(--su-static24) - var(--su-static2)); // 22px
59+
--_ta-pl: calc(var(--su-static24) + var(--su-static2)); //26px
5760
--_ta-before-size: calc(var(--su-static16) - var(--su-static2)); // 14px
61+
5862
// --_ta-before-icon defined per variant
59-
6063
&:before {
6164
height: var(--_ta-before-size);
6265
width: var(--_ta-before-size);
@@ -66,10 +69,8 @@
6669
background-color: currentColor;
6770
content: "";
6871
display: block;
69-
left: var(--su-static4);
70-
margin-right: var(--su2);
72+
left: var(--_ta-before-pl);
7173
position: absolute;
72-
top: calc(50% - calc(var(--su-static8) - var(--su-static1)));
7374
-webkit-mask-size: contain;
7475
mask-size: contain;
7576
}
@@ -80,25 +81,34 @@
8081
&__ignored, // TODO: remove all single `&` ignored styles once core no longer requires them
8182
&&__ignored {
8283
--_ta-before-icon: url("data:image/svg+xml;,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath d='M3.52 7.38 1.58 9.26A12.38 12.38 0 0 1 0 7s2.63-5.14 7.05-5.14c.66 0 1.28.12 1.86.32L7.44 3.6a3.48 3.48 0 0 0-3.92 3.78ZM5.3 9.99c.5.28 1.1.44 1.71.44 1.94 0 3.5-1.53 3.5-3.43 0-.62-.17-1.21-.47-1.72L8.7 6.6a1.73 1.73 0 0 1-2.08 2.07L5.29 10Zm6.23-6.19A12.7 12.7 0 0 1 14 7s-2.63 5.14-6.95 5.14A6.1 6.1 0 0 1 4 11.3L2.27 13l-1.4-1.36L11.9 1l1.23 1.2-1.6 1.6Z'/%3E%3C/svg%3E");
84+
--_ta-fc: var(--theme-tag-color, var(--_ta-fc-disabled));
85+
&:hover {
86+
--_ta-bg-hover: var(--theme-tag-hover-background-color, var(--_ta-bg));
87+
--_ta-fc-hover: var(--theme-tag-hover-color, var(--_ta-fc-disabled));
88+
}
8389
}
8490

85-
// moderator overrides other required
91+
&&__required,
8692
&&__moderator {
87-
--_ta-bc: var(--orange-300);
93+
border-width: var(--su1);
94+
}
95+
96+
&&__moderator:not(&&__ignored) {
8897
--_ta-bg: var(--orange-100);
98+
--_ta-bc: var(--orange-300);
8999
--_ta-fc: var(--orange-500);
90-
--_ta-bc-hover: var(--orange-300);
91100
--_ta-bg-hover: var(--orange-200);
101+
--_ta-bc-hover: var(--orange-300);
92102
--_ta-fc-hover: var(--orange-600);
93103
}
94104

95105
&&__required:not(&__moderator) {
96-
--_ta-bc: var(--theme-tag-required-border-color, var(--theme-tag-border-color, var(--black-400)));
97-
--_ta-bg: var(--theme-tag-required-background-color, var(--theme-tag-background-color, var(--black-150)));
98-
--_ta-fc: var(--theme-tag-required-color, var(--theme-tag-color, var(--black-500)));
106+
--_ta-bc: var(--theme-tag-required-border-color, var(--theme-tag-border-color, var(--black-500)));
99107
--_ta-bc-hover: var(--theme-tag-required-hover-border-color, var(--theme-tag-hover-border-color, var(--black-600)));
100-
--_ta-bg-hover: var(--theme-tag-required-hover-background-color, var(--theme-tag-hover-background-color, var(--black-200)));
101-
--_ta-fc-hover: var(--theme-tag-required-hover-color, var(--theme-tag-hover-color, var(--black-600)));
108+
}
109+
110+
&&__required:not(&__moderator)&__ignored {
111+
--_ta-bc-hover: var(--_ta-bc);
102112
}
103113

104114
&__watched, // TODO: remove all single `&` watched styles once core no longer requires them
@@ -129,13 +139,12 @@
129139
align-items: center;
130140
align-self: stretch;
131141
background-color: transparent;
132-
border-radius: var(--br-md);
142+
border-radius: var(--_ta-br);
133143
color: inherit;
134144
cursor: pointer;
135145
display: flex;
136146
justify-content: center;
137-
margin: var(--su-static1) calc(var(--_ta-dismiss-padding) * -1) var(--su-static1) var(--_ta-dismiss-padding);
138-
padding: var(--_ta-dismiss-padding);
147+
margin: var(--_ta-dismiss-padding-y) calc(var(--_ta-dismiss-padding-x) * -1) var(--_ta-dismiss-padding-y) calc(var(--_ta-dismiss-padding-x) * 2);
139148
}
140149

141150
& &--sponsor { // The small sponsor favicon displayed within a tag
@@ -146,9 +155,9 @@
146155
}
147156

148157
align-self: center;
149-
border-radius: calc(var(--br-md) - var(--su-static1));
158+
border-radius: var(--_ta-br);
150159
display: inline-flex;
151-
margin: calc(var(--su1) * -1) var(--su4) calc(var(--su2) * -1) calc(var(--su2) * -1);
160+
margin: calc(var(--su1) * -1) var(--su4) calc(var(--su2) * -1) var(--su0);
152161
max-width: calc(var(--su-static16) + var(--su-static2));
153162
}
154163

@@ -167,17 +176,18 @@
167176
}
168177

169178
background-color: var(--_ta-bg);
170-
border: var(--su-static1) solid var(--_ta-bc);
171-
border-radius: var(--_ta-br);
179+
border: var(--su0) solid var(--_ta-bc);
172180
color: var(--_ta-fc);
173181
font-size: var(--_ta-fs);
174182
line-height: var(--_ta-lh);
175183
padding-left: var(--_ta-pl);
176184
padding-right: var(--_ta-pr);
185+
padding-top: var(--_ta-pt);
186+
padding-bottom: var(--_ta-pb);
177187

178188
align-items: center;
179189
display: inline-flex;
180-
font-weight: 700;
190+
font-weight: 400;
181191
justify-content: center;
182192
min-width: 0;
183193
text-decoration: none;

packages/stacks-classic/lib/components/tag/tag.visual.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe("tag", () => {
3737
runVisualTests({
3838
baseClass: "s-tag",
3939
modifiers: {
40-
primary: ["xs", "sm", "md", "lg"],
40+
primary: ["sm", "lg"],
4141
},
4242
children: {
4343
default: `default`,

packages/stacks-classic/lib/exports/constants-helpers.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ body {
3131
--zi-modals: 9000; // Modals
3232

3333
// Border Radius
34-
--br-md: calc(var(--su-static4) + var(--su-static6)); // 10px;
34+
--br-md: calc(var(--su-static4) + var(--su-static6)); // 10px
3535
--br-circle: 50%;
3636
--br-pill: 1000px;
3737
// TODO SHINE Retaining legacy border radius for backward compatibility
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:2967c0e742c88dbe3a1ca3a36ba7e7f5bb3905de819b4e6094f62400702b083d
3-
size 12352
2+
oid sha256:3b275c4c253c6242b15d364ef25b43b970f0fbdb65c3d6ef898b5e28500db4c5
3+
size 11524
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:d9fe8ef0ebac66eba4af0ffd9910cc8ab900d8d722eabc8412d387f8dcba6acf
3-
size 30147
2+
oid sha256:d71807a13f3d208827632f7ae0b074a8590f01e1e9dcf96e6e63e9316ddf0af6
3+
size 28543
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:f715a8409b21d726256475697a079c4a27de9d6d421d432a4eaf27730514c80e
3-
size 12059
2+
oid sha256:33fcee41492d061f0daf228e5eb8f6e7bdd344e0803bdce029b9fc110553a585
3+
size 11231
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:413d8e099a66630c7aa1d5931e5c92a441f283758cad9ad9d9377bd8790ae658
3-
size 30092
2+
oid sha256:dc1f191349baef3c2bd9b3b1a1fc66acadc297f47901ebaa802fe19653c649d5
3+
size 27715

0 commit comments

Comments
 (0)