import { LandingProductFeature } from '@/components/landing/LandingProductFeature'; import { LandingProductVideoFeature } from '@/components/landing/LandingProductVideoFeature'; import { GlowBg } from '@/components/shared/ui/glow-bg'; import clsx from 'clsx'; import { Children, ReactElement, cloneElement } from 'react'; type Child = ReactElement; // eslint-disable-line @typescript-eslint/no-explicit-any /** * A component meant to be used in the landing page. * It displays a title, description and a grid of LandingProductFeature and/or LandingProductVideoFeature (in any combination, passed as children). */ export const LandingProductFeaturesGrid = ({ className, children, title, titleComponent, description, descriptionComponent, withBackground = true, withBackgroundGlow = false, variant = 'primary', backgroundGlowVariant = 'primary', containerType = 'ultrawide', numberOfColumns, }: { className?: string; children?: React.ReactNode; title?: string | React.ReactNode; titleComponent?: React.ReactNode; description?: string | React.ReactNode; descriptionComponent?: React.ReactNode; withBackground?: boolean; withBackgroundGlow?: boolean; variant?: 'primary' | 'secondary'; backgroundGlowVariant?: 'primary' | 'secondary'; containerType?: 'narrow' | 'wide' | 'ultrawide'; numberOfColumns?: number; }) => { const childrenCount = Children.count(children); const childrenWithBackground = Children.map(children, (child) => { if (!child) { return null; } if (typeof child !== 'object') { return child; } const reactChild = child as Child; const reactChildType = reactChild?.type; return cloneElement(reactChild, { className: '!p-0 rounded-xl'.concat( variant === 'primary' ? ' fancy-glass' : ' fancy-glass-contrast', ), minHeight: 0, innerClassName: 'p-4 lg:p-10 m-0 lg:m-0 h-full'.concat( variant === 'primary' ? ' bg-primary-100/20 dark:bg-primary-900/10' : ' bg-secondary-100/20 dark:bg-secondary-900/10', ), ...(reactChildType === LandingProductFeature ? { imagePosition: 'center', imageShadow: 'none' } : {}), ...(reactChildType === LandingProductVideoFeature ? { videoPosition: 'center' } : {}), }); }); return (
{withBackgroundGlow ? (
) : null} {title || description || titleComponent || descriptionComponent ? (
{title ? (

{title}

) : ( titleComponent )} {description ? (

{description}

) : ( descriptionComponent )}
) : null}
{childrenWithBackground}
); };