Skip to content

Commit

Permalink
fix(links): open external links in new tab
Browse files Browse the repository at this point in the history
  • Loading branch information
bsahitya committed Aug 13, 2024
1 parent 80e5566 commit 956b84b
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 9 deletions.
9 changes: 7 additions & 2 deletions libs/react-components/src/lib/components/Card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,18 @@ const Card: React.FC<CardProps> = ({
imageAltText,
imageDirection = 'left',
imageSrc,
imageWidth = '35%',
imageWidth = '350px',
title,
}) => {
return (
<div className={`${styles.card} ${styles[imageDirection]}`}>
{imageSrc && (
<div className={styles.cardImage} style={{ flex: `0 0 ${imageWidth}` }}>
<div
className={styles.cardImage}
style={
{ '--td-web-card-img-width': imageWidth } as React.CSSProperties
}
>
<img src={imageSrc} alt={imageAltText} />
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
}

.cardImage {
flex: 0 0 350px;
flex: 0 0 var(--td-web-card-img-width);

img {
display: block;
Expand Down
7 changes: 6 additions & 1 deletion libs/react-components/src/lib/components/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ export const FooterNavLinkItem: React.FC<FooterNavLink> = ({
}) => {
return (
<li className={styles.footerLinkItem}>
<a href={href} className={styles.footerNavLink}>
<a
href={href}
className={styles.footerNavLink}
target={external ? '_blank' : '_self'}
rel="noreferrer"
>
{label}
{external && (
<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
display: flex;
flex-wrap: wrap;
gap: 1rem 0.75rem;
padding-top: 1rem;
}

.legalLinksWrapper {
Expand Down
7 changes: 5 additions & 2 deletions libs/react-components/src/lib/components/NavItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const NavItem: React.FC<NavItemProps> = ({
href,
nestedNavItems = [],
label,
external,
onClick,
onMenuChange,
}) => {
Expand Down Expand Up @@ -120,7 +121,8 @@ const NavItem: React.FC<NavItemProps> = ({
>
<a
href={item.href}
target="_self"
target={item.external ? '_blank' : '_self'}
rel="noreferrer"
className={`${item.external ? styles.externalLink : ''} ${
item.active ? styles.active : ''
}`}
Expand All @@ -143,7 +145,8 @@ const NavItem: React.FC<NavItemProps> = ({
) : (
<a
href={href}
target="_self" // TODO: remove this
target={external ? '_blank' : '_self'}
rel="noreferrer"
className={`${styles.navItemLink} ${active ? styles.active : ''}`}
onClick={handleClick}
>
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"version": "1.9.0",
"license": "MIT",
"scripts": {
"semantic-release": "semantic-release --branches main",
"build-storybook": "nx run react-components:build-storybook",
"format:check": "nx format",
"release:prepare": "npx nx run-many --target=build --all && node ./scripts/version-placeholder ./dist"
"release:prepare": "npx nx run-many --target=build --all && node ./scripts/version-placeholder ./dist",
"semantic-release": "semantic-release --branches main",
"storybook": "nx run react-components:storybook"
},
"dependencies": {
"react": "18.3.1",
Expand Down

0 comments on commit 956b84b

Please sign in to comment.