summaryrefslogtreecommitdiff
path: root/src/components/grid/Cell.tsx
blob: 1a21164bc5f64bc69ff0ea01eff9363191204cfe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import type { GridCell } from '@/types/grid';
import { getStyleForAnsiColor } from '@/utils/ansi';

interface CellProps {
    cell: GridCell;
    onClick?: () => void;
    onMouseEnter?: () => void;
}

export const Cell: React.FC<CellProps> = ({ cell, onClick, onMouseEnter }) => {
    const handleMouseDown = (e: React.MouseEvent) => {
        e.preventDefault(); // Prevent text selection
        onClick?.();
    };

    return (
        <span
            className={`grid-cell ${onClick ? 'highlightable' : ''}`}
            onMouseDown={handleMouseDown}
            onMouseEnter={onMouseEnter}
            style={getStyleForAnsiColor(cell.color)}
        >
            {cell.char === ' ' ? '\u00A0' : cell.char}
        </span>
    );
};