Merged in fix/use-link-component-content-card (pull request #1899)
fix: use link component for all types of links to add proper styling to set text decoration none when external Approved-by: Chuma Mcphoy (We Ahead)
This commit is contained in:
@@ -12,10 +12,3 @@ export interface ContentCardProps {
|
||||
promoText?: string
|
||||
className?: string
|
||||
}
|
||||
|
||||
export interface ContentCardLinkProps {
|
||||
href: string
|
||||
openInNewTab?: boolean
|
||||
isExternal?: boolean
|
||||
children: React.ReactNode
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
|
||||
|
||||
import styles from "./contentCard.module.css"
|
||||
|
||||
import type { ContentCardLinkProps, ContentCardProps } from "./contentCard"
|
||||
import type { ContentCardProps } from "./contentCard"
|
||||
|
||||
export default function ContentCard({
|
||||
heading,
|
||||
@@ -40,31 +40,16 @@ export default function ContentCard({
|
||||
|
||||
if (!link) return card
|
||||
|
||||
return (
|
||||
<ContentCardLink
|
||||
href={link.href}
|
||||
openInNewTab={link.openInNewTab}
|
||||
isExternal={link.isExternal}
|
||||
>
|
||||
{card}
|
||||
</ContentCardLink>
|
||||
)
|
||||
}
|
||||
|
||||
function ContentCardLink({
|
||||
children,
|
||||
href,
|
||||
openInNewTab,
|
||||
isExternal,
|
||||
}: ContentCardLinkProps) {
|
||||
const Component = isExternal ? "a" : Link
|
||||
const linkProps = {
|
||||
href,
|
||||
...(openInNewTab && {
|
||||
...(link.openInNewTab && {
|
||||
target: "_blank",
|
||||
rel: "noopener noreferrer",
|
||||
}),
|
||||
}
|
||||
|
||||
return <Component {...linkProps}>{children}</Component>
|
||||
return (
|
||||
<Link href={link.href} {...linkProps}>
|
||||
{card}
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user