|
7 | 7 | display: grid;
|
8 | 8 | gap: var(--ams-card-gap);
|
9 | 9 | outline-offset: var(--ams-card-outline-offset);
|
10 |
| - position: relative; |
| 10 | + position: relative; // Allows stretching the card link below. |
11 | 11 | touch-action: manipulation;
|
12 | 12 |
|
13 |
| - /* Set native outline on card if card has focus visible within */ |
| 13 | + // Set native outline to Card if it has a visible focus inside. |
14 | 14 | &:has(:focus-visible) {
|
15 | 15 | outline-color: -webkit-focus-ring-color;
|
16 | 16 | outline-style: auto;
|
17 | 17 | outline-width: 0.0625rem;
|
18 | 18 | }
|
19 |
| - |
20 |
| - /* |
21 |
| - Remove link focus outline only if :has is supported, |
22 |
| - which means the outline on the whole card is set |
23 |
| - */ |
24 |
| - &:has(:focus-visible) a:focus { |
25 |
| - outline: none; |
26 |
| - } |
27 |
| - |
28 |
| - /* |
29 |
| - This trick, together with position: relative on the outer wrapper, makes the whole card clickable. |
30 |
| - Taken from https://inclusive-components.design/cards/ |
31 |
| - */ |
32 |
| - a::after { |
33 |
| - content: ""; |
34 |
| - display: block; |
35 |
| - inset-block: 0; |
36 |
| - inset-inline: 0; |
37 |
| - position: absolute; |
38 |
| - } |
39 | 19 | }
|
40 | 20 |
|
41 | 21 | .ams-card__heading-group {
|
|
50 | 30 | text-decoration-thickness: var(--ams-card-link-text-decoration-thickness);
|
51 | 31 | text-underline-offset: var(--ams-card-link-text-underline-offset);
|
52 | 32 |
|
| 33 | + // Make the whole Card clickable by making the link cover its entire area. |
| 34 | + // Source: https://inclusive-components.design/cards/ |
| 35 | + &::after { |
| 36 | + content: ""; |
| 37 | + display: block; |
| 38 | + inset-block: 0; |
| 39 | + inset-inline: 0; |
| 40 | + position: absolute; |
| 41 | + } |
| 42 | + |
53 | 43 | &:hover {
|
54 | 44 | color: var(--ams-card-link-hover-color);
|
55 | 45 | text-decoration-line: var(--ams-card-link-hover-text-decoration-line);
|
56 | 46 | }
|
| 47 | + |
| 48 | + // Remove the outline from the link; it’s already on the Card. |
| 49 | + // Reuses the `.ams-card:has(:focus-visible)` selector above, so that |
| 50 | + // browsers that support it apply both styles, while those that don’t apply neither. |
| 51 | + .ams-card:has(:focus-visible) &:focus { |
| 52 | + outline: none; |
| 53 | + } |
57 | 54 | }
|
0 commit comments