import { cn } from "@/lib/utils"; import { BgColorName, bgColors, sidePlacements, VerticalPlacementName, verticalPlacements, } from "@/front/lib/constants"; import { ButtonProps, IconConfig, TextProps } from "@/types/front"; import { forwardRef, ReactNode } from "react"; import Container from "./Container"; import Button from "./Button"; import { Link } from "@inertiajs/react"; export type ButtonSectionProps = ButtonProps & { /** Button vertical placement (top or bottom). Default: bottom */ placement?: VerticalPlacementName; icon?: IconConfig; }; type Props = { variant?: BgColorName; title?: TextProps; subtitle?: TextProps; description?: TextProps; children: ReactNode; className?: string; containerClassName?: string; button?: ButtonSectionProps; }; const Section = forwardRef((props, ref) => { const { variant = bgColors.BACKGROUND, title, subtitle, description, children, className, button, containerClassName, } = props; const btnVariant = variant === bgColors.BACKGROUND ? "default" : "inverted"; const btnPlacement = (button && button.placement) ?? verticalPlacements.BOTTOM; return (
{btnPlacement === verticalPlacements.TOP && button && (
)} {(title || subtitle || description) && ( {title && (

{title.text}

)} {subtitle && (

{subtitle.text}

)} {description && (

{description.text}

)}
)}
{children}
{btnPlacement === verticalPlacements.BOTTOM && button && (
)}
); }); export default Section;