Files
AgentCompany/landing/components/pixel/xp-bar.tsx
T
ZacharyZhang-NYandClaude Opus 5.5 2d7af224dd
CI / Typecheck, lint, tests, e2e (push) Failing after 3m51s
Website: 16-bit pixel-art rebuild with a live Three.js office, downloads from Gitea v1.5.1
- Title screen over a real-time voxel office rendered at low resolution and quantized to a rotating 32-colour palette with Bayer dithering; day part and season re-light the scene and every surface.
- 16-bit UI kit: name-plate dialogs, menu cursor, inventory, XP bar, badges, NPC speech, GAME OVER with CONTINUE, hand-placed 12x12 icons, Fusion Pixel font (Latin subset preloaded).
- Sections as a game: quest log (onboarding), character select (AI CEO / AI Co-Founder), inventory (features), party roster (providers), live download XP, save point (all v1.5.1 builds), FAQ as NPC dialog, credits.
- Downloads and source point to the Gitea release; the download function only redirects to git.zacharyzhang.com.
- Tailwind and the old components removed; unit tests for platform/downloads, rewritten e2e suite.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 23:37:23 -04:00

52 lines
1.6 KiB
TypeScript

"use client";
import { useEffect, useId, useRef, useState, type CSSProperties } from "react";
import styles from "./pixel.module.css";
const SEGMENTS = 20;
/** A segmented XP bar that ticks up one block at a time the first time it scrolls into view. */
export function XpBar({ value, max, label }: { value: number; max: number; label: string }) {
const ref = useRef<HTMLDivElement>(null);
const [playing, setPlaying] = useState(false);
const labelId = useId();
const current = Math.max(0, Math.min(max, value));
const lit = Math.round((current / max) * SEGMENTS);
useEffect(() => {
const observer = new IntersectionObserver(([entry]) => {
if (!entry?.isIntersecting) return;
setPlaying(true);
observer.disconnect();
});
observer.observe(ref.current!);
return () => observer.disconnect();
}, []);
return (
<div ref={ref} className={styles.xp} data-playing={playing ? "" : undefined}>
<div className={styles.xpHead}>
<span id={labelId}>{label}</span>
<span className={styles.xpNumbers}>{current}/{max}</span>
</div>
<div
role="progressbar"
aria-labelledby={labelId}
aria-valuemin={0}
aria-valuemax={max}
aria-valuenow={current}
className={styles.xpTrack}
>
{Array.from({ length: SEGMENTS }, (_, index) => (
<span
key={index}
className={styles.xpSegment}
data-on={index < lit ? "" : undefined}
style={{ "--i": index } as CSSProperties}
/>
))}
</div>
</div>
);
}