summaryrefslogtreecommitdiff
path: root/app/client/common/buttonGrid.component.js
blob: 4b86d629b67f1e5191e42e883c2243e48c89c58d (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
27
28
29
30
31
32
import { h, Component } from 'preact'

export default function ButtonGrid(props) {
  const max = props.max || Infinity
  return (
    <table className='buttonGrid'>
      <tr className='row'>
        <th>{" "}</th>
        {props.x.map(x => (
          <th>{x}</th>
        ))}
      </tr>          
      {props.y.map(y => (
        <tr className='row'>
          <th>{y}</th>
          {props.x.map(x => (
            <td>
              {x * y > max ? " " :
                <button
                  onClick={() => props.onClick(x, y)}
                  onMouseEnter={() => props.onHover(x, y)}
                >
                  {" "}
                </button>
              }
            </td>
          ))}
        </tr>
      ))}
    </table>
  )
}