import React from "react"; import clsx from "clsx"; import { PageGrid } from "../../components/PageGrid/page-grid"; import StandardCard, { StandardCardPropsWithoutVariant, StandardCardVariant, } from "../../components/StandardCard"; import { getCardKey, getTextFromChildren, isEnvironment } from "../../utils"; // Re-export types for convenience export type { StandardCardPropsWithoutVariant, StandardCardVariant }; /** * Props for the StandardCardGroupSection pattern component */ export interface StandardCardGroupSectionProps extends React.ComponentPropsWithoutRef<"section"> { /** Section headline text */ headline: React.ReactNode; /** Section description text */ description: React.ReactNode; /** Background color variant applied uniformly to all cards */ variant: StandardCardVariant; /** Array of StandardCard configurations (variant is omitted and applied uniformly) */ cards: readonly StandardCardPropsWithoutVariant[]; } /** * StandardCardGroupSection Pattern Component * * A section pattern that displays a headline, description, and a responsive grid * of StandardCard components. All cards share a uniform variant determined by the section. * * Features: * - Responsive grid layout (1 column mobile, 3 columns tablet and desktop) * - Headline and description with consistent typography * - Uniform variant applied to all cards * - Proper spacing using PageGrid for container and alignment * - Full dark mode support * * @example * ```tsx * * ``` */ export const StandardCardGroupSection = React.forwardRef< HTMLElement, StandardCardGroupSectionProps >((props, ref) => { const { headline, description, variant, cards, className, ...rest } = props; // Early return for empty cards array if (cards.length === 0) { if (isEnvironment("development")) { console.error("StandardCardGroupSection: No cards provided"); } return null; } return (
{/* Header content row */}
{headline && (

{headline}

)} {description && (
{description}
)}
{/* Cards grid row */} {cards .map((card, index) => { const headlineStr = typeof card.headline === "string" ? card.headline : getTextFromChildren(card.headline) || undefined; return { card, index, headlineStr }; }) .map(({ card, index, headlineStr }) => { if (!card.headline) { if (isEnvironment("development")) { console.warn( "StandardCardGroupSection: Card has no headline", ); } return null; } return ( ); })}
); }); StandardCardGroupSection.displayName = "StandardCardGroupSection"; export default StandardCardGroupSection;