|
| 1 | +@use '../../compiled/tokens/scss/color'; |
| 2 | +@use '../../compiled/tokens/scss/ease'; |
| 3 | +@use "../../compiled/tokens/scss/font-weight"; |
| 4 | +@use '../../compiled/tokens/scss/size'; |
| 5 | +@use "../../compiled/tokens/scss/scale"; |
| 6 | +@use '../../compiled/tokens/scss/transition'; |
| 7 | +@use '../../mixins/focus'; |
| 8 | +@use '../../mixins/ms'; |
| 9 | +@use '../../mixins/theme'; |
| 10 | + |
| 11 | +/// Footnote links are small numbered circles within a body of text that |
| 12 | +/// link to a footnote below |
| 13 | +/// |
| 14 | +/// 1. They start off as circles but if their content gets wide they turn into pills |
| 15 | +/// 2. Since they can be linked to we assign them a margin offset, so when they're |
| 16 | +/// linked they're not right at the top of the screen |
| 17 | +/// 3. They have a higher vertical baseline than the text around them. (This is |
| 18 | +/// similar to the `<sup>` element. Since `<sup>` has no semantic meaning, we |
| 19 | +/// apply these styles via CSS |
| 20 | +.c-footnote-link { |
| 21 | + background-color: color.$base-gray-lighter; |
| 22 | + border-radius: size.$border-radius-full; /* 1 */ |
| 23 | + color: color.$text-action; |
| 24 | + display: inline-block; |
| 25 | + font-size: ms.step(-2); |
| 26 | + font-weight: font-weight.$medium; |
| 27 | + line-height: size.$square-footnote-link; /* 1 */ |
| 28 | + min-width: size.$square-footnote-link; /* 1 */ |
| 29 | + padding: 0 ms.step(-5); /* 1 */ |
| 30 | + scroll-margin: ms.step(4); /* 2 */ |
| 31 | + text-align: center; |
| 32 | + text-decoration: none; |
| 33 | + transition-duration: transition.$quick; |
| 34 | + transition-property: background-color, color, transform; |
| 35 | + transition-timing-function: ease.$out; |
| 36 | + vertical-align: super; /* 3 */ |
| 37 | + |
| 38 | + &:hover { |
| 39 | + background-color: color.$text-action; |
| 40 | + color: color.$text-light-emphasis; |
| 41 | + } |
| 42 | + |
| 43 | + @include theme.styles(dark) { |
| 44 | + background-color: color.$brand-primary-dark; |
| 45 | + color: color.$text-light-emphasis; |
| 46 | + |
| 47 | + &:hover { |
| 48 | + background-color: color.$text-light-emphasis; |
| 49 | + color: color.$text-action; |
| 50 | + } |
| 51 | + } |
| 52 | + |
| 53 | + /// We add a subtle animation to the footnote link when it is targeted via the |
| 54 | + /// URL hash. This is meant to provide a visual cue about where you landed. |
| 55 | + /// We use a temporary animation to avoid it being confused with a focus or |
| 56 | + /// hover style. |
| 57 | + &:target { |
| 58 | + animation: footnote-link-target-circle transition.$glacial ease.$out; |
| 59 | + } |
| 60 | + |
| 61 | + @include focus.focus-visible { |
| 62 | + box-shadow: 0 0 0 size.$edge-medium color.$brand-primary-lighter; |
| 63 | + } |
| 64 | + |
| 65 | + &:active { |
| 66 | + transform: scale(scale.$effect-shrink); |
| 67 | + } |
| 68 | +} |
| 69 | + |
| 70 | +@keyframes footnote-link-target-circle { |
| 71 | + from { |
| 72 | + box-shadow: 0 0 0 size.$edge-medium color.$brand-primary-light; |
| 73 | + } |
| 74 | + to { |
| 75 | + box-shadow: 0 0 0 size.$edge-medium transparent; |
| 76 | + } |
| 77 | +} |
0 commit comments