All Projects → noderaider → Gridiron

noderaider / Gridiron

Feature-Packed React Grid Framework

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Gridiron

Niui
Lightweight, feature-rich, accessible front-end library
Stars: ✭ 152 (+1800%)
Mutual labels:  grid, cards, accordion
React Datepicker
An easily internationalizable, accessible, mobile-friendly datepicker library for the web, build with styled-components.
Stars: ✭ 252 (+3050%)
Mutual labels:  grid, styled-components
Styled Components Grid
A responsive grid components for styled-components.
Stars: ✭ 218 (+2625%)
Mutual labels:  grid, styled-components
rebass
⚛️ React primitive UI components built with styled-system.
Stars: ✭ 7,844 (+97950%)
Mutual labels:  grid, styled-components
React Awesome Styled Grid
A responsive 8-point grid system layout for React using styled-components
Stars: ✭ 157 (+1862.5%)
Mutual labels:  grid, styled-components
Grid
This package has moved and renamed
Stars: ✭ 2,079 (+25887.5%)
Mutual labels:  grid, styled-components
Music163 React
🔥基于React全家桶开发:「网易云音乐PC端项目」实战
Stars: ✭ 209 (+2512.5%)
Mutual labels:  immutable, styled-components
Griz
Grid library for React; Rescue the cat
Stars: ✭ 99 (+1137.5%)
Mutual labels:  grid, styled-components
Vxe Table
🐬 vxe-table vue 表格解决方案
Stars: ✭ 4,242 (+52925%)
Mutual labels:  grid, pager
Maroto
A maroto way to create PDFs. Maroto is inspired in Bootstrap and uses gofpdf. Fast and simple.
Stars: ✭ 334 (+4075%)
Mutual labels:  fast, grid
React Styled Flexboxgrid
Grid system based on styled-components and flexbox for React
Stars: ✭ 515 (+6337.5%)
Mutual labels:  grid, styled-components
Flutter graphite
Flutter widget to draw interactive direct graphs (flowcharts) of any complexity in a tile rectangular manner.
Stars: ✭ 23 (+187.5%)
Mutual labels:  graph, grid
React Flexa
Responsive React Flexbox (CSS Flexible Box Layout Module) grid system based heavily on the standard CSS API.
Stars: ✭ 120 (+1400%)
Mutual labels:  grid, styled-components
Styled Bootstrap Components
The bootstrap components made with styled-components 💅
Stars: ✭ 196 (+2350%)
Mutual labels:  grid, styled-components
Re Jok
A React UI Component library built with styled-components
Stars: ✭ 102 (+1175%)
Mutual labels:  grid, styled-components
React Cloud Music
React 16.8打造精美音乐WebApp
Stars: ✭ 1,722 (+21425%)
Mutual labels:  immutable, styled-components
React Rasta
React Rasta is a powerful and flexible grid system for React
Stars: ✭ 88 (+1000%)
Mutual labels:  grid, styled-components
jojo-cards
Card game based on Jojo's Bizarre Adventure (ジョジョの奇妙な冒険)
Stars: ✭ 112 (+1300%)
Mutual labels:  styled-components, cards
Styled Css Grid
🍱 A tiny CSS grid layout for React
Stars: ✭ 562 (+6925%)
Mutual labels:  grid, styled-components
Cr
Runs your tasks at maximum concurrency
Stars: ✭ 681 (+8412.5%)
Mutual labels:  graph, fast

NPM

Feature-Packed Grid Framework for React and ImmutableJS

❗️ Demo at gridiron.js.org

Build Status codecov

NPM


Install

npm install -S gridiron gridiron-modules

For easiest usage across an application, setup a gridiron.js file in a modules folder with the following content:

import gridiron from 'gridiron'
import gridironModules from 'gridiron-modules'

/** Factory that imports all of the gridiron components and feeds them your apps version of its dependencies (React, ReactDOM, addons, etc.) */
export default gridiron(gridironModules(), { themeName: 'mellow' })

