import React from 'react'; import Image from 'next/image'; import { cn } from '../../lib/utils'; import { Container } from '../ui/Container'; import { Button } from '../ui/Button'; // Hero height options type HeroHeight = 'sm' | 'md' | 'lg' | 'xl' | 'full'; // Hero variant options type HeroVariant = 'default' | 'dark' | 'primary' | 'gradient'; interface HeroProps { title: string; subtitle?: string; backgroundImage?: string; backgroundAlt?: string; height?: HeroHeight; variant?: HeroVariant; ctaText?: string; ctaLink?: string; ctaVariant?: 'primary' | 'secondary' | 'outline'; overlay?: boolean; overlayOpacity?: number; children?: React.ReactNode; className?: string; } // Helper function to get height styles const getHeightStyles = (height: HeroHeight) => { switch (height) { case 'sm': return 'min-h-[300px] md:min-h-[400px]'; case 'md': return 'min-h-[400px] md:min-h-[500px]'; case 'lg': return 'min-h-[500px] md:min-h-[600px]'; case 'xl': return 'min-h-[600px] md:min-h-[700px]'; case 'full': return 'min-h-screen'; default: return 'min-h-[500px] md:min-h-[600px]'; } }; // Helper function to get variant styles const getVariantStyles = (variant: HeroVariant) => { switch (variant) { case 'dark': return 'bg-gray-900 text-white'; case 'primary': return 'bg-primary text-white'; case 'gradient': return 'bg-gradient-to-br from-primary to-secondary text-white'; default: return 'bg-gray-800 text-white'; } }; // Helper function to get overlay opacity const getOverlayOpacity = (opacity?: number) => { if (opacity === undefined) return 'bg-black/50'; if (opacity >= 1) return 'bg-black'; if (opacity <= 0) return 'bg-transparent'; return `bg-black/${Math.round(opacity * 100)}`; }; export const Hero: React.FC = ({ title, subtitle, backgroundImage, backgroundAlt = '', height = 'md', variant = 'default', ctaText, ctaLink, ctaVariant = 'primary', overlay = true, overlayOpacity, children, className = '', }) => { const hasBackground = !!backgroundImage; const hasCTA = !!ctaText && !!ctaLink; return (
{/* Background Image */} {hasBackground && (
{backgroundAlt
)} {/* Background Variant (if no image) */} {!hasBackground && (
)} {/* Overlay */} {overlay && hasBackground && (
)} {/* Content */}
{/* Title */}

{title}

{/* Subtitle */} {subtitle && (

{subtitle}

)} {/* CTA Button */} {hasCTA && (
)} {/* Additional Content */} {children && (
{children}
)}
); }; // Sub-components for more complex hero layouts export const HeroContent: React.FC<{ title: string; subtitle?: string; children?: React.ReactNode; className?: string; }> = ({ title, subtitle, children, className = '' }) => (

{title}

{subtitle &&

{subtitle}

} {children}
); export const HeroActions: React.FC<{ children: React.ReactNode; className?: string; }> = ({ children, className = '' }) => (
{children}
); export default Hero;