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
31 lines
1.5 KiB
TypeScript
31 lines
1.5 KiB
TypeScript
'use client';
|
|
/* The sound layer (mounted once in app/layout.tsx): wires lib/sound.ts to the site's meaningful moments. Pages add nothing; to sound
|
|
their own moment they call play('done') from lib/sound.ts, or put data-sound="tick" on a control (data-sound=""
|
|
silences one). Clicks and keys only: never hover, scroll or page load. */
|
|
import { useEffect } from 'react';
|
|
import { play } from '../lib/sound';
|
|
|
|
const ASK = '.x-ask-a, .x-btn.solid, a.solid, button.solid, [data-cta], [data-thumb]';
|
|
const TICK = '[role=tab], [role=switch], [role=menuitemradio], [aria-pressed], input[type=checkbox], input[type=radio], .x-faq button';
|
|
|
|
export default function Sound() {
|
|
useEffect(() => {
|
|
const click = (e: MouseEvent) => {
|
|
if (!e.isTrusted) return;
|
|
const t = (e.target as Element).closest?.('[data-sound], ' + ASK + ', ' + TICK);
|
|
if (!t) return;
|
|
const own = t.closest('[data-sound]');
|
|
if (own) { const n = own.getAttribute('data-sound'); if (n) play(n); return; }
|
|
if (t.matches(TICK)) play('tick');
|
|
else if (t.matches(ASK)) play('tap');
|
|
};
|
|
const asked = (e: Event) => play((e as CustomEvent<string>).detail);
|
|
// Morph and the palette announce their moments; the click layer above stays silent for those (one sound at once)
|
|
document.addEventListener('click', click, true);
|
|
addEventListener('hz-sound', asked);
|
|
return () => { document.removeEventListener('click', click, true); removeEventListener('hz-sound', asked); };
|
|
}, []);
|
|
|
|
return null;
|
|
}
|