Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion src/pages/about.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import styles from './about.module.css';
import Link from 'next/link';
import Image from 'next/image';

export default function About() {
return (
Expand All @@ -11,7 +12,15 @@ export default function About() {
</div>
<div className={styles['hero-illustration']}>
{/* Placeholder for the complex glowing keyboard illustration */}
<img src="/hero-keyboard.png" alt="neon keyboard" className={styles.keyboardImg} />
<Image
src="/hero-keyboard.png"
alt="neon keyboard"
className={styles.keyboardImg}
width={540}
height={300}
style={{ height: 'auto' }}
priority
/>
</div>
</div>

Expand Down
17 changes: 9 additions & 8 deletions src/pages/race.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useAuth } from '@/context/AuthContext';
import { ArrowLeft, RotateCcw, Settings } from 'lucide-react';
import Link from 'next/link';
import { useRouter } from 'next/router';
import { useEffect, useRef, useState } from 'react';
import { useEffect, useRef, useState, useCallback } from 'react';

export default function Race() {
const { user, saveTypingStat } = useAuth();
Expand All @@ -27,18 +27,13 @@ export default function Race() {
const [showSettings, setShowSettings] = useState(false);
const [sentenceInfo, setSentenceInfo] = useState(null);

// Fetch random sentence on component mount and when difficulty changes
useEffect(() => {
fetchNewSentence();
}, [difficulty]);

useEffect(() => {
if (!loading && inputRef.current) {
inputRef.current.focus();
}
}, [loading, raceStatus]); // Focus input when a new race starts

const fetchNewSentence = async () => {
const fetchNewSentence = useCallback(async () => {
setLoading(true);
try {
const response = await fetch(`/api/sentences?difficulty=${difficulty}&type=mixed`);
Expand All @@ -52,7 +47,12 @@ export default function Race() {
} finally {
setLoading(false);
}
};
}, [difficulty]);

// Fetch random sentence on component mount and when difficulty changes
useEffect(() => {
fetchNewSentence();
}, [fetchNewSentence]);

const endRace = async () => {
setTimerActive(false);
Expand Down Expand Up @@ -311,6 +311,7 @@ export default function Race() {
<input
ref={inputRef}
type="text"
onPaste={(e) => e.preventDefault()}
value={userInput}
onChange={handleInputChange}
placeholder="Start typing the sentence above..."
Expand Down