summaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authorElizabeth Hunt <me@liz.coffee>2025-10-04 18:36:10 -0700
committerElizabeth Hunt <me@liz.coffee>2025-10-04 18:36:10 -0700
commit35add63ec4dce39710095f17abd86777de9e5b49 (patch)
tree1afdf952f310e09a663e85541474efdc95155a73 /src/components
parent507c972ecafeceaf4f8962ad881f8fb50c9b86c1 (diff)
downloadansicolor-35add63ec4dce39710095f17abd86777de9e5b49.tar.gz
ansicolor-35add63ec4dce39710095f17abd86777de9e5b49.zip
Working history state
Diffstat (limited to 'src/components')
-rw-r--r--src/components/grid/Cell.tsx19
-rw-r--r--src/components/grid/GridComponent.tsx30
2 files changed, 49 insertions, 0 deletions
diff --git a/src/components/grid/Cell.tsx b/src/components/grid/Cell.tsx
new file mode 100644
index 0000000..fe91da8
--- /dev/null
+++ b/src/components/grid/Cell.tsx
@@ -0,0 +1,19 @@
+import type { GridCell } from '@/types/grid';
+import { getStyleForAnsiColor } from '@/utils/ansi';
+
+interface CellProps {
+ cell: GridCell;
+ onClick?: () => void;
+}
+
+export const Cell: React.FC<CellProps> = ({ cell, onClick }) => {
+ return (
+ <span
+ className={`grid-cell ${onClick ? 'highlightable' : ''}`}
+ onMouseDown={onClick}
+ style={getStyleForAnsiColor(cell.color)}
+ >
+ {cell.char === ' ' ? '\u00A0' : cell.char}
+ </span>
+ );
+};
diff --git a/src/components/grid/GridComponent.tsx b/src/components/grid/GridComponent.tsx
new file mode 100644
index 0000000..75d65aa
--- /dev/null
+++ b/src/components/grid/GridComponent.tsx
@@ -0,0 +1,30 @@
+import React from 'react';
+
+import type { Grid, GridCell } from '@/types/grid';
+import { Cell } from '@/components/grid/Cell';
+
+interface GridProps {
+ grid: Grid;
+ onCellInteract?: (cell: GridCell) => void;
+}
+
+export const GridComponent: React.FC<GridProps> = ({
+ grid,
+ onCellInteract,
+}) => {
+ return (
+ <div className='grid'>
+ {grid.map((row, i) => (
+ <div className='grid-row' key={i}>
+ {row.map((cell, j) => (
+ <Cell
+ key={j}
+ cell={cell}
+ onClick={() => onCellInteract?.(cell)}
+ />
+ ))}
+ </div>
+ ))}
+ </div>
+ );
+};