Files
web/apps/scandic-web/components/ContentCard/index.tsx
2025-05-19 09:13:23 +00:00

57 lines
1.4 KiB
TypeScript

import Image from "@/components/Image"
import Chip from "@/components/TempDesignSystem/Chip"
import Link from "@/components/TempDesignSystem/Link"
import Body from "@/components/TempDesignSystem/Text/Body"
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
import styles from "./contentCard.module.css"
import type { ContentCardProps } from "./contentCard"
export default function ContentCard({
heading,
image,
bodyText,
promoText,
className = "",
link,
}: ContentCardProps) {
const card = (
<article className={`${styles.card} ${className}`}>
<div className={styles.imageContainer}>
<Image
src={image.url}
alt={image.meta.alt || image.meta.caption || ""}
className={styles.image}
width={400}
height={250}
sizes="(min-width: 768px) 413px, 100vw"
focalPoint={image.focalPoint}
/>
{promoText ? (
<Chip className={styles.promoTag}>{promoText}</Chip>
) : null}
</div>
<div className={styles.content}>
<Subtitle type="two">{heading}</Subtitle>
<Body>{bodyText}</Body>
</div>
</article>
)
if (!link) return card
const linkProps = {
...(link.openInNewTab && {
target: "_blank",
rel: "noopener noreferrer",
}),
}
return (
<Link href={link.href} {...linkProps}>
{card}
</Link>
)
}