import clsx from 'clsx'; import { GlowBg } from '@/components/shared/ui/glow-bg'; import React, { Children, cloneElement, ReactElement } from 'react'; import { LandingPriceComparisonColumn } from '@/components/landing/pricing-comparison/LandingPriceComparisonColumn'; type Child = ReactElement; // eslint-disable-line @typescript-eslint/no-explicit-any /** * A component meant to be used in the landing page. * It shows a price comparison section with a title, description, and can render columns of product comparisons. * Supports 2-5 columns for product comparison. */ export const LandingPriceComparisonSection = ({ children, className, title, titleComponent, description, descriptionComponent, textPosition = 'center', withBackground = false, withBackgroundGlow = false, variant = 'primary', backgroundGlowVariant = 'primary', }: { children?: React.ReactNode; className?: string; title?: string | React.ReactNode; titleComponent?: React.ReactNode; description?: string | React.ReactNode; descriptionComponent?: React.ReactNode; textPosition?: 'center' | 'left'; withBackground?: boolean; withBackgroundGlow?: boolean; variant?: 'primary' | 'secondary'; backgroundGlowVariant?: 'primary' | 'secondary'; }) => { const columnNumber = React.Children.count(children); const childrenWithProps = Children.map(children, (child, index) => { if (!child) { return null; } if (typeof child !== 'object') { return child; } const reactChild = child as Child; const reactChildType = reactChild?.type; if (reactChildType === LandingPriceComparisonColumn) { return cloneElement(reactChild, { variant, }); } return child; }); return (
{withBackgroundGlow ? (
) : null}
{title ? (

{title}

) : ( titleComponent )} {description ? (

{description}

) : ( descriptionComponent )}
5 ? 'grid-cols-5' : '', 'min-w-0', )} style={{ gridTemplateColumns: columnNumber > 5 ? 'repeat(5, minmax(200px, 1fr))' : undefined, }} > {childrenWithProps}
); };