Components

pager

All components should be wrapped in a pager component whether you want the data displayed in pages or not. The pager is responsible for taking data from redux and mapping it to the format that the grid and other components expect. Sorting, filtering, and partitioning of the data all occurs at the pager level. By filtering and sorting as early as possible in the rendering hierarchy, gridiron components are able to render fast and bypass unnecessary data.

PropTypes

name type description
documentsPerPage `number null`
columns array an array of the column IDs that will be passed
map object how to break the data into documents and cells
mapEarlyProps function allows early lifecycle filtering of columns
sort object which columns to sort by
filterStream function how to filter the data

grid

A complex full example:

import React, { Component, PropTypes } from 'react'
import { connect } from 'react-redux'

import Immutable from 'immutable'
import Header from './Header'
import styles from './styles.css'

/** Import your applications namespaced gridiron components. */
import gridiron from './modules/gridiron'

const getFormName = columnID => `filter-form-${columnID}`
const getFilterName = documentID => `filter_${documentID}`

/** gridiron filters operate on streams: */
const createFilterStream = columnIDs => {
  const formNames = columnIDs.map(getFormName)
  return onFilter => {
    const unsubscribe = gridiron.formula.subscribe(formNames, formStates => {
      const filterState = columnIDs.reduce((result, columnID, i) => {
        const formState = formStates[i]
        const getFilterValue = documentID => formState ? formState.getIn([ getFilterName(documentID), 'value' ], false) : false
        return { ...result, [columnID]: getFilterValue }
      }, {})

      onFilter(filterState)
    })
    return unsubscribe
  }
}

const FilterForm = pure (
  { displayName: 'FilterForm'
  , propTypes:  { columnID: PropTypes.any
                , columnData: PropTypes.object.isRequired
                }
  , render() {
      const { columnData, columnID } = this.props
      const form = gridiron.formula(getFormName(this.props.columnID))
      return (
        <div>
          {columnData.entrySeq().map(([ documentID, cells ], documentIndex) => {
            const cellDatum = cells.get(columnID)
            return (
              <form.Field key={documentIndex} name={getFilterName(documentID)} type="checkbox"><pre>{JSON.stringify(cellDatum, null, 2)}</pre></form.Field>
            )
          })}
        </div>
      )
    }
  }
)

function mapStateToProps (state) {
  const meta = state.data.getIn([ 'meta' ], Immutable.Map())

  const columns = gridiron.Columns ( meta.get('columns', []).filter(x => x !== 'Alias')
                          , { 'Airline ID': { style: { flex: '0 0 2em', alignItems: 'center' }, className: styles.desktop }
                            , 'Name': { style: { flex: '2 0 7em' } }
                            , 'IATA': { style: { flex: '0 0 4em' } }
                            , 'ICAO': { style: { flex: '0 0 4em', alignItems: 'flex-start' } }
                            , 'Callsign': { style: { flex: '1 0 4em', alignItems: 'flex-start' } }
                            , 'Country': { style: { flex: '1 0 4em', alignItems: 'flex-start' } }
                            , 'Active': { style: { flex: '1 0 4em', alignItems: 'flex-start' } }
                            }
                          )
  return { columns }
}

