diff --git a/frontend/src/components/SolveHeatmap.tsx b/frontend/src/components/SolveHeatmap.tsx new file mode 100644 index 0000000..63b832f --- /dev/null +++ b/frontend/src/components/SolveHeatmap.tsx @@ -0,0 +1,45 @@ +import { useTranslation } from 'react-i18next' +import { useStore } from '../store' + +export default function SolveHeatmap() { + const { t } = useTranslation() + const puzzle = useStore((s) => s.puzzle) + const cellStatus = useStore((s) => s.cellStatus) + const cellEverWrong = useStore((s) => s.cellEverWrong) + + if (!puzzle) return null + + const size = Math.min(200, window.innerWidth - 40) + const cellW = size / puzzle.width + const cellH = size / puzzle.height + + function cellColor(r: number, c: number): string { + if (puzzle!.cells[r][c] === 'black') return 'var(--cell-black, #1a1a2e)' + if (cellStatus[r]?.[c] === 'revealed') return 'var(--heatmap-hint, #f59e0b)' + if (cellEverWrong[r]?.[c]) return 'var(--heatmap-wrong, #ef4444)' + return 'var(--heatmap-clean, #22c55e)' + } + + return ( +
+

{t('heatmap.title')}

+ + {Array.from({ length: puzzle.height }, (_, r) => + Array.from({ length: puzzle.width }, (_, c) => ( + + )) + )} + +
+ {t('heatmap.clean')} + {t('heatmap.hinted')} + {t('heatmap.wrong')} +
+
+ ) +}