Files
web/components/TempDesignSystem/TeaserCard/index.tsx
2024-10-21 14:22:00 +02:00

93 lines
2.6 KiB
TypeScript

import Image from "@/components/Image"
import Button from "@/components/TempDesignSystem/Button"
import Link from "@/components/TempDesignSystem/Link"
import Body from "@/components/TempDesignSystem/Text/Body"
import Subtitle from "../Text/Subtitle"
import TeaserCardSidepeek from "./Sidepeek"
import { teaserCardVariants } from "./variants"
import styles from "./teaserCard.module.css"
import type { TeaserCardProps } from "@/types/components/teaserCard"
export default function TeaserCard({
title,
description,
primaryButton,
secondaryButton,
sidePeekButton,
sidePeekContent,
image,
style = "default",
alwaysStack = false,
className,
}: TeaserCardProps) {
const cardClasses = teaserCardVariants({ style, alwaysStack, className })
return (
<article className={cardClasses}>
{image && (
<div className={styles.imageContainer}>
<Image
src={image.url}
alt={image.meta?.alt || ""}
className={styles.backgroundImage}
width={399}
height={201}
focalPoint={image.focalPoint}
/>
</div>
)}
<div className={styles.content}>
<Subtitle textAlign="left" type="two" color="black">
{title}
</Subtitle>
<Body color="black" className={styles.body}>
{description}
</Body>
{sidePeekButton && sidePeekContent ? (
<TeaserCardSidepeek
button={sidePeekButton}
sidePeekContent={sidePeekContent}
/>
) : (
<div className={styles.ctaContainer}>
{primaryButton && (
<Button
asChild
intent="primary"
size="small"
className={styles.ctaButton}
>
<Link
href={primaryButton.href}
target={primaryButton.openInNewTab ? "_blank" : undefined}
color="none"
>
{primaryButton.title}
</Link>
</Button>
)}
{secondaryButton && (
<Button
asChild
intent="secondary"
size="small"
className={styles.ctaButton}
>
<Link
href={secondaryButton.href}
target={secondaryButton.openInNewTab ? "_blank" : undefined}
>
{secondaryButton.title}
</Link>
</Button>
)}
</div>
)}
</div>
</article>
)
}