-
Notifications
You must be signed in to change notification settings - Fork 1k
USWDS - Section / Dark Background: Use consistent styling for dark background links #5567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
USWDS - Section / Dark Background: Use consistent styling for dark background links #5567
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR and updating the story!
No issues or regressions found. Added suggestions for using the mixin to set the colors consistently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR.
Hope you don't mind, the change was so small I pushed up a commit to use the color setting mixin in 6db5629.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| @include set-link-from-bg( | ||
| "base-darker", | ||
| $theme-link-reverse-color, | ||
| $context: $background-context | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amyleadem good find. Yes, please create an issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened #5659 for follow-up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Thank you!
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