aboutsummaryrefslogtreecommitdiff
path: root/web/src/App.tsx
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2025-09-30 13:15:59 +0200
committersrdusr <trevorgray@srdusr.com>2025-09-30 13:15:59 +0200
commit18a1b361a9d6567b87c49e8bbbf0bba9ba51687f (patch)
tree4892a7d495e44b31bb51a1e24748dcdbe57629da /web/src/App.tsx
parent8d60c7f93407988ee0232ea90980028f299cb0f3 (diff)
downloadtyperpunk-18a1b361a9d6567b87c49e8bbbf0bba9ba51687f.tar.gz
typerpunk-18a1b361a9d6567b87c49e8bbbf0bba9ba51687f.zip
TUI: fixed wpm history/made UI more identical to web/ctrl-backspace behaviour/improved accuracy
Web: improved category selection/fixed endscreen responsiveness inconsistency/mistake tracking/clean game memory after use/improve general UI
Diffstat (limited to 'web/src/App.tsx')
-rw-r--r--web/src/App.tsx17
1 files changed, 10 insertions, 7 deletions
diff --git a/web/src/App.tsx b/web/src/App.tsx
index b34c4b4..9b266d9 100644
--- a/web/src/App.tsx
+++ b/web/src/App.tsx
@@ -108,7 +108,10 @@ function App() {
const { game, resetGame, cleanupGame } = useCoreGame();
const [allTexts, setAllTexts] = useState<TextItem[]>(LOCAL_TEXTS);
const [categories, setCategories] = useState<string[]>(uniqueCategories(LOCAL_TEXTS));
- const [selectedCategory, setSelectedCategory] = useState<string>('random');
+ const [selectedCategory, setSelectedCategory] = useState<string>(() => {
+ const saved = localStorage.getItem('typerpunk:last_mode');
+ return saved || 'random';
+ });
const [gameState, setGameState] = useState<GameState>({
screen: 'main-menu',
currentText: '',
@@ -140,12 +143,7 @@ function App() {
}));
const testText = "This is a test sentence for the end screen. It has some text to display and check for errors.";
const testUserInput = "This is a test sentance for the end screen. It has sone text to display and check for erors.";
- const _testCharTimings = testText.split('').map((char, i) => ({
- time: (i / testText.length) * 60,
- isCorrect: char === (testUserInput[i] || ''),
- char: char,
- index: i
- }));
+ // removed unused _testCharTimings
const [lastTest, setLastTest] = useState<{ stats: Stats; wpmHistory: Array<{ time: number; wpm: number; raw: number; isError: boolean }>; text: string; userInput: string; charTimings?: Array<{ time: number; isCorrect: boolean; char: string; index: number }>; keypressHistory?: Array<{ time: number; index: number; isCorrect: boolean }> } | null>(null);
// Removed unused Enter key end-screen toggle handler
@@ -167,6 +165,10 @@ function App() {
})();
}, []);
+ useEffect(() => {
+ try { localStorage.setItem('typerpunk:last_mode', selectedCategory); } catch {}
+ }, [selectedCategory]);
+
const handleStartGame = async () => {
try {
// Reset game state first
@@ -402,6 +404,7 @@ function App() {
categories={categories}
selectedCategory={selectedCategory}
onSelectCategory={setSelectedCategory}
+ startLabel={`Start: ${selectedCategory === 'random' ? 'Random' : selectedCategory.charAt(0).toUpperCase() + selectedCategory.slice(1)}`}
/>
) : gameState.screen === 'end-screen' ? (
<EndScreen