Skip to content

Commit

Permalink
[Links] Show external-link icon where applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
meissadia committed Jun 25, 2024
1 parent 2e31896 commit 3d8363e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/components/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// this component could potentially be lifted with others into the DSR in a later refactor
// see: https://github.com/cfpb/sbl-frontend/issues/200

import type { LinkProperties as DesignSystemReactLinkProperties } from 'design-system-react';
import {
Link as DesignSystemReactLink,
ListLink as DesignSystemReactListLink,
} from 'design-system-react';
import { Link as DesignSystemReactLink, LinkProperties as DesignSystemReactLinkProperties, ListLink as DesignSystemReactListLink, Icon } from 'design-system-react';

const getIsLinkExternal = (url: string | undefined): boolean => {
if (url === undefined) {
Expand Down Expand Up @@ -54,13 +50,21 @@ export function Link({
isRouterLink,
...others
}: LinkProperties): JSX.Element {
const isInternalLink = getIsRouterLink(href, isRouterLink)
const icon = !isInternalLink ? <>
{' '}<Icon name="external-link" className='link-icon-override-color' />
</>
: null

return (
<DesignSystemReactLink
href={href}
isRouterLink={getIsRouterLink(href, isRouterLink)}
isRouterLink={isInternalLink}
hasIcon={!isInternalLink}
{...others}
>
{children}
{icon}
</DesignSystemReactLink>
);
}
Expand Down
15 changes: 15 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,18 @@ td:last-child{
td {
background-color: white !important;
}

/* Design System overrides */

/* Alerts - all icons in DS Alerts are colored based on the Alert type */
a .link-icon-override-color .cf-icon-svg{
@apply fill-pacific;
}

a:visited .link-icon-override-color .cf-icon-svg {
@apply fill-teal;
}

a:hover .link-icon-override-color .cf-icon-svg {
@apply !fill-pacificDark;
}

0 comments on commit 3d8363e

Please sign in to comment.