import { Slot } from "@radix-ui/react-slot"

import { captionVariants, fontOnlycaptionVariants } from "./variants"

import type { CaptionProps } from "./caption"

export default function Caption({
  asChild = false,
  className = "",
  color,
  fontOnly = false,
  textAlign,
  textTransform,
  uppercase,
  type,
  ...props
}: CaptionProps) {
  const Comp = asChild ? Slot : "p"
  const classNames = fontOnly
    ? fontOnlycaptionVariants({
        className,
        textTransform,
        uppercase,
        type,
      })
    : captionVariants({
        className,
        color,
        textTransform,
        textAlign,
        uppercase,
        type,
      })
  return <Comp className={classNames} {...props} />
}
