import React from 'react'; import clsx from 'clsx'; import { Button } from '../../components/Button/Button'; import { PageGrid } from '../../components/PageGrid/page-grid'; export interface FeatureTwoColumnLink { /** Link label text */ label: string; /** Link URL */ href: string; } export interface FeatureTwoColumnProps { /** Color theme variant */ color?: 'neutral' | 'lilac' | 'yellow' | 'green'; /** Content arrangement - left places content on left side, right places content on right side */ arrange?: 'left' | 'right'; /** Feature title text (heading-md typography) */ title: string; /** Feature description text (body-l typography) */ description: string; /** Array of links (1-5 links supported) * - 1 link: renders as secondary button * - 2 links: renders as primary + tertiary buttons * - 3-5 links: renders all as tertiary buttons */ links: FeatureTwoColumnLink[]; /** Feature media (image) configuration */ media: { src: string; alt: string; }; /** Additional CSS classes */ className?: string; } /** * FeatureTwoColumn Pattern * * A feature section pattern that pairs editorial content with a media element * in a two-column layout. Designed for showcasing features, products, or use cases. * * Uses the PageGrid component system for responsive layout: * - Mobile: Stacked layout (content above media) * - Tablet: Stacked layout (content above media) * - Desktop: Side-by-side (6/12 columns each) * * Button behavior based on link count: * - 1 link: Secondary button * - 2 links: Primary button (first) + Tertiary button (second) * - 3-5 links: All tertiary buttons (first is filled, rest are text-only) */ export const FeatureTwoColumn: React.FC = ({ color = 'neutral', arrange = 'left', title, description, links = [], media, className, }) => { // Build root class names const rootClasses = clsx( 'bds-feature-two-column', `bds-feature-two-column--${color}`, `bds-feature-two-column--${arrange}`, className ); // Determine button color based on background // Rule: Black buttons must be used for all backgrounds (including neutral) const buttonColor = 'black'; const forceColor = true; // Render content section with appropriate CTA layout based on link count // For 3-5 links, items are direct children for space-between distribution const renderContent = () => { const linkCount = links.length; // 1 link: Secondary button if (linkCount === 1) { return (

{title}

{description}

); } // 2 links: Primary + Tertiary in a row if (linkCount === 2) { return (

{title}

{description}

); } // 3-5 links: Text group + Button group (contains all buttons with consistent 16px spacing) // Desktop: space-between distribution between text-group and button-group // Tablet: 32px gap, Mobile: 24px gap return (

{title}

{description}

{/* Button group - all buttons grouped with 16px spacing between them */}
{/* First two links in a row: Primary + Tertiary */}
{links[1] && ( )}
{/* Secondary button */} {links[2] && ( )} {/* Remaining tertiary links */} {links.slice(3).map((link) => ( ))}
); }; // Render media section (for mobile/tablet stacked layout) const renderMedia = () => (
{media.alt}
); return (
{/* Desktop layout - simple two-column flex with background image */}
{renderContent()}
{/* Mobile/Tablet layout - stacked with PageGrid */}
{renderContent()}
{renderMedia()}
); }; export default FeatureTwoColumn;