mirror of
https://github.com/hanzoai/site.git
synced 2026-11-21 01:07:08 +00:00
* Type page props, hook state and helper parameters from their call sites First pass of the strict typing of components/pages (About to cloudfam): destructured props get an interface built from the JSX that renders them, refs and state get their element and value types, plain parameters get the type their callers or body fix. Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk * Type pages (careers, calculator, blog, brand, cli) from their data and call sites Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk * Type the cloud pages from their scenes and hooks Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk * wip * Type the remaining pages under strict Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk
43 lines
1.9 KiB
TypeScript
43 lines
1.9 KiB
TypeScript
'use client';
|
|
/* /api entrances (MOTION-MAP row: line-draw, underline-sweep, invert-flash, shutter, swing-door), page-local.
|
|
One IntersectionObserver marks each [data-enter] once with data-in when about a quarter of it (or a quarter of the
|
|
screen) is in view; enter.css plays the entrance named by data-enter. The markup is identical on server and client:
|
|
start states live in enter.css under html.js and prefers-reduced-motion: no-preference, so JS off and reduced motion
|
|
show everything in its final state. */
|
|
import { useEffect } from 'react';
|
|
|
|
export function useEnter(rootSel: string) {
|
|
useEffect(() => {
|
|
const root = document.querySelector(rootSel);
|
|
if (!root) return;
|
|
const els = [...root.querySelectorAll<HTMLElement>('[data-enter]')];
|
|
const timers: ReturnType<typeof setTimeout>[] = [];
|
|
if (typeof IntersectionObserver === 'undefined') { els.forEach((el) => { el.dataset.in = ''; }); return; }
|
|
const io = new IntersectionObserver((es) => {
|
|
es.forEach((e) => {
|
|
if (!e.isIntersecting) return;
|
|
const h = e.intersectionRect.height;
|
|
if (e.intersectionRatio >= 0.25 || h >= innerHeight * 0.25) {
|
|
const el = e.target;
|
|
if (!(el instanceof HTMLElement)) return;
|
|
el.dataset.in = '';
|
|
io.unobserve(el);
|
|
// once played, later content (a filtered row, say) appears at once, not through the entrance again
|
|
timers.push(setTimeout(() => { el.dataset.done = ''; }, 1600));
|
|
}
|
|
});
|
|
}, { threshold: [0, 0.1, 0.25, 0.5] });
|
|
els.forEach((el) => io.observe(el));
|
|
return () => { io.disconnect(); timers.forEach(clearTimeout); };
|
|
}, [rootSel]);
|
|
}
|
|
|
|
/* line-draw: the card's outline, drawn by enter.css (one path length, dash offset 1 to 0), then the card fills */
|
|
export function Draw({ r = 16 }) {
|
|
return (
|
|
<svg className="api-draw" aria-hidden="true" focusable="false">
|
|
<rect x="1" y="1" rx={r} ry={r} pathLength="1" />
|
|
</svg>
|
|
);
|
|
}
|