import { cva, type VariantProps } from "class-variance-authority";
import React from "react";

import { cn } from "@/lib/utils";

export const containerVariants = cva("p-6", {
  variants: {
    variant: {
      full: "w-full",
      boxed: "container max-w-3xl lg:max-w-5xl mx-auto",
    },
  },
  defaultVariants: {
    variant: "full",
  },
});

export interface ContainerProps
  extends React.HTMLAttributes<HTMLDivElement>,
    VariantProps<typeof containerVariants> {
  as?: React.ElementType;
}

export const Container = ({
  className,
  as: Comp = "article",
  variant,
  ...props
}: ContainerProps) => <Comp className={cn(containerVariants({ variant, className }))} {...props} />;

Container.displayName = "Container";
