import Title from "@/components/Title"

import Button from "../Button"
import Link from "../Link"
import { CardProps } from "./card"

import styles from "./card.module.css"

export default function Card({
  link,
  subtitle,
  title,
  openInNewTab = false,
}: CardProps) {
  return (
    <article className={styles.linkCard}>
      {title ? (
        <Title level="h3" weight="semiBold">
          {title}
        </Title>
      ) : null}
      {subtitle ? (
        <Title level="h5" weight="light">
          {subtitle}
        </Title>
      ) : null}
      {link ? (
        <Button asChild intent="primary">
          <Link href={link.href} target={openInNewTab ? "_blank" : undefined}>
            {link.title}
          </Link>
        </Button>
      ) : null}
    </article>
  )
}
