Files
zeekayandGitHub ea43c5a975 Type lib, scripts, v2, home and app under strict (#8)
* 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
2026-11-14 01:34:34 -08:00

49 lines
2.6 KiB
TypeScript

'use client';
/* How much AI, as one slider: the plan cards' usage ladder on the home and /pricing (lib/plans.ts `rungs`), lowest
first, each stop named under it by its multiple of Go (3x … 50x), the last with no cap ∞. It is the browser's own
range input, so arrows, Home/End, a drag and a screen reader all work as they do everywhere; aria-valuetext says the
plan, its usage and its price. The track's fill and the stops' places are CSS from --n and --at, so the server draws
it as it stays and nothing is measured. A tap on the track or a stop's name goes to that stop (Safari on a phone
moves a range only by its thumb). */
import { useRef, type CSSProperties, type MouseEvent, type ReactNode } from 'react';
import type { Rung } from '../lib/plans';
import './Usage.css';
export default function Usage({ rungs, at, set }: { rungs: Rung[]; at: number; set: (i: number) => void }) {
const r = rungs[at];
const n = Math.max(1, rungs.length - 1);
const down = useRef<number | null>(null);
// a tap (not a drag) goes to the nearest stop: the stops sit a half thumb (22px) in from each end, as the input puts them
const tap = (e: MouseEvent<HTMLInputElement>) => {
if (down.current == null || Math.abs(e.clientX - down.current) > 6) return;
const box = e.currentTarget.getBoundingClientRect();
const k = Math.round(((e.clientX - box.left - 22) / (box.width - 44)) * n);
set(Math.min(n, Math.max(0, k)));
};
return (
<div className="x-usage" style={{ '--n': n, '--at': at } as CSSProperties}>
<input
type="range" min={0} max={n} step={1} value={at}
onChange={(e) => set(+e.target.value)}
onPointerDown={(e) => { down.current = e.clientX; }}
onClick={tap}
aria-label="Usage"
aria-valuetext={`${r.name}, ${r.x === '∞' ? 'no usage caps' : r.x + ' usage'}, $${r.price} a month`}
/>
<ol aria-hidden="true">
{rungs.map((q, k) => <li key={q.id} style={{ '--k': k } as CSSProperties} data-on={k === at || undefined} data-inf={q.x === '∞' || undefined}>{q.x}</li>)}
</ol>
</div>
);
}
/** Every stop's version of a part in one cell, the current one shown: the cell is as tall and as wide as the largest, so
a move of the slider never moves anything around it. `as` is the cell's element: span within a line, div around blocks. */
export function Stack({ at, as: Tag = 'span', className = '', children }: { at: number; as?: 'span' | 'div'; className?: string; children: ReactNode[] }) {
return (
<Tag className={'x-stack' + (className ? ' ' + className : '')}>
{children.map((c, k) => <Tag key={k} data-on={k === at || undefined}>{c}</Tag>)}
</Tag>
);
}