Skip to content

Commit a901027

Browse files
mdojulien-deramond
andauthored
Update colored links, add new .link-body-emphasis helper (#37833)
* Rewrite colored links to use color property again instead of --bs-link-color-rgb value because nav links and more do not set --bs-link-color-rgb * Update bundlewatch * Document it Co-authored-by: Julien Déramond <juderamond@gmail.com>
1 parent f40e76d commit a901027

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

.bundlewatch.config.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
},
2727
{
2828
"path": "./dist/css/bootstrap.css",
29-
"maxSize": "32.0 kB"
29+
"maxSize": "32.25 kB"
3030
},
3131
{
3232
"path": "./dist/css/bootstrap.min.css",
33-
"maxSize": "30.0 kB"
33+
"maxSize": "30.25 kB"
3434
},
3535
{
3636
"path": "./dist/js/bootstrap.bundle.js",

scss/helpers/_colored-links.scss

+17-3
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,30 @@
33
// All-caps `RGBA()` function used because of this Sass bug: https://github.com/sass/node-sass/issues/2251
44
@each $color, $value in $theme-colors {
55
.link-#{$color} {
6-
--#{$prefix}link-color-rgb: #{to-rgb($value)};
7-
text-decoration-color: RGBA(to-rgb($value), var(--#{$prefix}link-underline-opacity, 1));
6+
color: RGBA(var(--#{$prefix}#{$color}-rgb, var(--#{$prefix}link-opacity, 1)));
7+
text-decoration-color: RGBA(var(--#{$prefix}#{$color}-rgb), var(--#{$prefix}link-underline-opacity, 1));
88

99
@if $link-shade-percentage != 0 {
1010
&:hover,
1111
&:focus {
1212
$hover-color: if(color-contrast($value) == $color-contrast-light, shade-color($value, $link-shade-percentage), tint-color($value, $link-shade-percentage));
13-
--#{$prefix}link-color-rgb: #{to-rgb($hover-color)};
13+
color: RGBA(#{to-rgb($hover-color)}, var(--#{$prefix}link-opacity, 1));
1414
text-decoration-color: RGBA(to-rgb($hover-color), var(--#{$prefix}link-underline-opacity, 1));
1515
}
1616
}
1717
}
1818
}
19+
20+
// One-off special link helper as a bridge until v6
21+
.link-body-emphasis {
22+
color: RGBA(var(--#{$prefix}emphasis-color-rgb), var(--#{$prefix}link-opacity, 1));
23+
text-decoration-color: RGBA(var(--#{$prefix}emphasis-color-rgb), var(--#{$prefix}link-underline-opacity, 1));
24+
25+
@if $link-shade-percentage != 0 {
26+
&:hover,
27+
&:focus {
28+
color: RGBA(var(--#{$prefix}emphasis-color-rgb), var(--#{$prefix}link-opacity, .75));
29+
text-decoration-color: RGBA(var(--#{$prefix}emphasis-color-rgb), var(--#{$prefix}link-underline-opacity, .75));
30+
}
31+
}
32+
}

site/content/docs/5.3/helpers/colored-links.md

+6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@ toc: true
1010

1111
You can use the `.link-*` classes to colorize links. Unlike the [`.text-*` classes]({{< docsref "/utilities/colors" >}}), these classes have a `:hover` and `:focus` state. Some of the link styles use a relatively light foreground color, and should only be used on a dark background in order to have sufficient contrast.
1212

13+
{{< callout info >}}
14+
**Heads up!** `.link-body-emphasis` is currently the only colored link that adapts to color modes. It's treated as a special case until v6 arrives and we can more thoroughly rebuild our theme colors for color modes. Until then, it's a unique, high-contrast link color with custom `:hover` and `:focus` styles. However, it still responds to the new link utilities.
15+
{{< /callout >}}
16+
1317
{{< example >}}
1418
{{< colored-links.inline >}}
1519
{{- range (index $.Site.Data "theme-colors") }}
1620
<p><a href="#" class="link-{{ .name }}">{{ .name | title }} link</a></p>
1721
{{- end -}}
1822
{{< /colored-links.inline >}}
23+
<p><a href="#" class="link-body-emphasis">Emphasis link</a></p>
1924
{{< /example >}}
2025

2126
{{< callout info >}}
@@ -34,4 +39,5 @@ Colored links can also be modified by our [link utilities]({{< docsref "/utiliti
3439
<p><a href="#" class="link-{{ .name }} link-offset-2 link-underline-opacity-25 link-underline-opacity-100-hover">{{ .name | title }} link</a></p>
3540
{{- end -}}
3641
{{< /colored-links.inline >}}
42+
<p><a href="#" class="link-body-emphasis link-offset-2 link-underline-opacity-25 link-underline-opacity-75-hover">Emphasis link</a></p>
3743
{{< /example >}}

0 commit comments

Comments
 (0)