Skip to content

USWDS - Links: External link labels #5166

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

Merged
merged 16 commits into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/usa-link/src/usa-link.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

<p>This is <a class="usa-link usa-color-text-visited" href="javascript:void(0);">a visited link</a>.</p>

<p>This is a link that goes to an <a class="usa-link usa-link--external" href="https://i.giphy.com/media/WPzQF6ruiIIVzHNlwX/source.gif">external website</a>.</p>
<p>
This is a link that opens in the <em>current</em> tab and goes to an <a class="usa-link usa-link--external" rel="noreferrer" href="https://i.giphy.com/media/WPzQF6ruiIIVzHNlwX/source.gif">external website</a>.
</p>

<p>
This is a link that opens in a <em>new</em> tab and goes to an <a class="usa-link usa-link--external" rel="noreferrer" target="_blank" href="https://i.giphy.com/media/WPzQF6ruiIIVzHNlwX/source.gif">external website</a>.
</p>

<div class="usa-dark-background padding-1 display-inline-block">
<p>This is <a class="usa-link" href="javascript:void(0);">a text link on a dark background</a>.</p>
<p><a class="usa-link usa-link--alt usa-link--external" href="https://i.giphy.com/media/WPzQF6ruiIIVzHNlwX/source.gif">This</a> is an alternate external text link on a dark background.</p>
<p><a class="usa-link usa-link--alt usa-link--external" rel="noreferrer" href="https://i.giphy.com/media/WPzQF6ruiIIVzHNlwX/source.gif">This</a> is an alternate external text link on a dark background.</p>
</div>
13 changes: 13 additions & 0 deletions packages/uswds-core/src/styles/mixins/general/external-link.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@use "../../settings" as *;
@use "./icon" as *;
@use "../../functions" as *;
@use "./screen-reader" as *;

$external-link-size: 1.75ex;

Expand All @@ -16,6 +18,17 @@ $icon-object: (
@mixin external-link($contrast-bg: "default") {
display: inline;

// Screen reader label
&::before {
@include sr-only;
content: $theme-external-link-sr-label-tab-same;
}

&[target="_blank"]::before {
@include sr-only;
content: $theme-external-link-sr-label-tab-new;
}

&::after {
@include add-color-icon($icon-object, $contrast-bg);
content: "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ $theme-in-page-nav-margin-left: 4 !default;
$theme-in-page-nav-margin-top: 2.5 !default;
$theme-in-page-nav-top: 4 !default;

// Link
$theme-external-link-sr-label-tab-new: "External, opens in a new tab." !default;
$theme-external-link-sr-label-tab-same: "External." !default;

// Modal
$theme-modal-border-radius: "lg" !default;
$theme-modal-default-max-width: "mobile-lg" !default;
Expand Down