feat: add CardGrid and add style to StayCard

This commit is contained in:
Christel Westerberg
2024-05-10 15:07:24 +02:00
parent 0a862ca770
commit d2eb2a3077
15 changed files with 176 additions and 106 deletions

View File

@@ -0,0 +1,32 @@
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>
)
}