{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"hero-local-business","type":"registry:block","title":"Hero, local business","description":"Home services hero with live rating, rotating service words and floating appointment, review and ETA cards.","dependencies":["lucide-react","motion"],"registryDependencies":["utils"],"files":[{"path":"registry/items/hero-local-business/hero-local-business.tsx","type":"registry:block","target":"components/facade/hero-local-business.tsx","content":"\"use client\";\n\nimport * as React from \"react\";\nimport {\n  AnimatePresence,\n  motion,\n  useMotionValue,\n  useReducedMotion,\n  useSpring,\n  useTransform,\n  type MotionValue,\n} from \"motion/react\";\nimport {\n  ArrowRight,\n  Calendar,\n  Car,\n  Check,\n  Clock,\n  MapPin,\n  Phone,\n  Star,\n} from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface HeroLocalBusinessAppointment {\n  service: string;\n  date: string;\n  time: string;\n  address: string;\n}\n\nexport interface HeroLocalBusinessReview {\n  name: string;\n  neighborhood: string;\n  quote: string;\n}\n\nexport interface HeroLocalBusinessTechnician {\n  name: string;\n  eta: string;\n  vehicle: string;\n}\n\nexport interface HeroLocalBusinessProps {\n  rating?: number;\n  reviewCount?: string;\n  eyebrowSuffix?: string;\n  headlinePrefix?: string;\n  rotatingWords?: string[];\n  headlineSuffix?: string;\n  description?: string;\n  primaryCta?: { label: string; href: string };\n  phone?: { label: string; href: string };\n  trustItems?: string[];\n  appointment?: HeroLocalBusinessAppointment;\n  review?: HeroLocalBusinessReview;\n  technician?: HeroLocalBusinessTechnician;\n  /** Interval in ms between word swaps. */\n  interval?: number;\n  className?: string;\n}\n\nconst EASE = [0.16, 1, 0.3, 1] as const;\n\nfunction initials(name: string) {\n  return name\n    .split(\" \")\n    .map((p) => p[0])\n    .join(\"\")\n    .slice(0, 2)\n    .toUpperCase();\n}\n\nfunction WordSwap({ words, interval }: { words: string[]; interval: number }) {\n  const reduce = useReducedMotion();\n  const [index, setIndex] = React.useState(0);\n  const longest = React.useMemo(\n    () => words.reduce((a, b) => (b.length > a.length ? b : a), \"\"),\n    [words],\n  );\n\n  React.useEffect(() => {\n    if (reduce || words.length < 2) return;\n    const id = window.setInterval(\n      () => setIndex((i) => (i + 1) % words.length),\n      interval,\n    );\n    return () => window.clearInterval(id);\n  }, [reduce, words.length, interval]);\n\n  return (\n    <span className=\"relative inline-grid overflow-hidden align-bottom\">\n      {/* Reserve width of the longest word so layout never jumps */}\n      <span aria-hidden className=\"invisible col-start-1 row-start-1\">\n        {longest}\n      </span>\n      <span className=\"sr-only\">{words.join(\", \")}</span>\n      <AnimatePresence mode=\"popLayout\" initial={false}>\n        <motion.span\n          key={words[index]}\n          aria-hidden\n          className=\"col-start-1 row-start-1\"\n          initial={{ y: \"60%\", opacity: 0 }}\n          animate={{ y: \"0%\", opacity: 1 }}\n          exit={{ y: \"-60%\", opacity: 0 }}\n          transition={{ duration: 0.6, ease: EASE }}\n        >\n          {words[index]}\n        </motion.span>\n      </AnimatePresence>\n    </span>\n  );\n}\n\nfunction Stars({ value, className }: { value: number; className?: string }) {\n  return (\n    <span className={cn(\"flex items-center gap-px\", className)} aria-hidden>\n      {Array.from({ length: 5 }).map((_, i) => (\n        <Star\n          key={i}\n          className={cn(\"size-3.5\", i < Math.round(value) ? \"fill-star text-star\" : \"fill-foreground/15 text-foreground/15\")}\n        />\n      ))}\n    </span>\n  );\n}\n\nfunction FloatingCard({\n  children,\n  className,\n  mx,\n  my,\n  depth,\n  delay,\n}: {\n  children: React.ReactNode;\n  className?: string;\n  mx: MotionValue<number>;\n  my: MotionValue<number>;\n  depth: number;\n  delay: number;\n}) {\n  const reduce = useReducedMotion();\n  const x = useTransform(mx, (v) => v * depth);\n  const y = useTransform(my, (v) => v * depth);\n  return (\n    <motion.div\n      style={reduce ? undefined : { x, y }}\n      initial={{ opacity: 0, y: 20 }}\n      animate={{ opacity: 1, y: 0 }}\n      transition={{ duration: 0.9, delay, ease: EASE }}\n      className={cn(\"absolute\", className)}\n    >\n      <div className=\"rounded-[20px] bg-background p-4 text-foreground shadow-float dark:bg-secondary dark:ring-1 dark:ring-border\">\n        {children}\n      </div>\n    </motion.div>\n  );\n}\n\nexport function HeroLocalBusiness({\n  rating = 4.9,\n  reviewCount = \"1,200+\",\n  eyebrowSuffix = \"reviews on Google\",\n  headlinePrefix = \"Austin's most trusted\",\n  rotatingWords = [\"plumbers\", \"electricians\", \"HVAC pros\", \"handymen\"],\n  headlineSuffix = \"on call today.\",\n  description = \"Upfront flat rate pricing, background checked technicians and a workmanship guarantee that means something. Book online in 60 seconds.\",\n  primaryCta = { label: \"Get a free quote\", href: \"#quote\" },\n  phone = { label: \"Call (512) 555-0142\", href: \"tel:+15125550142\" },\n  trustItems = [\"Licensed and insured\", \"Same day service\", \"5 year warranty\"],\n  appointment = {\n    service: \"Water heater install\",\n    date: \"Thu, Mar 14\",\n    time: \"9:00 to 11:00 AM\",\n    address: \"2104 Travis Heights Blvd\",\n  },\n  review = {\n    name: \"Jessica Moreno\",\n    neighborhood: \"South Congress\",\n    quote:\n      \"Showed up in under two hours, explained everything and cleaned up after. Easily the best service call we've had.\",\n  },\n  technician = {\n    name: \"Marcus Bell\",\n    eta: \"12 min\",\n    vehicle: \"White Ford Transit\",\n  },\n  interval = 2400,\n  className,\n}: HeroLocalBusinessProps) {\n  const reduce = useReducedMotion();\n  const ref = React.useRef<HTMLDivElement>(null);\n  const rawX = useMotionValue(0);\n  const rawY = useMotionValue(0);\n  const mx = useSpring(rawX, { stiffness: 120, damping: 30 });\n  const my = useSpring(rawY, { stiffness: 120, damping: 30 });\n\n  const onMove = (e: React.PointerEvent<HTMLDivElement>) => {\n    if (reduce || !ref.current) return;\n    const r = ref.current.getBoundingClientRect();\n    rawX.set(((e.clientX - r.left) / r.width - 0.5) * 2);\n    rawY.set(((e.clientY - r.top) / r.height - 0.5) * 2);\n  };\n  const onLeave = () => {\n    rawX.set(0);\n    rawY.set(0);\n  };\n\n  const fadeUp = (delay: number) => ({\n    initial: { opacity: 0, y: 16 },\n    animate: { opacity: 1, y: 0 },\n    transition: { duration: 0.8, delay, ease: EASE },\n  });\n\n  return (\n    <section className={cn(\"relative overflow-hidden bg-background text-foreground\", className)}>\n      <div className=\"mx-auto grid max-w-[1120px] items-center gap-14 px-6 py-20 sm:py-28 lg:grid-cols-[1.05fr_1fr] lg:gap-12\">\n        {/* Copy */}\n        <div className=\"max-w-[640px]\">\n          <motion.a\n            {...fadeUp(0)}\n            href=\"#reviews\"\n            className=\"group inline-flex items-center gap-2 rounded-full text-sm text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n          >\n            <Stars value={rating} />\n            <span className=\"font-medium text-foreground\">{rating.toFixed(1)}</span>\n            <span>\n              from {reviewCount} {eyebrowSuffix}\n            </span>\n            <ArrowRight className=\"size-3.5 transition-transform group-hover:translate-x-0.5\" aria-hidden />\n          </motion.a>\n\n          <motion.h1\n            {...fadeUp(0.08)}\n            className=\"mt-6 font-display text-[44px] font-semibold leading-[1] tracking-[-0.045em] text-balance sm:text-[64px] lg:text-[76px]\"\n          >\n            {headlinePrefix} <WordSwap words={rotatingWords} interval={interval} />\n            <br className=\"hidden sm:block\" /> {headlineSuffix}\n          </motion.h1>\n\n          <motion.p {...fadeUp(0.16)} className=\"mt-6 max-w-[560px] text-[19px] leading-[1.4] text-muted-foreground text-pretty sm:text-xl\">\n            {description}\n          </motion.p>\n\n          <motion.div {...fadeUp(0.24)} className=\"mt-9 flex flex-col gap-3 sm:flex-row sm:items-center\">\n            <a\n              href={primaryCta.href}\n              className=\"group inline-flex h-12 items-center justify-center gap-2 rounded-full bg-brand px-6 text-[15px] font-medium text-brand-foreground transition-colors hover:bg-[color-mix(in_srgb,var(--brand)_88%,black)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\"\n            >\n              {primaryCta.label}\n              <ArrowRight className=\"size-4 transition-transform group-hover:translate-x-0.5\" aria-hidden />\n            </a>\n            <a\n              href={phone.href}\n              className=\"inline-flex h-12 items-center justify-center gap-2 rounded-full bg-muted px-6 text-[15px] font-medium text-foreground transition-colors hover:bg-foreground/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n            >\n              <Phone className=\"size-4\" aria-hidden />\n              {phone.label}\n            </a>\n          </motion.div>\n\n          <motion.ul {...fadeUp(0.32)} className=\"mt-10 flex flex-wrap gap-x-6 gap-y-3 text-sm text-muted-foreground\">\n            {trustItems.map((item) => (\n              <li key={item} className=\"flex items-center gap-2\">\n                <Check className=\"size-4 text-foreground\" strokeWidth={2.25} aria-hidden />\n                <span>{item}</span>\n              </li>\n            ))}\n          </motion.ul>\n        </div>\n\n        {/* Card composition */}\n        <div\n          ref={ref}\n          onPointerMove={onMove}\n          onPointerLeave={onLeave}\n          className=\"relative mx-auto h-[460px] w-full max-w-[520px] sm:h-[500px]\"\n        >\n          <motion.div\n            aria-hidden\n            initial={{ opacity: 0 }}\n            animate={{ opacity: 1 }}\n            transition={{ duration: 1, ease: EASE }}\n            className=\"absolute inset-x-6 inset-y-8 rounded-[28px] bg-muted\"\n          />\n\n          {/* Appointment card */}\n          <FloatingCard mx={mx} my={my} depth={8} delay={0.35} className=\"left-0 top-0 w-[78%] max-w-[300px] sm:top-2\">\n            <div className=\"flex items-center justify-between\">\n              <span className=\"text-xs font-medium text-muted-foreground\">Upcoming visit</span>\n              <span className=\"rounded-full bg-success/10 px-2 py-0.5 text-[11px] font-medium text-success\">Confirmed</span>\n            </div>\n            <div className=\"mt-3 flex items-start gap-3\">\n              <div className=\"flex size-10 shrink-0 items-center justify-center rounded-full bg-muted text-foreground\">\n                <Calendar className=\"size-4\" aria-hidden />\n              </div>\n              <div className=\"min-w-0\">\n                <p className=\"truncate text-[15px] font-semibold tracking-[-0.01em]\">{appointment.service}</p>\n                <p className=\"mt-0.5 flex items-center gap-1.5 text-sm text-muted-foreground\">\n                  <Clock className=\"size-3.5\" aria-hidden />\n                  {appointment.date}, {appointment.time}\n                </p>\n                <p className=\"mt-0.5 flex items-center gap-1.5 truncate text-sm text-muted-foreground\">\n                  <MapPin className=\"size-3.5 shrink-0\" aria-hidden />\n                  <span className=\"truncate\">{appointment.address}</span>\n                </p>\n              </div>\n            </div>\n          </FloatingCard>\n\n          {/* Review card */}\n          <FloatingCard mx={mx} my={my} depth={-14} delay={0.5} className=\"right-0 top-[34%] w-[82%] max-w-[320px]\">\n            <div className=\"flex items-center gap-3\">\n              <span className=\"flex size-9 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background\">\n                {initials(review.name)}\n              </span>\n              <div className=\"min-w-0 flex-1\">\n                <p className=\"truncate text-sm font-semibold\">{review.name}</p>\n                <p className=\"truncate text-xs text-muted-foreground\">{review.neighborhood}, verified customer</p>\n              </div>\n              <Stars value={5} />\n            </div>\n            <p className=\"mt-3 text-sm leading-relaxed text-foreground/80\">&ldquo;{review.quote}&rdquo;</p>\n          </FloatingCard>\n\n          {/* Technician card */}\n          <FloatingCard mx={mx} my={my} depth={18} delay={0.65} className=\"bottom-0 left-[4%] w-[80%] max-w-[300px] sm:bottom-2\">\n            <div className=\"flex items-center gap-3\">\n              <span className=\"flex size-10 items-center justify-center rounded-full bg-muted text-sm font-semibold text-foreground\">\n                {initials(technician.name)}\n              </span>\n              <div className=\"min-w-0 flex-1\">\n                <p className=\"text-xs font-medium text-muted-foreground\">Technician on the way</p>\n                <p className=\"truncate text-[15px] font-semibold tracking-[-0.01em]\">{technician.name}</p>\n              </div>\n              <div className=\"text-right\">\n                <p className=\"text-lg font-semibold leading-none tracking-[-0.02em] tabular-nums\">{technician.eta}</p>\n                <p className=\"mt-1 text-[11px] text-muted-foreground\">ETA</p>\n              </div>\n            </div>\n            <div className=\"mt-3.5 h-1.5 overflow-hidden rounded-full bg-foreground/10\">\n              <motion.div\n                className=\"h-full rounded-full bg-brand\"\n                initial={{ width: \"15%\" }}\n                animate={{ width: \"72%\" }}\n                transition={{ duration: 2.4, delay: 1, ease: EASE }}\n              />\n            </div>\n            <p className=\"mt-2 flex items-center gap-1.5 text-xs text-muted-foreground\">\n              <Car className=\"size-3.5\" aria-hidden />\n              {technician.vehicle}\n            </p>\n          </FloatingCard>\n        </div>\n      </div>\n    </section>\n  );\n}\n\nexport default HeroLocalBusiness;\n"}],"categories":["hero"],"meta":{"tier":"free","demo":"import { HeroLocalBusiness } from \"./hero-local-business\";\n\nexport default function Demo() {\n  return <HeroLocalBusiness />;\n}\n"}}