-
Notifications
You must be signed in to change notification settings - Fork 0
Free‑typing Timed Mode (No Forced Mistake Fix), Uncapped Public Lobbies, and Docs/Leaderboard UX Refresh #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
af43c25
d244ac4
07b2021
11d0a3b
3db0793
e6f5bbb
9271b43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -205,7 +205,40 @@ function Leaderboard({ defaultDuration = 15, defaultPeriod = 'alltime', layoutMo | |||||
| {error && <p className="error-message">Error: {error}</p>} | ||||||
| {(hasLoadedOnce ? !showSpinner : !loading) && !error && ( | ||||||
| <div className="leaderboard-list"> | ||||||
| {leaderboard.length > 0 ? ( leaderboard.map((entry, index) => ( <div key={`${entry.user_id}-${entry.created_at}`} className={`leaderboard-item ${user && entry.netid === user.netid ? 'current-user' : ''}`}> <span className="leaderboard-rank">{index + 1}</span> <div className="leaderboard-player"> <div className="leaderboard-avatar" onClick={() => handleAvatarClick(entry.avatar_url, entry.netid)} title={`View ${entry.netid}\'s avatar`}> <img src={entry.avatar_url || defaultProfileImage} alt={`${entry.netid} avatar`} onError={(e) => { e.target.onerror = null; e.target.src=defaultProfileImage; }} /> </div> <span className="leaderboard-netid">{entry.netid}</span> </div> <div className="leaderboard-stats"> <span className="leaderboard-wpm">{parseFloat(entry.adjusted_wpm).toFixed(0)} WPM</span> <span className="leaderboard-accuracy">{parseFloat(entry.accuracy).toFixed(1)}%</span> <span className="leaderboard-date">{period === 'daily' ? formatRelativeTime(entry.created_at) : new Date(entry.created_at).toLocaleDateString()}</span> </div> </div> )) ) : ( <p className="no-results">No results found for this leaderboard.</p> )} | ||||||
| {leaderboard.length > 0 ? ( | ||||||
| leaderboard.map((entry, index) => ( | ||||||
| <div | ||||||
| key={`${entry.user_id}-${entry.created_at}`} | ||||||
| className={`leaderboard-item ${user && entry.netid === user.netid ? 'current-user' : ''}`} | ||||||
| > | ||||||
| <span className="leaderboard-rank">{index + 1}</span> | ||||||
| <div | ||||||
| className={`leaderboard-player ${authenticated ? 'clickable' : 'disabled'}`} | ||||||
| onClick={authenticated ? () => handleAvatarClick(entry.avatar_url, entry.netid) : undefined} | ||||||
| title={authenticated ? `View ${entry.netid}'s profile` : 'Log in to view profiles'} | ||||||
| role={authenticated ? 'button' : undefined} | ||||||
| tabIndex={authenticated ? 0 : -1} | ||||||
| onKeyDown={authenticated ? (e => { if (e.key === 'Enter' || e.key === ' ') handleAvatarClick(entry.avatar_url, entry.netid); }) : undefined} | ||||||
| > | ||||||
| <div className="leaderboard-avatar"> | ||||||
| <img | ||||||
| src={entry.avatar_url || defaultProfileImage} | ||||||
| alt={`${entry.netid} avatar`} | ||||||
| onError={(e) => { e.target.onerror = null; e.target.src=defaultProfileImage; }} | ||||||
| /> | ||||||
| </div> | ||||||
| <span className="leaderboard-netid">{entry.netid}</span> | ||||||
| </div> | ||||||
| <div className="leaderboard-stats"> | ||||||
| <span className="leaderboard-wpm">{parseFloat(entry.adjusted_wpm).toFixed(0)} WPM</span> | ||||||
| <span className="leaderboard-accuracy">{parseFloat(entry.accuracy).toFixed(1)}%</span> | ||||||
| <span className="leaderboard-date">{period === 'daily' ? formatRelativeTime(entry.created_at) : new Date(entry.created_at).toLocaleDateString()}</span> | ||||||
| </div> | ||||||
| </div> | ||||||
| )) | ||||||
| ) : ( | ||||||
| <p className="no-results">No results found for this leaderboard.</p> | ||||||
| )} | ||||||
| </div> | ||||||
| )} | ||||||
| <p className="leaderboard-subtitle">Resets daily at 12:00 AM EST</p> | ||||||
|
|
@@ -257,12 +290,15 @@ function Leaderboard({ defaultDuration = 15, defaultPeriod = 'alltime', layoutMo | |||||
| className={`leaderboard-item ${user && entry.netid === user.netid ? 'current-user' : ''}`} | ||||||
| > | ||||||
| <span className="leaderboard-rank">{index + 1}</span> | ||||||
| <div className="leaderboard-player"> | ||||||
| <div | ||||||
| className={`leaderboard-avatar ${!authenticated ? 'disabled' : ''}`} | ||||||
| onClick={authenticated ? () => handleAvatarClick(entry.avatar_url, entry.netid) : undefined} | ||||||
| title={authenticated ? `View ${entry.netid}\'s profile` : 'Log in to view profiles'} | ||||||
| > | ||||||
| <div | ||||||
| className={`leaderboard-player ${authenticated ? 'clickable' : 'disabled'}`} | ||||||
| onClick={authenticated ? () => handleAvatarClick(entry.avatar_url, entry.netid) : undefined} | ||||||
| title={authenticated ? `View ${entry.netid}'s profile` : 'Log in to view profiles'} | ||||||
| role={authenticated ? 'button' : undefined} | ||||||
| tabIndex={authenticated ? 0 : -1} | ||||||
| onKeyDown={authenticated ? (e => { if (e.key === 'Enter' || e.key === ' ') handleAvatarClick(entry.avatar_url, entry.netid); }) : undefined} | ||||||
|
||||||
| onKeyDown={authenticated ? (e => { if (e.key === 'Enter' || e.key === ' ') handleAvatarClick(entry.avatar_url, entry.netid); }) : undefined} | |
| onKeyDown={authenticated ? (e => { if (e.key === 'Enter' || e.key === ' ') { if (e.key === ' ') e.preventDefault(); handleAvatarClick(entry.avatar_url, entry.netid); } }) : undefined} |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -35,6 +35,7 @@ function TestConfigurator({ | |||||
| onShowLeaderboard, | ||||||
| isLobby = false, | ||||||
| snippetError = null, | ||||||
| allowTimed = true, | ||||||
| }) { | ||||||
|
|
||||||
| const [subjects, setSubjects] = React.useState(['all']); | ||||||
|
|
@@ -68,6 +69,21 @@ function TestConfigurator({ | |||||
| fetchDifficulties(); | ||||||
| }, [snippetCategory, snippetSubject]); | ||||||
|
|
||||||
| // If timed mode is disallowed (e.g., private lobbies), coerce to snippet mode | ||||||
| React.useEffect(() => { | ||||||
| if (!allowTimed && testMode === 'timed') { | ||||||
|
Comment on lines
+73
to
+74
|
||||||
| // Update race state first so the server/client agree on mode | ||||||
| setRaceState(prev => ({ | ||||||
| ...prev, | ||||||
| timedTest: { ...prev.timedTest, enabled: false }, | ||||||
| settings: { ...(prev.settings||{}), testMode: 'snippet' } | ||||||
| })); | ||||||
| setTestMode('snippet'); | ||||||
| // Load a snippet immediately to reflect the change | ||||||
| setTimeout(() => { loadNewSnippet && loadNewSnippet(); }, 0); | ||||||
| } | ||||||
| }, [allowTimed, testMode, setRaceState, setTestMode, loadNewSnippet]); | ||||||
|
||||||
| }, [allowTimed, testMode, setRaceState, setTestMode, loadNewSnippet]); | |
| }, [allowTimed, testMode, setRaceState, setTestMode]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When handling keyboard events for accessibility, the Space key press should call
e.preventDefault()to prevent the page from scrolling. Adde.preventDefault();before callinghandleAvatarClickwhen Space is pressed.