-
Notifications
You must be signed in to change notification settings - Fork 1k
USWDS - Links: Fix external link icon issues #5046
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
Conversation
- Add SassDoc comments to mixin - Allow user to set positioning in icon object
- Remove non-breaking space in favor of margin-left - Use padding-left for creating icon width - Improve alignment via vertical align middle
@@ -77,7 +77,9 @@ | |||
// ($base, $variant, $variant-alt, $bg) | |||
// the mixin will pick IE11-compatible svgs named | |||
// [base]-[variant].svg based on the specified background-color | |||
|
|||
// | |||
// @param {Map} - $icon-object - name, svg-height, svg-width, height, container-height, container-width, color, color-variant, color-hover, rotate, path, background-p |
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.
Added Sassdoc style comments to document the types of things $icon-object
accepts in this mixin.
$position-y: if( | ||
map.has-key($icon-object, "position-y"), | ||
map.get($icon-object, "position-y"), | ||
bottom | ||
); | ||
$position-x: if( | ||
map.has-key($icon-object, "position-x"), | ||
map.get($icon-object, "position-x"), | ||
center | ||
); |
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.
New settings to allow user more control over icon positioning for background/mask image.
Defaults for both are center
.
mask-position: $position-x $position-y; | ||
mask-size: $width $height; | ||
mask-repeat: no-repeat; | ||
|
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.
Stopped using shorthands for background and mask properties to allow user more control in overrides.
I'm not certain, but I believe A potential solution is to use |
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
Nice fix! I like the ability to customize positioning.
Everything seems to be behaving in Firefox, Chrome, and Edge. I did notice that Safari is still showing icon line breaks in the footer and identifier. However, I do not see the same issue in any of the external links in the main content of the links page in Safari.
I noticed that if I delete this extra space in the html via inspector, it resolves the issue. So I suspect this is more of an issue with uswds-site markup, but wanted to flag it for your consideration in case something else is at play.
- There shouldn't be any visual regressions in external links
- There shouldn't be any visual regressions with external links in Safari
- There shouldn't be any visual regressions in external link background image fallback
- Punctuation shouldn't break into it's own line following external link
- External link icon shouldn't break into it's own line
Hey @jhancock532, thanks for taking a look at this PR. Were you experiencing the same issues in the test preview for the site? If so, would you mind sharing what OS and browser (with version) you used? I'll also take a look at that spacing issue you mentioned @amyleadem, thanks! |
@mejiaj I was testing this on MacOS Monterey with the latest version of Firefox at that time (107), but I'm unable to replicate this issue using Firefox and the testing site. I think the code changes you've made here have resolved the problem. |
Fantastic, thanks for checking @jhancock532. |
@amyleadem after looking into it some more these whitespaces are specific to site. Created a separate issue for identifier links uswds/uswds-site#1928. I'll push a fix and re-request review. Good find! |
This PR is ready for review. The safari whitespace issue in identifier links has been fixed in uswds/uswds-site@dbb6795. This PR must be merged before the site PR. |
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.
Looks good!
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.
This is an important fix. Nice work!
Description
uswds-1918-2022-11-21.at.14.50.09.webm
Fixed icon wrapping and safari display issues in external links. Improved wrapping so icon doesn't break on its own and causes display issues with punctuation. There's also an improved way for getting around Safari display issues (transparent gradient). Closes #4977.
add-color-icon
mixin now allows more control over positioning. The$icon-object
that gets passed toadd-color-icon
mixin now takes attributes for x and y positioning. These are used for both background and mask positioning.Defaults
Additional information
This has been a tricky issue to debug and fix. The original attempt (#3395) later caused a background bleed issue in Safari (#4439). Now both issues should be resolved.
Link and icon wrapping bug
Both the link and pseudoelement have been made inline elements. The icon sizing is controlled via
padding-left
and background/mask size.Safari display bug
Icon with transparent gradient on mask

Background bleeding has been resolved by adding a transparent linear gradient to masks.
Related issues
Browsers tested
How to test
I've also created a test branch in Site you can use for additional testing.
Before you hit Submit, make sure you’ve done whichever of these applies to you:
npm test
and make sure the tests for the files you have changed have passed.