import type { GameStats, SolverReplay } from '@wordle/shared';
interface Screen3ResultsProps {
won: boolean;
attemptCount: number;
revealedWord: string | null;
stats: GameStats;
replays?: SolverReplay[];
onPlayAgain?: () => void;
}
function Histogram({ stats }: { stats: GameStats }) {
if (stats.gamesPlayed === 0) return
No games yet.
;
const maxCount = Math.max(...stats.histogram, 1);
return (
{stats.histogram.map((count, idx) => {
const label = idx < 6 ? `${idx + 1}` : 'X';
const pct = (count / maxCount) * 100;
return (
{label}
0 ? '#6aaa64' : '#d3d6da', width: `${Math.max(pct, count > 0 ? 5 : 0)}%`, minWidth: count > 0 ? '12px' : '4px', borderRadius: '2px' }} />
{count}
);
})}
);
}
const MINI_COLORS: Record
= { g: '#6aaa64', y: '#c9b458', x: '#787c7e' };
function MiniBoard({ replay }: { replay: SolverReplay }) {
return (
{replay.solver}
{replay.steps.map((step, rowIdx) => (
{step.guess.split('').map((letter, colIdx) => {
const c = step.colors[colIdx];
const bg = MINI_COLORS[c] ?? '#d3d6da';
return (
{letter}
);
})}
))}
);
}
export function Screen3Results({ won, attemptCount, revealedWord, stats, replays, onPlayAgain }: Screen3ResultsProps) {
return (
{won ? '🎉 Congratulations!' : 'Better luck next time'}
{won ? (
Solved in {attemptCount} {attemptCount === 1 ? 'attempt' : 'attempts'}
) : (
revealedWord &&
The word was: {revealedWord.toUpperCase()}
)}
Statistics
{stats.gamesPlayed}
Played
{stats.gamesPlayed > 0 ? Math.round((stats.wins / stats.gamesPlayed) * 100) : 0}%
Win Rate
{stats.currentStreak}
Streak
{stats.maxStreak}
Max Streak
{replays && replays.length > 0 && (
How the solvers cracked this word:
{replays.map((r) => (
))}
)}
{onPlayAgain && (
)}
);
}