USWDS - Section / Dark Background: Use consistent styling for dark background links#5567
Conversation
amyleadem
left a comment
There was a problem hiding this comment.
Thank you for this fix! Everything looks good to me.
I tested by adding the following code to the Section - dark story and toggling the :visited element state in web inspector:
<a class="usa-link" href="http://designsystem.digital.gov">Test link</a>It would also be great to see a link added to the packages/usa-section/src/usa-section.twig file for testing, but that can be done in a follow-up PR if needed.
Sure! Not sure if you have a preference, but I adopted some content from alert stories which included a link. See 2b0bbb4. |
mejiaj
left a comment
There was a problem hiding this comment.
Thanks for the PR and updating the story!
No issues or regressions found. Added suggestions for using the mixin to set the colors consistently.
I don't mind at all Thanks for jumping in to make those changes, and apologies for being slow to respond. |
| &:hover { | ||
| color: color($theme-link-reverse-hover-color); | ||
| } | ||
| @include set-link-from-bg("base-darker"); |
There was a problem hiding this comment.
@mejiaj Out of curiosity, does switching from $theme-link-reverse-color have any impact on the effectiveness of that theme configuration? Or is that theme configuration being deprecated?
There was a problem hiding this comment.
Not deprecated, the mixin uses $theme-link-color (primary) and $theme-link-reverse-color (base-lighter) by default.
| &:hover { | ||
| color: color($theme-link-reverse-hover-color); | ||
| } | ||
| @include set-link-from-bg("base-darker"); |
There was a problem hiding this comment.
We could add $theme-link-reverse-color as the preferred link color for the mixin. This way it maintains the theme setting when appropriate but will resort to a fallback if need be
| @include set-link-from-bg("base-darker"); | |
| @include set-link-from-bg("base-darker", $theme-link-reverse-color); |
This results in a lighter link text than what's currently displayed
With preferred theme token:
There was a problem hiding this comment.
@mahoneycm, I was unable to reproduce this. The mixin uses theme link colors by default and I was still getting base-lighter as the value (for both passing and leaving out theme link reverse color).
For clarity and consistency I've added in commit d3d7656:
- A
$contextvariable for future debugging. - Explicitly passing
$theme-link-reverse-colorto avoid any confusion.
| @include set-link-from-bg( | ||
| "base-darker", | ||
| $theme-link-reverse-color, | ||
| $context: $background-context | ||
| ); |
There was a problem hiding this comment.
@mejiaj One small note with this approach is that set-link-from-bg sets both :hover and :active states to the $theme-link-reverse-hover-color token. This means that $theme-link-reverse-active-color is ignored here.
I think using the mixin is a reasonable approach for this PR and don't think this should be a blocker, but I am curious why set-link-from-bg doesn't distinguish an active color. Should we create a follow-up issue to explore updating the related mixins to define active states?
/* Before set-link-from-bg*/
.usa-section--dark a:hover{
color:#f0f0f0;
}
.usa-section--dark a:active{
color:white;
}
/* After set-link-from-bg*/
.usa-dark-background a:hover, .usa-dark-background a:active{
color:#f0f0f0;
}There was a problem hiding this comment.
@amyleadem good find. Yes, please create an issue.
There was a problem hiding this comment.
I believe the reason why this ignores active is to allow the original link color to be lighter (since there are fewer lightening steps to account for without active).
Summary
Use consistent link styling for links in dark background content. Previously,
usa-section--darkandusa-dark-backgrounddid not have consistent styling for links.Related discussion
See related discussion in our application at GSA-TTS/identity-dev-docs#367 (comment)
Solution
Provides the complete set of link pseudo classes between
usa-section--darkandusa-dark-background:Before:
usa-section--darkusa-dark-background:hover:active:visitedAfter:
usa-section--darkusa-dark-background:hover:active:visited