import { Children, ReactNode, ReactElement, cloneElement } from 'react'; import { clsx } from 'clsx'; import { LandingBlogPost } from '@/components/landing/blog/LandingBlogPost'; type Child = ReactElement; // eslint-disable-line @typescript-eslint/no-explicit-any /** * A blog list component displays a responsive grid of blog posts. */ export const LandingBlogList = ({ children, title, titleComponent, description, descriptionComponent, className, variant = 'primary', withBackground = false, withBackgroundGlow = false, backgroundGlowVariant = 'primary', textPosition = 'left', display = 'list', }: { children: ReactNode; title?: string; titleComponent?: ReactNode; description?: string; descriptionComponent?: ReactNode; className?: string; variant?: 'primary' | 'secondary'; withBackground?: boolean; withBackgroundGlow?: boolean; backgroundGlowVariant?: 'primary' | 'secondary'; textPosition?: 'center' | 'left'; display?: 'grid' | 'list'; }) => { const childrenWithProps = 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 === LandingBlogPost ? { imagePosition: display === 'grid' ? 'center' : 'right' } : {}), }); }); return (
{withBackgroundGlow ? (
) : null}
{(title || titleComponent) && (
{title ? (

{title}

) : ( titleComponent )} {description ? (

{description}

) : ( descriptionComponent )}
)}
{childrenWithProps}
); };