import React from "react"; import { PrimaryHeroProps } from "./types"; import { Checklist } from "@shared/components/checklist"; import { NextImage } from "@shared/components/next-image"; import { Text } from "@shared/components/text"; import { Button } from "@shared/contentful/blocks/button"; import { cx } from "@shared/utils"; export const PrimaryHero: React.FC = props => { const { title, showAsHeading, subTitle, primaryCta1, primaryCta2, carouselImages, bottomLink, price, priceCallout, priceSuffix, checklist, renderCheckPlans, badgeImage, pricingDescription, pricingDescriptionDisclaimer, secondaryCta, secondaryCtaPrefix, onModalButtonClick, hideOnMobileCta1, hideOnMobileCta2, textColor = "light", logoLockup, heroVideo, heroVideoMobile, } = props; const isButtonType = (cta: any) => { const type = cta?.showButtonAs ?? "solid"; return ( type === "solid" || type === "button-with-icon" || type === "unstyled" ); }; const showCtasSideBySide = primaryCta1 && primaryCta2 && isButtonType(primaryCta1) && isButtonType(primaryCta2); const desktopVideoUrl = heroVideo?.url?.trim(); const mobileVideoUrl = heroVideoMobile?.url?.trim(); const hasDesktopVideo = !!desktopVideoUrl; const hasMobileVideo = !!mobileVideoUrl; const normalizeImageUrl = (url?: string) => url?.startsWith("//") ? `https:${url}` : url; const badgeImageUrl = normalizeImageUrl(badgeImage); const heroImageUrl = normalizeImageUrl(carouselImages?.[0]); const bottomLinkLabel = bottomLink?.buttonLabel ?? bottomLink?.label; const baseTextColorClass = textColor === "dark" ? "text-text" : "text-white"; const textColorClass = hasDesktopVideo && textColor === "dark" ? `${baseTextColorClass} xl:text-white` : baseTextColorClass; const Badge = ({ className }: { className: string }) => badgeImageUrl ? ( ) : null; return (
{hasDesktopVideo ? ( ) : null}
{/* Left column: navy background, headline, body, address, button, link */}
{title && ( {title} )} {subTitle && ( {subTitle} )} {/* price callout */} {price ? (
{priceCallout ? priceCallout.split("|").map((line, index) => ( {line} )) : null}
$ {price} {priceSuffix ? ( {priceSuffix} ) : null}
) : null} {pricingDescription ? ( {pricingDescription} ) : null} {pricingDescriptionDisclaimer ? ( {pricingDescriptionDisclaimer} ) : null} {/* checklist */} {checklist && ( item.iconUrl ? { title: item.title, iconUrl: item.iconUrl } : item.title )} /> )} {logoLockup ? (
) : null} {/* CTA section */}
{/* desktop CTA */} {showCtasSideBySide ? (
) : ( <> {primaryCta1 && (
)} {primaryCta2 && (
)} )} {secondaryCtaPrefix || secondaryCta ? (
{secondaryCtaPrefix && ( {secondaryCtaPrefix} )} {secondaryCta && (
) : null} {/* desktop bottom link */} {bottomLink && (bottomLinkLabel || bottomLink?.href) && (
)}
{/* mobile hero image and bottom link */}
{hasMobileVideo ? (
) : ( <> {badgeImage ? ( ) : null} {heroImageUrl ? ( ) : null} )}
{secondaryCtaPrefix || secondaryCta ? (
{secondaryCtaPrefix && ( {secondaryCtaPrefix} )} {secondaryCta && (
) : null} {bottomLink && (bottomLinkLabel || bottomLink?.href) && (
)}
{/* Right column: bright blue background, diagonal top edge, hero image */}
); }; export default PrimaryHero;