feat: responsive grid with scrollable area and fixed hint column
- Add CSS variables (--cell, --cell-font, --trigger-h) for responsive cell sizing - Shrink grid cells at 600px and 420px breakpoints - Add .page-body wrapper with 16px horizontal padding to prevent edge collisions - Separate hint column from scrollable grid: hints rendered outside the table in a fixed flex column, only the letter grid scrolls horizontally Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,41 +1,55 @@
|
||||
import React from 'react';
|
||||
import GameRow from './GameRow';
|
||||
import ActorPopover from './ActorPopover';
|
||||
|
||||
export default function GameGrid({ grid, width, middle }) {
|
||||
return (
|
||||
<table id="actors">
|
||||
<tbody>
|
||||
<div className="game-grid-area">
|
||||
<div className="hint-col">
|
||||
{grid.map((row, rowIndex) => {
|
||||
if (row.separator !== undefined) {
|
||||
return (
|
||||
<tr key={rowIndex} className="separator-row">
|
||||
<td />
|
||||
{Array.from({ length: middle }, (_, i) => (
|
||||
<td key={i} />
|
||||
))}
|
||||
<td className="letter-static separator-char">
|
||||
{row.separator === ' ' ? '' : row.separator}
|
||||
</td>
|
||||
{Array.from({ length: width - middle }, (_, i) => (
|
||||
<td key={middle + 1 + i} />
|
||||
))}
|
||||
</tr>
|
||||
);
|
||||
return <div key={rowIndex} className="hint-separator" />;
|
||||
}
|
||||
|
||||
return (
|
||||
<GameRow
|
||||
key={rowIndex}
|
||||
actorName={row.actorName}
|
||||
pos={row.pos}
|
||||
colStart={middle - row.pos}
|
||||
totalWidth={width}
|
||||
hintType={row.hintType}
|
||||
hintText={row.hintText}
|
||||
/>
|
||||
<div key={rowIndex} className="hint-cell">
|
||||
<ActorPopover hintType={row.hintType} hintText={row.hintText} />
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="game-grid-scroll">
|
||||
<table id="actors">
|
||||
<tbody>
|
||||
{grid.map((row, rowIndex) => {
|
||||
if (row.separator !== undefined) {
|
||||
return (
|
||||
<tr key={rowIndex} className="separator-row">
|
||||
{Array.from({ length: middle }, (_, i) => (
|
||||
<td key={i} />
|
||||
))}
|
||||
<td className="letter-static separator-char">
|
||||
{row.separator === ' ' ? '' : row.separator}
|
||||
</td>
|
||||
{Array.from({ length: width - middle }, (_, i) => (
|
||||
<td key={middle + 1 + i} />
|
||||
))}
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<GameRow
|
||||
key={rowIndex}
|
||||
actorName={row.actorName}
|
||||
pos={row.pos}
|
||||
colStart={middle - row.pos}
|
||||
totalWidth={width}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import React, { useRef, useCallback, useMemo } from 'react';
|
||||
import LetterInput from './LetterInput';
|
||||
import ActorPopover from './ActorPopover';
|
||||
|
||||
function isLetter(ch) {
|
||||
return /[a-zA-Z]/.test(ch);
|
||||
}
|
||||
|
||||
export default function GameRow({ actorName, pos, colStart, totalWidth, hintType, hintText }) {
|
||||
export default function GameRow({ actorName, pos, colStart, totalWidth }) {
|
||||
const inputRefs = useRef([]);
|
||||
const letters = actorName.split('');
|
||||
|
||||
@@ -29,9 +28,6 @@ export default function GameRow({ actorName, pos, colStart, totalWidth, hintType
|
||||
|
||||
return (
|
||||
<tr>
|
||||
<td>
|
||||
<ActorPopover hintType={hintType} hintText={hintText} />
|
||||
</td>
|
||||
{Array.from({ length: totalWidth + 1 }, (_, colIndex) => {
|
||||
const charIndex = colIndex - colStart;
|
||||
const isInRange = charIndex >= 0 && charIndex < letters.length;
|
||||
|
||||
Reference in New Issue
Block a user