mirror of
https://github.com/hanzoai/site.git
synced 2026-11-20 21:21:13 +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
83 lines
4.0 KiB
TypeScript
83 lines
4.0 KiB
TypeScript
'use client';
|
|
/* SpecDrawer: the spec sheet and its "see the spec" sheet (VISION: detail lives in things you open). A calm row of
|
|
huge tabular figures; one button raises a sheet from the bottom with the long detail (code, full lists). The sheet's
|
|
content is always in the HTML (inert while closed), so nothing is lost. Esc, the backdrop or Close shut it, focus
|
|
returns to the button, and the page behind holds still while it is open.
|
|
Usage:
|
|
<SpecDrawer rows={[{ v: '4222', l: 'Client port' }, { v: 'Replay', l: 'From any point' }]}
|
|
open="See the code" sheetTitle="events.go">{<Code … />}</SpecDrawer>
|
|
rows: Hanzo's own figures and words only. Without children there is no button. The closed sheet is not a dialog
|
|
(no role, no aria-modal), so the site's sticky ask (components/Ask.jsx) does not mistake it for an open overlay.
|
|
Owned by Cloud 3. */
|
|
import { useEffect, useId, useRef, useState, type CSSProperties, type ReactNode } from 'react';
|
|
import './LaunchType.css';
|
|
import './SpecDrawer.css';
|
|
|
|
interface SheetProps {
|
|
open: boolean;
|
|
onClose: () => void;
|
|
title: string;
|
|
children?: ReactNode;
|
|
id?: string;
|
|
}
|
|
|
|
export function Sheet({ open, onClose, title, children, id }: SheetProps) {
|
|
const close = useRef<HTMLButtonElement>(null);
|
|
useEffect(() => {
|
|
if (!open) return;
|
|
const prev = document.activeElement as HTMLElement | null;
|
|
const html = document.documentElement;
|
|
html.classList.add('x-lock');
|
|
window.__lenis?.stop();
|
|
close.current?.focus({ preventScroll: true });
|
|
const key = (e: KeyboardEvent) => e.key === 'Escape' && onClose();
|
|
addEventListener('keydown', key);
|
|
return () => { removeEventListener('keydown', key); html.classList.remove('x-lock'); window.__lenis?.start(); prev?.focus?.({ preventScroll: true }); };
|
|
}, [open, onClose]);
|
|
return (
|
|
<div className="lx-sheet" data-open={open ? '' : undefined} id={id}>
|
|
<button type="button" className="lx-sheet-scrim" tabIndex={-1} aria-hidden="true" onClick={onClose} />
|
|
<div className="lx-sheet-panel" role={open ? 'dialog' : undefined} aria-modal={open || undefined} aria-label={title} inert={!open} data-lenis-prevent>
|
|
<div className="lx-sheet-bar">
|
|
<p className="lx-kick">{title}</p>
|
|
<button ref={close} type="button" className="lx-sheet-x" onClick={onClose} aria-label="Close"><svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="M4 4l8 8M12 4l-8 8" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" /></svg></button>
|
|
</div>
|
|
<div className="lx-sheet-body">{children}</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
interface SpecDrawerProps {
|
|
rows: { v: ReactNode; l: ReactNode }[];
|
|
open?: string;
|
|
sheetTitle?: string;
|
|
children?: ReactNode;
|
|
className?: string;
|
|
note?: ReactNode;
|
|
}
|
|
|
|
export default function SpecDrawer({ rows, open: openLabel = 'See the spec', sheetTitle, children, className = '', note }: SpecDrawerProps) {
|
|
const [open, setOpen] = useState(false);
|
|
const id = useId();
|
|
return (
|
|
<div className={'lx-spec ' + className}>
|
|
<dl className="lx-spec-rows" style={{ '--cols': Math.min(rows.length, 4) } as CSSProperties}>
|
|
{rows.map((r, i) => (
|
|
<div key={i} className="lx-spec-row">
|
|
<dt className="lx-spec-l">{r.l}</dt>
|
|
<dd className="lx-spec-v lx-num">{r.v}</dd>
|
|
</div>
|
|
))}
|
|
</dl>
|
|
{(children || note) && (
|
|
<div className="lx-spec-foot">
|
|
{note && <p className="lx-body">{note}</p>}
|
|
{children && <button type="button" className="lx-ghost lx-spec-open" aria-haspopup="dialog" aria-controls={id} aria-expanded={open} onClick={() => setOpen(true)}>{openLabel}<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d="M8 3v10M3 8h10" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" /></svg></button>}
|
|
</div>
|
|
)}
|
|
{children && <Sheet id={id} open={open} onClose={() => setOpen(false)} title={sheetTitle || openLabel}>{children}</Sheet>}
|
|
</div>
|
|
);
|
|
}
|