Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | SOFTWARE & RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : ORIX App Universe8 * File : src/components/showcase/Showcase.tsx9 * Module : components10 * Repository : https://git.spboucher.ai/orix-spboucher-ai11 * Project Website : https://www.orixlab.dev12 * Created : 2026-11-2513 * Last Modified : 2026-11-2514 *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 { useEffect, useRef, useState, type CSSProperties, type ReactNode } from "react";46import { motion, useMotionValueEvent, useReducedMotion, useScroll, useSpring, useTransform, type MotionValue } from "motion/react";4748export type ShowcaseItem = {49 slug: string; name: string; tagline: string; summary: string; icon: string | null; accent: string | null;50 device: "iphone" | "ipad" | "mac"; shot: { src: string; width: number; height: number; alt: string };51 /** Rendered on the server: platform tags, status and the verified primary action. */52 meta: ReactNode; actions: ReactNode;53};5455function Panel({ item, i, n, progress, pinned }: { item: ShowcaseItem; i: number; n: number; progress: MotionValue<number>; pinned: boolean }) {56 // Position of this panel relative to the centre of the screen: -1 = one panel to the right, 0 = centred, 1 = one to the left.57 const local = useTransform(progress, (p) => p * (n - 1) - i);58 const shotX = useTransform(local, [-1, 0, 1], [220, 0, -220]);59 const shotRotate = useTransform(local, [-1, 0, 1], [-22, -7, 10]);60 const shotScale = useTransform(local, [-1, 0, 1], [0.84, 1, 0.84]);61 const copyX = useTransform(local, [-1, 0, 1], [90, 0, -90]);62 const copyOpacity = useTransform(local, [-0.75, -0.2, 0.2, 0.75], [0, 1, 1, 0]);63 const numberX = useTransform(local, [-1, 0, 1], [-140, 0, 140]);64 const portrait = item.device !== "mac";65 return (66 <article className="showcase-panel" style={{ "--accent": item.accent ?? "var(--blue)" } as CSSProperties} data-testid="showcase-panel" data-slug={item.slug}>67 <motion.span className="showcase-number mono" aria-hidden style={pinned ? { x: numberX } : undefined}>{String(i + 1).padStart(2, "0")}</motion.span>68 <div className="showcase-glow" aria-hidden />69 <div className={`showcase-grid ${portrait ? "is-portrait" : ""}`}>70 <motion.div className="showcase-copy" style={pinned ? { x: copyX, opacity: copyOpacity } : undefined}>71 <div className="flex items-center gap-4">72 {item.icon && <span className="icon w-[4.5rem]"><Image src={item.icon} alt="" width={72} height={72} sizes="72px" /></span>}73 <div className="flex flex-wrap items-center gap-2">{item.meta}</div>74 </div>75 <h3 className="showcase-name">{item.name}</h3>76 <p className="showcase-tagline accent-text">{item.tagline}</p>77 <p className="mt-4 max-w-[34rem] text-[1.02rem] leading-relaxed text-ink2">{item.summary}</p>78 <div className="mt-7 flex flex-wrap items-center gap-3">{item.actions}</div>79 </motion.div>80 <div className="showcase-stage">81 <motion.div className={`frame ${item.device === "mac" ? "frame-mac" : `frame-${item.device}`} showcase-shot`} style={pinned ? { x: shotX, rotateY: shotRotate, scale: shotScale } : undefined}>82 {item.device === "mac"83 ? <Image src={item.shot.src} alt={item.shot.alt} width={item.shot.width} height={item.shot.height} sizes="(max-width: 1024px) 92vw, 900px" />84 : <div className="screen"><Image src={item.shot.src} alt={item.shot.alt} width={item.shot.width} height={item.shot.height} sizes="(max-width: 1024px) 60vw, 360px" /></div>}85 </motion.div>86 </div>87 </div>88 </article>89 );90}9192/**93 * The released applications, one per screen. On a wide screen with a fine pointer the section pins and the94 * vertical scroll drives a horizontal journey, each capture turning in space as it crosses the centre.95 * Elsewhere (touch, narrow screens, reduced motion) it is an ordinary swipeable row.96 */97export function Showcase({ items, label }: { items: ShowcaseItem[]; label: string }) {98 const ref = useRef<HTMLDivElement>(null);99 const reduce = useReducedMotion();100 const [pinned, setPinned] = useState(false);101 const [active, setActive] = useState(0);102 const n = items.length;103 const { scrollYProgress } = useScroll({ target: ref, offset: ["start start", "end end"] });104 const smooth = useSpring(scrollYProgress, { stiffness: 90, damping: 24, mass: 0.6 });105 const x = useTransform(smooth, (p) => `${-p * (n - 1) * 100}vw`);106 const bar = useTransform(smooth, [0, 1], [0, 1]);107 useMotionValueEvent(smooth, "change", (p) => setActive(Math.round(p * (n - 1))));108109 useEffect(() => {110 if (reduce) return;111 const mq = matchMedia("(min-width: 1024px) and (min-height: 620px) and (hover: hover) and (pointer: fine)");112 const set = () => setPinned(mq.matches);113 set();114 mq.addEventListener("change", set);115 return () => mq.removeEventListener("change", set);116 }, [reduce]);117118 const jump = (i: number) => {119 const el = ref.current;120 if (!el) return;121 if (pinned) window.scrollTo({ top: el.getBoundingClientRect().top + window.scrollY + ((el.offsetHeight - window.innerHeight) * i) / Math.max(1, n - 1), behavior: "smooth" });122 else el.querySelectorAll<HTMLElement>(".showcase-panel")[i]?.scrollIntoView({ behavior: "smooth", inline: "center", block: "nearest" });123 };124125 return (126 <div ref={ref} className={`showcase ${pinned ? "is-pinned" : ""}`} style={pinned ? { height: `${100 + (n - 1) * 85}vh` } : undefined} data-testid="showcase">127 <div className="showcase-sticky">128 <motion.div className="showcase-track" style={pinned ? { x } : undefined}>129 {items.map((item, i) => <Panel key={item.slug} item={item} i={i} n={n} progress={smooth} pinned={pinned} />)}130 </motion.div>131 <nav className="showcase-rail" aria-label={label}>132 <ol>133 {items.map((item, i) => (134 <li key={item.slug}>135 <button type="button" onClick={() => jump(i)} aria-label={item.name} aria-current={pinned && active === i ? "true" : undefined} title={item.name} style={{ "--accent": item.accent ?? "var(--blue)" } as CSSProperties}>136 {item.icon ? <span className="icon w-full"><Image src={item.icon} alt="" width={40} height={40} sizes="40px" /></span> : <span className="icon icon-empty w-full" />}137 </button>138 </li>139 ))}140 </ol>141 {pinned && <span className="showcase-bar" aria-hidden><motion.i style={{ scaleX: bar }} /></span>}142 </nav>143 </div>144 </div>145 );146}147