Skip to content

USWDS - Section / Dark Background: Use consistent styling for dark background links#5567

Merged
thisisdano merged 4 commits into
uswds:developfrom
aduth:aduth-consistent-dark-background-links
Dec 6, 2023
Merged

USWDS - Section / Dark Background: Use consistent styling for dark background links#5567
thisisdano merged 4 commits into
uswds:developfrom
aduth:aduth-consistent-dark-background-links

Conversation

@aduth

@aduth aduth commented Oct 18, 2023

Copy link
Copy Markdown
Contributor

Summary

Use consistent link styling for links in dark background content. Previously, usa-section--dark and usa-dark-background did 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--dark and usa-dark-background:

Before:

State usa-section--dark usa-dark-background
Initial
:hover
:active
:visited

After:

State usa-section--dark usa-dark-background
Initial
:hover
:active
:visited

@amyleadem amyleadem left a comment

Copy link
Copy Markdown
Contributor

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>

Before:
image

After:
image

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.

@aduth

aduth commented Nov 20, 2023

Copy link
Copy Markdown
Contributor Author

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 mejiaj left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread packages/usa-dark-background/src/styles/_usa-dark-background.scss
Comment thread packages/usa-section/src/styles/_usa-section.scss
@mejiaj mejiaj self-requested a review December 5, 2023 15:58

@mejiaj mejiaj left a comment

Copy link
Copy Markdown
Contributor

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.

@mejiaj mejiaj requested a review from amyleadem December 5, 2023 16:00
@aduth

aduth commented Dec 5, 2023

Copy link
Copy Markdown
Contributor Author

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");

Copy link
Copy Markdown
Contributor Author

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?

Copy link
Copy Markdown
Contributor

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");

Copy link
Copy Markdown
Contributor

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

Suggested change
@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

Current:
Screenshot 2023-12-05 at 3 18 07 PM

With preferred theme token:

Screenshot 2023-12-05 at 3 17 41 PM

@mejiaj mejiaj Dec 6, 2023

Copy link
Copy Markdown
Contributor

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:

  1. A $context variable for future debugging.
  2. Explicitly passing $theme-link-reverse-color to avoid any confusion.

@mejiaj mejiaj requested a review from mahoneycm December 6, 2023 15:02

@mahoneycm mahoneycm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm! Thanks @aduth and @mejiaj !

@amyleadem amyleadem left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates @aduth and @mejiaj! Looks good to me. I had a small note about defining the active state with set-link-from-bg, but I don't think it should be a blocker because all link states are now legible.

Before (:visited state)

image

After (:visited state)

image

Comment on lines +14 to +18
@include set-link-from-bg(
"base-darker",
$theme-link-reverse-color,
$context: $background-context
);

Copy link
Copy Markdown
Contributor

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;
}

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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).

@thisisdano thisisdano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thank you!

@thisisdano thisisdano merged commit e9cc7ca into uswds:develop Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants