Skip to content

Commit ce2d3b0

Browse files
committed
[Links] Show external-link icon where applicable
1 parent a4aaaac commit ce2d3b0

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

src/components/Link.tsx

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
// this component could potentially be lifted with others into the DSR in a later refactor
22
// see: https://github.com/cfpb/sbl-frontend/issues/200
33

4-
import type { LinkProperties as DesignSystemReactLinkProperties } from 'design-system-react';
5-
import {
6-
Link as DesignSystemReactLink,
7-
ListLink as DesignSystemReactListLink,
8-
} from 'design-system-react';
4+
import { Link as DesignSystemReactLink, LinkProperties as DesignSystemReactLinkProperties, ListLink as DesignSystemReactListLink, Icon } from 'design-system-react';
95

106
const getIsLinkExternal = (url: string | undefined): boolean => {
117
if (url === undefined) {
@@ -59,15 +55,23 @@ export function Link({
5955
const isInternalLink = getIsRouterLink(href, isRouterLink);
6056
const otherProperties: LinkProperties = { ...others };
6157

62-
if (!isInternalLink) otherProperties.target = '_blank'; // Open link in new tab
58+
let icon = null
59+
if (!isInternalLink) {
60+
otherProperties.target = '_blank'; // Open link in new tab
61+
icon =<>
62+
{' '}<Icon name="external-link" className='link-icon-override-color' />
63+
</>
64+
}
6365

6466
return (
6567
<DesignSystemReactLink
6668
href={href}
6769
isRouterLink={isInternalLink}
70+
hasIcon={!isInternalLink}
6871
{...otherProperties}
6972
>
7073
{children}
74+
{icon}
7175
</DesignSystemReactLink>
7276
);
7377
}

src/index.css

+15
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,18 @@ td:last-child{
123123
td {
124124
background-color: white !important;
125125
}
126+
127+
/* Design System overrides */
128+
129+
/* Alerts - all icons in DS Alerts are colored based on the Alert type */
130+
a .link-icon-override-color .cf-icon-svg{
131+
@apply fill-pacific;
132+
}
133+
134+
a:visited .link-icon-override-color .cf-icon-svg {
135+
@apply fill-teal;
136+
}
137+
138+
a:hover .link-icon-override-color .cf-icon-svg {
139+
@apply !fill-pacificDark;
140+
}

0 commit comments

Comments
 (0)