atable
it's a table
$ npm install atable
comes with no styling of it's own, it's completely up to you on how to render your Cells.
why?
a very simple, declarative way of generating tables, define your table as if it was rendering just one row and pass an array of datums.
usage
simple
const Table THead Row Cell TBody = module { return <Table> <THead> <Row> <Cell>Hello</Cell> <Cell>Data</Cell> </Row> </THead> <TBody> <Row> <Cell>Something</Cell> <Cell>Else</Cell> </Row> <Row> <Cell>Another</Cell> <Cell>Row</Cell> </Row> </TBody> </Table> }
with data array
const Table THead Row Cell TBody = module { const data = a: 1 b: 2 c: 3 return <Table data=data rowClassName='row' cellClassName='cell'> <THead> <Row> <Cell>Hello</Cell> <Cell colSpan=2>Data</Cell> </Row> </THead> <TBody> <Row> <Cell> datuma</Cell> <Cell>datumb rowIdx</Cell> <Cell> datumc</Cell> </Row> </TBody> </Table> }
possibly render multiple rows per datum
const Table THead Row Cell TBody = module { const data = a: 1 b: 2 c: 3 a: 4 b: 5 c: 6 return <Table data=data rowClassName='row' cellClassName='cell'> <THead> <Row> <Cell>Hello</Cell> <Cell colSpan=2>Data</Cell> </Row> </THead> <TBody> <Row> <Cell> datuma</Cell> <Cell> datumb</Cell> <Cell> datumc</Cell> </Row> idx % 2 === 0 && <Row className='row--even'> <Cell> datuma</Cell> <Cell> datumb</Cell> <Cell> datumc</Cell> </Row> </TBody> </Table> }
more advanced example with keys (recommended for efficient re-renders)
const Table THead Row Cell TBody = module { const data = id: '309hj24g0ih2g3' a: 1 b: 2 c: 3 return <Table data=data rowClassName='row' cellClassName='cell'> <THead> <Row> <Cell>Hello</Cell> <Cell colSpan=3>Data</Cell> </Row> </THead> <TBody> <Row getKey= datumid> <Cell> datuma</Cell> <Cell>idx</Cell> <Cell>datumb idx</Cell> <Cell> datumc</Cell> </Row> </TBody> </Table> }