import { Image } from '@components/common/Image.js'; import { Editable, EditableImage, EditableMarkdown, isPageBuilderActive } from '@components/common/page-builder/index.js'; import { buttonVariants } from '@components/common/ui/Button.js'; import { ImagePlus, ShoppingBag } from 'lucide-react'; import React, { useEffect, useState } from 'react'; /** * Product hero — single-product spotlight. A mini-PDP embedded on the * homepage: image, eyebrow, name, price, optional editorial copy, and a * "View details" link to the real product page. * * Variant picking + add-to-cart deliberately defer to the theme's normal * PDP affordances — exposing them from a homepage widget would require * wiring up the cart drawer machinery, which is theme-owned. The hero * is read-only: it surfaces the product and links into its full PDP. */ interface HeroProduct { productId: number; uuid: string; name: string; sku?: string | null; price?: { regular?: { value: number; text: string } | null; special?: { value: number; text: string } | null; } | null; image?: { alt: string; url: string } | null; url: string; inventory?: { isInStock?: boolean } | null; } export interface ProductHeroProps { productHeroWidget: { productUuid: string | null; image: string | null; imageAlt: string; /** Natural intrinsic width of the override image, captured at pick * time. Falls back to a hero-scale default. The product's own image * doesn't carry dimensions, so we always need this fallback when * the override is empty. */ imageWidth: number | null; /** Natural intrinsic height. */ imageHeight: number | null; eyebrow: string | null; copy: string | null; imagePosition: 'left' | 'right'; product: HeroProduct | null; }; } export default function ProductHero({ productHeroWidget }: ProductHeroProps) { const { image, imageAlt, imageWidth, imageHeight, eyebrow, copy, imagePosition, product } = productHeroWidget; const [inPb, setInPb] = useState(false); useEffect(() => { setInPb(isPageBuilderActive()); }, []); if (!product) { if (inPb) { const reverseP = imagePosition === 'right'; const imageBlock = (