'use client' import React from 'react' import { motion } from 'framer-motion' import type { Page, Media } from '../../payload-types' import Link from 'next/link' import Image from 'next/image' import { ImagePlaceholder } from '../../components/ImagePlaceholder' type BaseProps = Extract[0], { blockType: 'hero' }> type Props = BaseProps & { whatsappNumber?: string | null } const customEase = [0.22, 1, 0.36, 1] as const const containerVariants = { hidden: {}, visible: { transition: { staggerChildren: 0.14, delayChildren: 0.2 }, }, } const itemVariants = { hidden: { opacity: 0, y: 22 }, visible: { opacity: 1, y: 0, transition: { duration: 0.7, ease: customEase, }, }, } export const HeroBlock: React.FC = ({ title, titleAccent, subtitle, primaryCta, secondaryCta, image, whatsappNumber, }) => { const whatsappLink = whatsappNumber ? `https://wa.me/${whatsappNumber}` : '#' const heroMedia = typeof image === 'object' && image !== null ? (image as Media) : null const imageUrl = heroMedia?.url const imageAlt = heroMedia?.alt || 'Tło hero' return ( {/* Background Layer */}
{imageUrl ? ( <> {imageAlt} {/* Ciemny gradient pod spodem, by biały tekst był świetnie czytelny, a zdjęcie pozostało nasycone */}
) : (
)}
{/* Content Layer */}
{/* Main Content (Bottom Left) */} {title} {titleAccent && ( {titleAccent.split(/(po polsku)/i).map((part, i) => part.toLowerCase() === 'po polsku' ? {part} : part )} )} {subtitle} {whatsappNumber && ( {primaryCta} )} {secondaryCta?.text && secondaryCta?.url && ( secondaryCta.url.startsWith('#') ? ( {secondaryCta.text} ) : ( {secondaryCta.text} ) )}
) }