feat: integrate GameRow into GameGrid

This commit is contained in:
thibaud-leclere
2026-03-28 13:19:44 +01:00
parent 29667f0b1e
commit 6290cef3fe

View File

@@ -1,25 +1,18 @@
import React from 'react'; import React from 'react';
import GameRow from './GameRow';
export default function GameGrid({ grid, width, middle }) { export default function GameGrid({ grid, width, middle }) {
return ( return (
<table id="actors"> <table id="actors">
<tbody> <tbody>
{grid.map((row, rowIndex) => ( {grid.map((row, rowIndex) => (
<tr key={rowIndex}> <GameRow
{Array.from({ length: width + 1 }, (_, colIndex) => { key={rowIndex}
const start = middle - row.pos; actorName={row.actorName}
const charIndex = colIndex - start; pos={row.pos}
const name = row.actorName; colStart={middle - row.pos}
const isInRange = charIndex >= 0 && charIndex < name.length; totalWidth={width}
const isHighlighted = charIndex === row.pos; />
return (
<td key={colIndex} style={isHighlighted ? { color: 'red' } : undefined}>
{isInRange ? name[charIndex].toUpperCase() : ''}
</td>
);
})}
</tr>
))} ))}
</tbody> </tbody>
</table> </table>