export default connect(mapStateToProps) (
  class Grid extends Component {
    constructor (props) {
      super(props)
      this.state = { useContentHeight: false }
    }
    toggleFixedHeight = () => {
      const { useContentHeight } = this.state
      this.setState({ useContentHeight: !useContentHeight })
    };
    render() {
      const { container, columns } = this.props
      const { useContentHeight } = this.state

      /**
       * A Pager component is used to split the data with ImmutableJS and hand it
       * to the Grid component in a consistent manner.
       */
      return (
        <gridiron.Pager
          documentsPerPage={100}
          columns={columns.ids}
          filterStream={createFilterStream(columns.ids)}

          map={
            { documents: state => state.data.getIn([ 'results' ], Immutable.Map())
            , cells: (documentID, datum) => Immutable.Map(
                columns.ids.reduce((cells, columnID) => ({ ...cells, [columnID]: datum.get(columnID) }), {})
              )
            }
          }

          /** EARLY PROPS ({ documents }) -> WILL BYPASS UPDATES IF DEFINED HERE */
          mapEarlyProps={
            ({ documents, columnData }) => {
              const columnFilters = columns.reduce(columnID => <FilterForm columnData={columnData} columnID={columnID} />)
              return { columnFilters }
            }
          }

          sort={Immutable.fromJS({ cols: [ 'Airline ID', 'Name' ] })}
        >
          {pager => (
            <gridiron.Grid
                data={pager.status.get('data', Immutable.Map())}
                useContentHeight={useContentHeight}
                /* mapDocument allows creation of a document header and footer row
                mapDocument={(
                  { header: ({ local, documentID, documentIndex, document }) => (
                      <h3>{documentID}</h3>
                    )
                  , footer: ({ local, documentID, documentIndex, document }) => (
                      <h5 style={{ float: 'right' }}>({documentIndex + 1})</h5>
                    )
                  }
                )}
                */
                mapColumn={
                  { local: columnID => columns[columnID]
                  , header: ({ local, columnID, columnIndex }) => local ? (
                      <local.Header
                        actions={pager.actions}
                        fields={
                          { sort: pager.status.get('sort')
                          /*
                          , filter: true
                          , checkbox: true
                          , radio: [ { yes: 'Yes', no: 'No' }, 'yes' ]
                          */
                          }
                        }
                        paneContent={pager.earlyProps.columnFilters[columnID]}
                      >
                        {columnID}
                      </local.Header>
                    ) : null
                  , footer: ({ local, columnID, columnIndex }) => local ? (
                      <local.Footer />
                    ) : null
                  }
                }
                mapCell={({ local, documentIndex, columnIndex, documentID, columnID, datum }) => local ? (
                  <local.Cell documentID={documentID}>
                    {datum}
                  </local.Cell>
                ) : null}
                onDocumentClick={
                  ({ documentID, documentIndex }) => {
                    console.info(`DOCUMENT CLICKED => ${documentID}, ${documentIndex}`)
                  }
                }
                header={
                  [ <Header key="left" title="Grid" subtitle="swiss army knife" description="badass grid" />
                  , (
                      <span key="right" className={styles.controls}>
                        <button className={styles.expandButton} onClick={this.toggleFixedHeight}>
                            <i className="fa fa-arrows-v" />
                        </button>
                        {/*
                        <Controls key="maximize" />
                      */}
                      </span>
                    )
                  ]
                }
                footer={
                  [ (
                      <span key="footer-left">
                        <pager.Controls key="pager-buttons">
                          <pager.Select />
                        </pager.Controls>
                      </span>
                    )
                  , (
                      <span key="footer-center">
                        <pager.DocumentStatus key="pager-row-status" />
                        <pager.PageStatus key="pager-page-status" />
                      </span>
                    )
                  , (
                      <span key="footer-right">
                        <pager.DocumentsPerPage label="Documents Per Page" key="documents-per-page" />
                      </span>
                    )
                  ]
                }
                {...this.props}
              />
          )}
        </gridiron.Pager>
      )
    }
  }
)

accordion

Accordion documentation is coming soon!

cards

Cards documentation is coming soon!

graph

Graph documentation is coming soon!


Contributing

To setup gridiron for use in development run the following steps at CLI:

npm i -g [email protected]
git clone https://github.com/noderaider/gridiron
cd gridiron
lerna bootstrap
lerna run start

Then from your project:

npm link ../gridiron/packages/gridiron
# start your project, gridiron should hot reload as you update its source code.

Test

See gridiron's test project at gridiron-test

In active development, come back in a few days.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].