Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

atable

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

atable

it's a table

  • 0.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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 } = require('atable')

module.exports = function Example () {
  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 } = require('atable')

module.exports = function Example () {
  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>{(datum) => datum.a}</Cell>
          {(datum, rowIdx) => (<Cell>{datum.b} {rowIdx}</Cell>)}
          <Cell>{(datum) => datum.c}</Cell>
        </Row>
      </TBody>
    </Table>
  )
}

possibly render multiple rows per datum

const { Table, THead, Row, Cell, TBody } = require('atable')

module.exports = function Example () {
  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>{(datum) => datum.a}</Cell>
          <Cell>{(datum) => datum.b}</Cell>
          <Cell>{(datum) => datum.c}</Cell>
        </Row>
        {(_, idx) => (idx % 2 === 0) && (
          <Row className='row--even'>
            <Cell>{(datum) => datum.a}</Cell>
            <Cell>{(datum) => datum.b}</Cell>
            <Cell>{(datum) => datum.c}</Cell>
          </Row>
        )}
      </TBody>
    </Table>
  )
}
const { Table, THead, Row, Cell, TBody } = require('atable')

module.exports = function Example () {
  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>
        {(datum, idx) => (
          <Row getKey={(datum) => datum.id}>
            <Cell>{(datum) => datum.a}</Cell>
            {(datum) => (<Cell>{idx}</Cell>)}
            {(datum, idx) => (<Cell>{datum.b} {idx}</Cell>)}
            <Cell>{(datum) => datum.c}</Cell>
          </Row>
        )}
      </TBody>
    </Table>
  )
}

FAQs

Package last updated on 12 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc