Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | SOFTWARE & RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : ORIX App Universe8 * File : src/components/hero/Hero.tsx9 * Module : components10 * Repository : https://git.spboucher.ai/orix-spboucher-ai11 * Project Website : https://www.orixlab.dev12 * Created : 2026-11-2113 * Last Modified : 2026-11-2114 *15 * Author : Simon-Pierre Boucher16 * Position : Professor of Finance17 * Institution : Université du Québec en Outaouais (UQO)18 * Organization : SP Boucher19 * Website : https://spboucher.ai20 * Git : https://git.spboucher.ai21 *22 * Preferred Contact: support@spboucher.ai23 * Development : dev@spboucher.ai24 * Support : support@spboucher.ai25 * Security/Admin : admin@spboucher.ai26 *27 * Copyright (c) 202628 * Simon-Pierre Boucher29 * All rights reserved where applicable. This file is governed by the30 * applicable project license, copyright notices and relevant law.31 * Existing third-party rights and notices remain unaffected.32 *33 * License : None specified (no license file in this repository)34 *35 * Do not embed credentials, private keys, access tokens,36 * certificates or confidential personal information.37 *38 * =============================================================================39 * END OF SP BOUCHER SOURCE HEADER40 * =============================================================================41 */4243"use client";44import Image from "next/image";45import Link from "next/link";46import { useEffect, useRef, type ReactNode } from "react";47import { motion, useMotionValue, useReducedMotion, useScroll, useSpring, useTransform, type MotionValue } from "motion/react";4849export type HeroApp = { slug: string; name: string; icon: string | null; accent: string | null; href: string };5051import { Starfield } from "./Starfield";5253/**54 * Sixteen slots at four depths around the headline. x / y are percentages of the hero, s the icon width.55 * `m*` are the phone positions: two bands, above and below the text, so nothing ever covers the copy.56 */57const SLOTS = [58 { x: 10, y: 19, s: 108, d: 1.0 }, { x: 90, y: 17, s: 102, d: 1.0 }, { x: 14, y: 66, s: 92, d: 0.8 }, { x: 86, y: 64, s: 96, d: 0.8 },59 { x: 29, y: 12, s: 66, d: 0.5 }, { x: 71, y: 11, s: 64, d: 0.5 }, { x: 4.5, y: 44, s: 60, d: 0.45 }, { x: 95.5, y: 42, s: 58, d: 0.45 },60 { x: 25, y: 85, s: 72, d: 0.6 }, { x: 76, y: 84, s: 74, d: 0.6 }, { x: 43, y: 6.5, s: 46, d: 0.3 }, { x: 57.5, y: 7.5, s: 44, d: 0.3 },61 { x: 10, y: 83, s: 54, d: 0.35 }, { x: 90.5, y: 81, s: 54, d: 0.35 }, { x: 39, y: 92, s: 48, d: 0.3 }, { x: 62, y: 93, s: 48, d: 0.3 },62].map((p, i) => ({ ...p, mx: 9 + (i % 8) * 11.7, my: i < 8 ? (i % 2 ? 14.5 : 9.5) : (i % 2 ? 95.5 : 90.5), ms: i % 2 ? 38 : 46 }));6364function Floater({ app, i, mx, my, progress, still }: { app: HeroApp; i: number; mx: MotionValue<number>; my: MotionValue<number>; progress: MotionValue<number>; still: boolean }) {65 const slot = SLOTS[i % SLOTS.length];66 // Pointer parallax plus the fly-through: while the hero scrolls away, each icon leaves along its own ray from the centre.67 const dx = slot.x - 50, dy = slot.y - 50;68 const x = useTransform([mx, progress], ([m, p]: number[]) => m * slot.d * 38 + dx * p * (6 + slot.d * 16));69 const y = useTransform([my, progress], ([m, p]: number[]) => m * slot.d * 28 + dy * p * (5 + slot.d * 12));70 const scale = useTransform(progress, [0, 1], [1, 1 + slot.d * 1.5]);71 const far = slot.d < 0.5;72 return (73 <motion.div className="hero-slot" style={{ x: still ? 0 : x, y: still ? 0 : y, scale: still ? 1 : scale, "--x": `${slot.x}%`, "--y": `${slot.y}%`, "--s": `${slot.s}px`, "--mx": `${slot.mx}%`, "--my": `${slot.my}%`, "--ms": `${slot.ms}px`, zIndex: Math.round(slot.d * 10) } as never}>74 <motion.div75 initial={still ? false : { opacity: 0, scale: 0.12, x: -dx * 9, y: -dy * 7, filter: "blur(14px)" }}76 animate={{ opacity: far ? 0.62 : 1, scale: 1, x: 0, y: 0, filter: far ? "blur(1.5px)" : "blur(0px)" }}77 transition={{ duration: 1.9, delay: 0.5 + (1 - slot.d) * 0.5 + i * 0.045, ease: [0.16, 1, 0.3, 1] }}>78 <Link href={app.href} aria-label={app.name} title={app.name} className="floaty block rounded-[22.37%] transition-[filter] duration-500 hover:brightness-125"79 style={{ "--dur": `${8 + (i % 4) * 1.7}s`, "--delay": `${-i * 1.3}s`, "--r0": `${-2 - (i % 3)}deg`, "--r1": `${1 + (i % 3)}deg`, "--accent": app.accent ?? "var(--blue)" } as never}>80 {app.icon81 ? <span className="icon w-full"><Image src={app.icon} alt="" width={slot.s} height={slot.s} sizes={`${slot.s}px`} priority={slot.d === 1} /></span>82 : <span className="icon icon-empty w-full"><span aria-hidden data-i={app.name.replace(/^ORIX\s+/i, "").slice(0, 2)} /></span>}83 </Link>84 </motion.div>85 </motion.div>86 );87}8889export function Hero({ apps, children }: { apps: HeroApp[]; children: ReactNode }) {90 const ref = useRef<HTMLElement>(null);91 const reduce = useReducedMotion();92 const mx = useMotionValue(0), my = useMotionValue(0);93 const sx = useSpring(mx, { stiffness: 40, damping: 18, mass: 1.2 }), sy = useSpring(my, { stiffness: 40, damping: 18, mass: 1.2 });94 const { scrollYProgress } = useScroll({ target: ref, offset: ["start start", "end start"] });95 const fieldOpacity = useTransform(scrollYProgress, [0, 0.55, 0.95], [1, 1, 0]);96 const copyY = useTransform(scrollYProgress, [0, 1], [0, -90]);97 const copyScale = useTransform(scrollYProgress, [0, 1], [1, 0.9]);98 const copyOpacity = useTransform(scrollYProgress, [0, 0.55], [1, 0]);99 const haloScale = useTransform(scrollYProgress, [0, 1], [1, 1.9]);100101 useEffect(() => {102 const el = ref.current;103 if (!el || reduce) return;104 const fine = matchMedia("(hover: hover) and (pointer: fine)").matches;105 const move = (e: PointerEvent) => { const r = el.getBoundingClientRect(); mx.set(((e.clientX - r.left) / r.width - 0.5) * -2); my.set(((e.clientY - r.top) / r.height - 0.5) * -2); };106 const leave = () => { mx.set(0); my.set(0); };107 if (fine) { el.addEventListener("pointermove", move, { passive: true }); el.addEventListener("pointerleave", leave); }108 // Floating stops when the hero is off screen: nothing animates that cannot be seen.109 const io = new IntersectionObserver(([e]) => el.classList.toggle("paused", !e.isIntersecting));110 io.observe(el);111 return () => { el.removeEventListener("pointermove", move); el.removeEventListener("pointerleave", leave); io.disconnect(); };112 }, [mx, my, reduce]);113114 return (115 <section ref={ref} className="hero relative isolate flex min-h-[100svh] items-center overflow-hidden pb-48 pt-28 md:pb-20 md:pt-24" data-testid="hero">116 <div className="aurora" aria-hidden /><Starfield /><div className="gridlines" aria-hidden />117 <motion.div className="absolute inset-0" style={reduce ? undefined : { scale: haloScale }} aria-hidden><div className="halo"><i /><i /><i /></div></motion.div>118 <div className="horizon" aria-hidden />119 <motion.div className="absolute inset-0" style={reduce ? undefined : { opacity: fieldOpacity }}>120 {apps.slice(0, SLOTS.length).map((a, i) => <Floater key={a.slug} app={a} i={i} mx={sx} my={sy} progress={scrollYProgress} still={!!reduce} />)}121 </motion.div>122 <motion.div className="wrap relative z-20 text-center" style={reduce ? undefined : { y: copyY, scale: copyScale, opacity: copyOpacity }}>{children}</motion.div>123 {/* Phones: the floating icons would crowd the copy, so the line-up passes as one calm strip under it. */}124 <div className="hero-strip" aria-hidden>125 {[0, 1].map((k) => (126 <ul key={k}>127 {apps.map((a) => <li key={a.slug}>{a.icon ? <span className="icon w-full"><Image src={a.icon} alt="" width={52} height={52} sizes="52px" /></span> : <span className="icon icon-empty w-full" />}</li>)}128 </ul>129 ))}130 </div>131 <div className="scroll-cue" aria-hidden><span /></div>132 </section>133 );134}135