buzzword-bingo/src/app/components/bingo.tsx

22 lines
466 B
TypeScript
Raw Normal View History

2023-11-02 23:08:51 +01:00
import BingoRow from './bingorow.tsx'
2023-11-02 23:38:12 +01:00
interface Props{
size: number;
items: string[];
}
export default function Bingo({size, items}: Props){
let rows: string[][] = [];
2023-11-03 03:41:08 +01:00
for(let i = 0; i < (items.length / size); i++)
2023-11-02 23:38:12 +01:00
{
rows[i] = items.slice(i * size, (i + 1) * size);
}
2023-11-02 23:08:51 +01:00
return(
2023-11-03 03:41:08 +01:00
<table className='w-1/2 table bg-primary text-primary-content m-auto'>
2023-11-02 23:08:51 +01:00
<tbody>
2023-11-02 23:38:12 +01:00
{rows.map((item, index) => <BingoRow key={index} items={item}/>)}
2023-11-02 23:08:51 +01:00
</tbody>
</table>
);
}