import React, { useMemo } from 'react'; import clsx from 'clsx'; import { PageGrid, PageGridCol, PageGridRow } from 'shared/components/PageGrid/page-grid'; import { TileLogo, TileLogoProps } from '../../components/TileLogo/TileLogo'; import { calculateTileOffset } from 'shared/utils/helpers'; export interface LogoItem extends TileLogoProps {} export interface LogoRectangleGridProps { /** Color variant - determines background color */ variant?: 'gray' | 'green'; /** Heading text (required) */ heading: string; /** Optional description text */ description?: string; /** Array of logo items to display in the grid */ logos: LogoItem[]; /** Additional CSS classes */ className?: string; } /** * LogoRectangleGrid Component * * A responsive grid pattern for displaying company/partner logos with rectangle tiles * and dynamic offset based on tile count. Features 9:5 aspect ratio rectangle tiles * with 2 color variants and dark mode support. * * Offset Logic (lg breakpoint only, applied to first tile): * - 1 tile: offset 9 * - 2 tiles: offset 6 * - 3 tiles: offset 3 * - 4 tiles: offset 9 * - 5 tiles: offset 6 * - 6 tiles: offset 3 * - 7 tiles: offset 9 * - 8 tiles: offset 6 * - 9 tiles: offset 3 * - 10+ tiles: no offset * * @example * // Basic usage with gray variant * * * @example * // With clickable logos * */ export const LogoRectangleGrid: React.FC = ({ variant = 'gray', heading, description, logos, className, }) => { // Build class names using BEM with bds namespace const classNames = clsx( 'bds-logo-rectangle-grid', `bds-logo-rectangle-grid--${variant}`, ); // Memoize offset calculations - only recalculate when logos array changes const logoOffsets = useMemo(() => { const total = logos.length; return logos.map((_, index) => calculateTileOffset(index, total)); }, [logos]); return ( {/* Header Section */}

{heading}

{description &&

{description}

}
{logos.map((logo, index) => { const offset = logoOffsets[index]; const hasOffset = offset.md > 0 || offset.lg > 0; return ( ); })}
); }; export default LogoRectangleGrid;