Files
web/components/TempDesignSystem/CardGrid/index.tsx
2024-05-15 09:43:29 +02:00

33 lines
709 B
TypeScript

import React, { PropsWithChildren } from "react"
import { CardGridProps } from "./cardGrid"
import { cardGridVariants } from "./variants"
export default function CardGrid({
children,
isMobileCarousel = false,
className,
}: PropsWithChildren<CardGridProps>) {
const amountOfChildren = React.Children.toArray(children).length
let variant: CardGridProps["variant"] = undefined
if (amountOfChildren % 3 === 0) {
variant = "treeColumnGrid"
} else if (amountOfChildren % 2 === 0) {
variant = "twoColumnGrid"
}
return (
<section
className={cardGridVariants({
className,
variant,
isMobileCarousel,
})}
>
{children}
</section>
)
}