import React from 'react' import { Button } from '@/core/components/ui/button' import { cn } from '@/core/lib/utils' import { buildSectionClasses, resolveMediaUrl } from '@/core/types/blocks' import type { HeroBlockProps } from './schema' /** * Hero Block Component * * Props from 3-tab structure: * - Content: title, content, cta * - Design: backgroundColor, backgroundImage, textColor * - Advanced: className, id */ export function HeroBlock({ // Base content props title, content, cta, // Base design props backgroundColor, // Hero-specific design backgroundImage, textColor = 'light', // Base advanced props className, id, // Legacy props for backward compatibility ...legacyProps }: HeroBlockProps & { ctaText?: string ctaLink?: string subtitle?: string description?: string }) { // Handle legacy CTA format (ctaText, ctaLink) for backward compatibility const ctaConfig = cta || (legacyProps.ctaText ? { text: legacyProps.ctaText, link: legacyProps.ctaLink || '#', target: '_self' as const, } : undefined) // Handle legacy subtitle/description props for backward compatibility const displayContent = content || legacyProps.subtitle || legacyProps.description // Resolve media ref to URL (handles both legacy string and new object format) const backgroundImageUrl = resolveMediaUrl(backgroundImage) // Build section classes with background and custom className const sectionClasses = buildSectionClasses( cn( 'relative flex min-h-[600px] items-center justify-center overflow-hidden px-4 py-20', textColor === 'light' ? 'text-white' : 'text-gray-900' ), { backgroundColor, className } ) return (
{/* Background Image */} {backgroundImageUrl && (
)} {/* Content */}
{title && (

{title}

)} {displayContent && (

{displayContent}

)} {ctaConfig && ( )}
) }