import React from 'react'; import { cn } from '../../lib/utils'; import { Container } from '../ui/Container'; // Section background options type SectionBackground = 'default' | 'light' | 'dark' | 'primary' | 'secondary' | 'gradient'; // Section padding options type SectionPadding = 'none' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'; interface SectionProps { children: React.ReactNode; background?: SectionBackground; padding?: SectionPadding; fullWidth?: boolean; className?: string; id?: string; as?: React.ElementType; } // Helper function to get background styles const getBackgroundStyles = (background: SectionBackground) => { switch (background) { case 'light': return 'bg-gray-50'; case 'dark': return 'bg-gray-900 text-white'; case 'primary': return 'bg-primary text-white'; case 'secondary': return 'bg-secondary text-white'; case 'gradient': return 'bg-gradient-to-br from-primary to-secondary text-white'; default: return 'bg-white'; } }; // Helper function to get padding styles const getPaddingStyles = (padding: SectionPadding) => { switch (padding) { case 'none': return 'py-0'; case 'sm': return 'py-4 sm:py-6'; case 'md': return 'py-8 sm:py-12'; case 'lg': return 'py-12 sm:py-16'; case 'xl': return 'py-16 sm:py-20 md:py-24'; case '2xl': return 'py-20 sm:py-24 md:py-32'; default: return 'py-12 sm:py-16'; } }; export const Section: React.FC = ({ children, background = 'default', padding = 'md', fullWidth = false, className = '', id, as: Component = 'section', }) => { const sectionClasses = cn( 'w-full', getBackgroundStyles(background), getPaddingStyles(padding), className ); const content = fullWidth ? (
{children}
) : (
{children}
); if (Component !== 'section' && !fullWidth) { return ( {children} ); } return content; }; // Sub-components for common section patterns export const SectionHeader: React.FC<{ title: string; subtitle?: string; align?: 'left' | 'center' | 'right'; className?: string; }> = ({ title, subtitle, align = 'center', className = '' }) => { const alignment = { left: 'text-left', center: 'text-center', right: 'text-right', }[align]; return (

{title}

{subtitle && (

{subtitle}

)}
); }; export const SectionContent: React.FC<{ children: React.ReactNode; className?: string; }> = ({ children, className = '' }) => (
{children}
); export const SectionGrid: React.FC<{ children: React.ReactNode; cols?: 1 | 2 | 3 | 4; gap?: 'sm' | 'md' | 'lg' | 'xl'; className?: string; }> = ({ children, cols = 3, gap = 'md', className = '' }) => { const gapClasses = { sm: 'gap-4 md:gap-6', md: 'gap-6 md:gap-8', lg: 'gap-8 md:gap-12', xl: 'gap-10 md:gap-16', }[gap]; const colClasses = { 1: 'grid-cols-1', 2: 'grid-cols-1 md:grid-cols-2', 3: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3', 4: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-4', }[cols]; return (
{children}
); }; export default Section;