This commit is contained in:
polwex 2026-03-25 23:24:54 +09:00
parent 0734364269
commit 4d3395fa1c
10 changed files with 1560 additions and 9 deletions

32
CLAUDE.md Normal file
View file

@ -0,0 +1,32 @@
# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## What This Is
A typing tutor app for a child (Leo), built with React 19 + TypeScript + Vite. Uses Bun as the package manager/runtime.
## Commands
- `bun run dev` — start dev server
- `bun run build` — typecheck (`tsc -b`) then build for production
- `bun run lint` — ESLint
- `bun run preview` — serve production build locally
## Architecture
**Modes** — The app has four tabs, each a top-level component rendered by `App.tsx`:
- **LessonMode** — structured lessons with progressive key introduction; lessons unlock sequentially (90%+ accuracy required)
- **FreeMode** — free typing practice using random quotes
- **GameMode** — arcade-style falling-words game with combo system and sound effects
- **StatsView** — charts (recharts) showing WPM/accuracy trends and per-key heatmaps
**Core hook: `useTypingEngine`** — shared typing logic used by LessonMode and FreeMode. Tracks cursor position, errors, WPM (updated every 500ms), per-key hit/miss stats, and fires `onComplete` when text is finished. GameMode has its own input handling since its mechanics differ (falling words, not linear text).
**State: `useStats`** — persists `UserProgress` (completed lessons, session history, game high score) to localStorage under key `leo-typing-progress`.
**Sound: `sounds.ts`** — all audio is synthesized via Web Audio API oscillators (no audio files). Exports: `playKeyClick`, `playWordComplete`, `playCombo`, `playMiss`, `playGameOver`.
**Data files** — `src/data/lessons.ts` (lesson definitions with word lists), `src/data/quotes.ts` (free mode texts), `src/data/keyboard.ts` (key-to-finger mapping for the visual keyboard).
**Styling** — CSS Modules (`src/styles/*.module.css`) plus a global stylesheet.