Skip to content

Commit

Permalink
feat(colored links): restrict to primary and light, and ensure contrasts
Browse files Browse the repository at this point in the history
  • Loading branch information
ffoodd committed Apr 8, 2020
1 parent af31c78 commit 104e43c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
23 changes: 17 additions & 6 deletions scss/helpers/_colored-links.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
@each $color, $value in $theme-colors {
.link-#{$color} {
color: $value;
// Boosted mod: restrict to primary and light and ensure contrast
@if ($value == $primary) or ($value == $light) {
$contrast: color-contrast($value);

@if $emphasized-link-hover-darken-percentage != 0 {
&:hover,
&:focus {
color: darken($value, $emphasized-link-hover-darken-percentage);
.link-#{$color} {
color: $value;
background-color: $contrast;

@if $emphasized-link-hover-darken-percentage != 0 {
&:hover,
&:focus {
@if $contrast == $white {
color: darken($value, $emphasized-link-hover-darken-percentage);
} @else {
color: lighten($value, $emphasized-link-hover-darken-percentage);
}
}
}
}
}
// End mod
}
7 changes: 2 additions & 5 deletions site/content/docs/4.3/helpers/colored-links.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ toc: false
You can use the `.link-*` classes to colorize links. Unlike the [`.text-*` classes]({{< docsref "/utilities/colors#colors" >}}), these classes have a `:hover` and `:focus` state.

{{< example >}}
{{< colored-links.inline >}}
{{- range (index $.Site.Data "theme-colors") }}
<a href="#" class="link-{{ .name }}">{{ .name | title }} link</a>
{{- end -}}
{{< /colored-links.inline >}}
<a href="#" class="link-primary">Primary link</a>
<a href="#" class="link-light">Light link</a>
{{< /example >}}

0 comments on commit 104e43c

Please sign in to comment.