mirror of
https://github.com/hanzoai/site.git
synced 2026-11-20 21:14:28 +00:00
* Type scripts under strict Playwright's API the checks use is declared in host.ts (the package is the app repo's); caught errors read through why(). tabs-tree.test waits for the typed tabsTree. Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk * Type the shared components under strict Window globals (__lenis, __hzHold, google) and the two react-dom calls are declared in components/*.d.ts, since @types/react-dom is not a dependency and the lockfile is frozen. Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk * Type components/v2 under strict Props, state, refs and DOM events in the 93 v2 files. A2Motion's easing tuples are as const. Two real bugs: x-archimedes/MaskLines imported a NoJs that does not exist, and x-hypatia/PinChapters returned the element from a ref callback, which React 19 reads as a cleanup. AppSheet no longer sets aria-label to a JSX label. Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk * Type components/home under strict The race, cost and frontier figures, the plan cards, the repository card and the product stories take Run, Models and Plan types from lib. Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk * Type the hero devices and the app routes under strict HeroScene and its parts describe hero-scenes.json; the [slug] pages take params as a Promise, and metadata and viewport carry Next's types. Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk * Give the integrations previews their Preview type Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk * Use the bench Card type for the closing cards Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk
33 lines
1.9 KiB
TypeScript
33 lines
1.9 KiB
TypeScript
'use client';
|
|
/* A page ported from hanzo.ai as Hanzo renders it, given the new motion layer: each block rises into place as it
|
|
is reached, and links inside the site navigate without a reload. */
|
|
import { useEffect, useRef } from 'react';
|
|
import { useRouter } from 'next/navigation';
|
|
import { has } from '../lib/route';
|
|
|
|
export default function Ported({ html }: { html?: string }) {
|
|
const ref = useRef<HTMLDivElement>(null);
|
|
const router = useRouter();
|
|
useEffect(() => {
|
|
const root = ref.current;
|
|
if (!root) return;
|
|
// the blocks worth revealing: top-level sections, else the first layer of children
|
|
let blocks: Element[] = [...root.querySelectorAll(':scope > section, :scope > div > section, :scope > div > div > section')];
|
|
if (blocks.length < 2) blocks = [...root.children].flatMap((c) => (c.children.length > 1 ? [...c.children] : [c]));
|
|
const calm = matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
const vh = innerHeight;
|
|
blocks.forEach((b) => { if (!calm && b.getBoundingClientRect().top > vh * 0.9) b.classList.add('x-rv'); });
|
|
const io = new IntersectionObserver((es) => es.forEach((e) => { if (e.isIntersecting) { e.target.classList.add('in'); io.unobserve(e.target); } }), { rootMargin: '0px 0px -12% 0px' });
|
|
blocks.forEach((b) => b.classList.contains('x-rv') && io.observe(b));
|
|
const click = (e: MouseEvent) => {
|
|
const a = (e.target as Element).closest<HTMLAnchorElement>('a[href^="/"]');
|
|
if (!a || a.target === '_blank' || e.metaKey || e.ctrlKey || e.shiftKey || a.hasAttribute('download') || !has(a.getAttribute('href')!)) return;
|
|
e.preventDefault();
|
|
router.push(a.getAttribute('href')!);
|
|
};
|
|
root.addEventListener('click', click);
|
|
return () => { io.disconnect(); root.removeEventListener('click', click); };
|
|
}, [html, router]);
|
|
return <div ref={ref} className="x-port" dangerouslySetInnerHTML={{ __html: html ?? '' }} />;
|
|
}
|