Skip to content

Commit 25971ad

Browse files
committed
Merge branch 'spark-70/update-link-component' of https://github.com/StackExchange/Stacks into spark-70/update-link-component
2 parents 39f6fc1 + 0da7614 commit 25971ad

File tree

188 files changed

+455
-765
lines changed

Some content is hidden

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

188 files changed

+455
-765
lines changed

MIGRATION_GUIDE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333

3434
### Components
3535

36+
#### Anchors
37+
- Removed `.s-anchors__default` in favor of appling those styles as the default for `.s-anchors`
38+
3639
#### Badge
3740
- `.s-badge__xs` removed
3841
- `.s-badge__filled` removed
@@ -54,6 +57,9 @@
5457
- The Award Bling component has been renamed to Bling.
5558
- Bling no longer accepts children elements besides those for screen readers. Please include any visually represented strings (such as counts) as siblings to the bling component.
5659

60+
#### Block Link
61+
- The Block Link component has been removed.
62+
5763
#### Buttons
5864
- The secondary style `outlined` has been removed i.e. `.s-btn__outlined`
5965
- The default button style is `filled`, use `.s-btn__clear` to use a clear style of a button

packages/stacks-classic/lib/components/anchor/anchor.a11y.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ describe("anchors", () => {
1212
baseClass: "s-anchors",
1313
modifiers: {
1414
primary: [
15-
"default",
1615
"grayscale",
1716
"muted",
1817
"danger",
@@ -28,8 +27,5 @@ describe("anchors", () => {
2827
false
2928
)}.`,
3029
},
31-
options: {
32-
includeNullModifier: false,
33-
},
3430
});
3531
});
Lines changed: 28 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
.s-anchors {
2-
// CUSTOM PROPERTIED DEFINED WITHIN VARIANTS
3-
// --_an-a-fc
4-
// --_an-a-fc-hover
5-
// --_an-a-fc-visited
6-
// --_an-a-fc-hover-visited
2+
--_an-a-fc: var(--theme-link-color, var(--black-600));
3+
--_an-a-fc-hover: var(--theme-link-color-hover, var(--blue-400));
4+
--_an-a-fc-visited: var(--theme-link-color-visited, var(--black-400));
5+
6+
// CONTEXTUAL STYLES
7+
.highcontrast-mode({
8+
a[href] {
9+
text-decoration: underline;
10+
}
11+
});
712

813
// MODIFIERS
914
&&__underlined {
@@ -14,30 +19,15 @@
1419
}
1520

1621
// VARIANTS
17-
&&__danger,
18-
&&__grayscale,
19-
&&__inherit,
20-
&&__muted {
21-
--_an-a-fc-hover-visited: var(--_an-a-fc-hover);
22-
}
23-
2422
&&__danger {
2523
--_an-a-fc: var(--red-400);
2624
--_an-a-fc-hover: var(--red-500);
2725
--_an-a-fc-visited: var(--red-600);
2826
}
2927

30-
&&__default {
31-
--_an-a-fc: var(--theme-link-color, var(--black-600));
32-
--_an-a-fc-hover: var(--theme-link-color-hover, var(--blue-400));
33-
--_an-a-fc-visited: var(--theme-link-color-visited, var(--black-500));
34-
--_an-a-fc-hover-visited: var(--theme-link-color-visited, var(--black-500));
35-
}
36-
3728
&&__grayscale {
3829
--_an-a-fc: var(--black-500);
3930
--_an-a-fc-hover: var(--black-600);
40-
--_an-a-fc-visited: var(--black-400);
4131
}
4232

4333
&&__inherit {
@@ -55,32 +45,30 @@
5545

5646
&&__muted {
5747
--_an-a-fc: var(--black-400);
58-
--_an-a-fc-hover: var(--blue-400);
59-
--_an-a-fc-visited: var(--black-500);
6048
}
6149

62-
&&__danger,
63-
&&__default,
64-
&&__grayscale,
65-
&&__inherit,
66-
&&__muted,
67-
&&__underlined {
68-
a:not(.s-link),
69-
.s-btn.s-btn__link {
70-
&:active,
71-
&:hover {
72-
color: var(--_an-a-fc-hover);
73-
}
50+
p& > a[href],
51+
p > a[href] {
52+
text-decoration: underline;
53+
}
7454

75-
color: var(--_an-a-fc, inherit);
55+
a:not(.s-link),
56+
.s-btn.s-btn__link {
57+
&:active,
58+
&:hover {
59+
color: var(--_an-a-fc-hover);
60+
text-decoration: underline;
7661
}
7762

78-
a:not(.s-link):visited {
79-
&:hover {
80-
color: var(--_an-a-fc-hover-visited, inherit);
81-
}
63+
color: var(--_an-a-fc, inherit);
64+
text-decoration: none;
65+
}
8266

83-
color: var(--_an-a-fc-visited, inherit);
67+
a:not(.s-link):visited {
68+
&:hover {
69+
color: var(--_an-a-fc-hover, inherit);
8470
}
71+
72+
color: var(--_an-a-fc-visited, inherit);
8573
}
8674
}

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ describe("anchors", () => {
1919
baseClass: "s-anchors",
2020
modifiers: {
2121
primary: [
22-
"default",
2322
"grayscale",
2423
"muted",
2524
"danger",
@@ -35,9 +34,6 @@ describe("anchors", () => {
3534
<div class="s-card s-anchors s-anchors__muted mt4">Muted: ${links}</div>
3635
`,
3736
},
38-
options: {
39-
includeNullModifier: false,
40-
},
4137
template: ({ component, testid }) => html`
4238
<div data-testid="${testid}" class="s-card ws3 fc-green-500">
4339
${testid}: ${component}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,6 @@
102102
background-size: 100%;
103103
display: inline-block; // Make sure the avatar has structure regardless of the element eg. span vs. div
104104
position: relative;
105+
text-decoration: none;
105106
vertical-align: bottom; // Make our avatars play more nicely with text next to it.
106107
}

packages/stacks-classic/lib/components/link-preview/link-preview.less

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,15 @@
105105
& a&--title {
106106
&:active,
107107
&:hover {
108-
color: var(--theme-link-color-hover, var(--theme-secondary-500));
109-
}
110-
111-
&:active,
112-
&:hover,
113-
&.s-link__visited:active,
114-
&.s-link__visited:hover,
115-
&.s-link__visited:visited {
116108
.highcontrast-mode({
117109
text-decoration: underline;
118110
});
119111

112+
color: var(--theme-link-color-hover, var(--theme-secondary-500));
120113
text-decoration: none;
121114
}
122115

123-
&:visited,
124-
&.s-link__visited {
116+
&:visited {
125117
&:hover {
126118
color: var(--theme-link-color, var(--purple-600));
127119
}

packages/stacks-classic/lib/components/link/link.a11y.test.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,7 @@ describe("link", () => {
66
runA11yTests({
77
baseClass: "s-link",
88
modifiers: {
9-
primary: [
10-
"grayscale",
11-
"muted",
12-
"danger",
13-
"inherit",
14-
"underlined",
15-
"visited",
16-
],
9+
primary: ["grayscale", "muted", "danger", "inherit", "underlined"],
1710
secondary: ["dropdown"],
1811
},
1912
children: {
Lines changed: 27 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,13 @@
1-
// Reset browser default underline for Stacks component anchors (e.g. .s-navigation--item).
2-
// Without this components that use <a> but don't use .s-link would inherit underline.
3-
a[class*="s-"] {
4-
text-decoration: none;
5-
}
6-
7-
// Base link styles shared by .s-link and by bare <a> inside .s-prose.
8-
.s-link,
9-
.s-prose a:not([class*="s-"]) {
1+
.s-link {
102
--_li-fc: var(--theme-link-color, var(--black-600));
113
--_li-fc-hover: var(--theme-link-color-hover, var(--blue-400));
124
--_li-fc-visited: var(--theme-link-color-visited, var(--black-400));
13-
--_li-fc-hover-visited: var(--theme-link-color-visited, var(--black-400));
145

6+
// CONTEXTUAL STYLES
157
.highcontrast-mode({
168
text-decoration: underline;
179
});
1810

19-
color: var(--_li-fc);
20-
cursor: pointer;
21-
text-decoration: none;
22-
user-select: auto;
23-
24-
// INTERACTION
25-
&:active,
26-
&:hover {
27-
--_li-fc: var(--_li-fc-hover);
28-
text-decoration: underline !important;
29-
}
30-
&:visited {
31-
color: var(--_li-fc-visited);
32-
}
33-
34-
&:hover:visited {
35-
color: var(--_li-fc-hover-visited);
36-
text-decoration: underline !important;
37-
}
38-
}
39-
40-
.s-link {
4111
// MODIFIERS
4212
&__dropdown {
4313
&:after {
@@ -62,21 +32,7 @@ a[class*="s-"] {
6232
text-decoration: underline !important;
6333
}
6434

65-
&__visited { // TODO can we get rid of this? It's only in 3 places in Core and seems to me it doesn't even serve a purpose.
66-
--_li-fc: var(--theme-link-color-visited, var(--black-500));
67-
--_li-fc-hover: var(--theme-link-color-hover, var(--black-600));
68-
--_li-fc-visited: var(--theme-link-color-visited, var(--black-500));
69-
--_li-fc-hover-visited: var(--theme-link-color-visited, var(--black-500));
70-
}
71-
7235
// VARIANTS
73-
&__danger,
74-
&__grayscale,
75-
&__inherit,
76-
&__muted {
77-
--_li-fc-hover-visited: var(--_li-fc-visited);
78-
}
79-
8036
&__danger {
8137
--_li-fc: var(--red-400);
8238
--_li-fc-hover: var(--red-500);
@@ -86,7 +42,6 @@ a[class*="s-"] {
8642
&__grayscale {
8743
--_li-fc: var(--black-500);
8844
--_li-fc-hover: var(--black-600);
89-
--_li-fc-visited: var(--black-400);
9045
}
9146

9247
&__inherit {
@@ -97,10 +52,9 @@ a[class*="s-"] {
9752

9853
&__muted {
9954
--_li-fc: var(--black-400);
100-
--_li-fc-hover: var(--blue-400);
101-
--_li-fc-visited: var(--black-400);
10255
}
10356

57+
// MODIFIERS
10458
fieldset[disabled] & {
10559
box-shadow: none !important;
10660
opacity: var(--_o-disabled-static);
@@ -120,4 +74,28 @@ a[class*="s-"] {
12074
padding: 0;
12175
user-select: auto;
12276
}
77+
78+
p & {
79+
text-decoration: underline;
80+
}
81+
82+
// INTERACTION
83+
&:active,
84+
&:hover {
85+
--_li-fc: var(--_li-fc-hover);
86+
text-decoration: underline;
87+
}
88+
89+
&:visited {
90+
&:hover {
91+
color: var(--_li-fc-hover);
92+
}
93+
94+
color: var(--_li-fc-visited);
95+
}
96+
97+
color: var(--_li-fc);
98+
cursor: pointer;
99+
text-decoration: none;
100+
user-select: auto;
123101
}

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

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,7 @@ describe("link", () => {
77
runVisualTests({
88
baseClass: "s-link",
99
modifiers: {
10-
primary: [
11-
"grayscale",
12-
"muted",
13-
"danger",
14-
"inherit",
15-
"underlined",
16-
"visited",
17-
],
10+
primary: ["grayscale", "muted", "danger", "inherit", "underlined"],
1811
secondary: ["dropdown"],
1912
},
2013
children: {
@@ -33,14 +26,7 @@ describe("link", () => {
3326
runVisualTests({
3427
baseClass: "s-link",
3528
modifiers: {
36-
primary: [
37-
"grayscale",
38-
"muted",
39-
"danger",
40-
"inherit",
41-
"underlined",
42-
"visited",
43-
],
29+
primary: ["grayscale", "muted", "danger", "inherit", "underlined"],
4430
secondary: ["dropdown"],
4531
},
4632
children: {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
.highcontrast-mode({
2424
--_na-item-bg-hover: var(--black-500);
2525
--_na-item-fc-hover: var(--black-225);
26+
27+
a[href].s-navigation--item {
28+
text-decoration: underline;
29+
}
2630
});
2731

2832
// MODIFIERS
@@ -126,6 +130,7 @@
126130
cursor: pointer;
127131
display: flex;
128132
position: relative;
133+
text-decoration: none;
129134
user-select: auto;
130135
}
131136

0 commit comments

Comments
 (0)