Code Monkey home page Code Monkey logo

rgx's Introduction

Rgx

React grid system – constraint-based responsive grid with no CSS and no media queries.

About

Rgx is an experimental, responsive grid system based on minimum and maximum widths and designed for content-out layout. Rgx is built purely in React and uses inline styles, with no CSS and no media queries. Each Grid row sets its child Cells to display inline block once the Grid is wide enough to fit all Cells’ minimum widths. Once set inline, each Cell’s width is based on the ratio of its own minimum width to the sum of minimum widths per row. Once a Cell hits its max-width, the remaining space is distributed to other Cells in the row. Since this isn’t based on viewport-based media queries, the Grid responds to its own width, similar to element queries.

Getting Started

npm i rgx
import React from 'react'
import { Grid, Cell } from 'rgx'

class Demo extends React.Component {
  render () {
    return (
      <Grid gutter={8}>
        <Cell min={256} max={320}>Min 256 Max 320</Cell>
        <Cell min={768}>Min 768</Cell>
      </Grid>
    )
  }
}

React.render(<Demo />, document.querySelector('#demo'))

Grid Component

Props

  • gutter - pixel value to set negative margins on the Grid component and padding on Cell components to create gutters.
  • min - pixel value to set a default min prop for child Cells

Cell Component

Props

  • min - pixel value to set the min-width at which a Cell is displayed inline.
  • max - pixel value at which the Cell should not expand. Remaining space is distributed to other Cells.
  • padding - sets left and right padding. This is used by the Grid component when the gutter prop is set and the Cell has no padding set.
  • width - fraction value used by the Grid component to set a width. This can also be set manually when used independently from the Grid component
  • inline - boolean value used by the Grid component to display a Cell inline.

Performance

I have yet to do any performance audits, and since the Grid component listens to window resize events, this probably has some performance issues. Any help in that area would be greatly appreciated.

MIT License

rgx's People

Contributors

jxnblk avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.