import * as React from "react";
import * as _ from "lodash";
import { IButtonGridProps } from "./@types";
import { ButtonGridButton } from "./ButtonGridButton";
export function ButtonGrid(props: IButtonGridProps) {
function rowHTML(row: number) {
return (
{_.times(props.numColumns, col =>
ButtonGridButton(col, props, row, handleClick)
)}
);
}
function handleClick(
e: React.MouseEvent,
row: number,
col: number
) {
props.onButtonDown(row, col);
}
return (
{_.times(props.numRows, rowHTML)}
);
}
ButtonGrid.defaultProps = {
numRows: 4,
numColumns: 4,
onButtonDown: (row: number, column: number) => {},
style: { color: "white" },
clickColor: "pink"
};