All Projects → garetmckinley → Hedron

garetmckinley / Hedron

Licence: mit
A no-frills flexbox grid system for React, powered by styled-components.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Hedron

Grid
This package has moved and renamed
Stars: ✭ 2,079 (+145.45%)
Mutual labels:  styled-components, flexbox
Griz
Grid library for React; Rescue the cat
Stars: ✭ 99 (-88.31%)
Mutual labels:  styled-components, flexbox
react-styled-flexbox
A Flexbox React component harnessing the power of styled-components
Stars: ✭ 30 (-96.46%)
Mutual labels:  styled-components, flexbox
React Flexa
Responsive React Flexbox (CSS Flexible Box Layout Module) grid system based heavily on the standard CSS API.
Stars: ✭ 120 (-85.83%)
Mutual labels:  styled-components, flexbox
React Styled Flexboxgrid
Grid system based on styled-components and flexbox for React
Stars: ✭ 515 (-39.2%)
Mutual labels:  styled-components, flexbox
Orbit
React components of open-source Orbit design system by Kiwi.com
Stars: ✭ 774 (-8.62%)
Mutual labels:  styled-components
Flexbox
CSS library for easier work with flex boxes
Stars: ✭ 17 (-97.99%)
Mutual labels:  flexbox
Styled Tools
Useful interpolated functions for CSS-in-JS
Stars: ✭ 761 (-10.15%)
Mutual labels:  styled-components
Cirrus
☁️ The CSS framework for the modern web.
Stars: ✭ 716 (-15.47%)
Mutual labels:  flexbox
Jest Styled Components Stylelint
Run stylelint on your styled-components styles at runtime.
Stars: ✭ 25 (-97.05%)
Mutual labels:  styled-components
Atomic Layout
Physical representation of layout composition to create declarative responsive layouts in React.
Stars: ✭ 920 (+8.62%)
Mutual labels:  styled-components
Wwcode Hacktoberfest 2020
🌎 No intuito de colaborar e incentivar a participação de mais mulheres na comunidade open source , um pull request por vez, nós do Women Who Code Recife, criamos um projeto para participarmos desta causa incrível, e toda comunidade poder colaborar
Stars: ✭ 16 (-98.11%)
Mutual labels:  styled-components
Kotlin Wrappers
Kotlin wrappers for popular JavaScript libraries
Stars: ✭ 780 (-7.91%)
Mutual labels:  styled-components
Security Checklist
A checklist for staying safe on the internet
Stars: ✭ 908 (+7.2%)
Mutual labels:  styled-components
React Three Flex
💪📦 Flexbox for react-three-fiber
Stars: ✭ 764 (-9.8%)
Mutual labels:  flexbox
React Flex Ready
A Flexbox grid ready, easy to implement and customize
Stars: ✭ 23 (-97.28%)
Mutual labels:  flexbox
Paralayout
Paralayout is a set of simple, useful, and straightforward utilities that enable pixel-perfect layout in iOS. Your designers will love you.
Stars: ✭ 742 (-12.4%)
Mutual labels:  flexbox
Flexbox
I ♥ Flexbox. Forever.
Stars: ✭ 6 (-99.29%)
Mutual labels:  flexbox
Bonneville
A simple, clean GatsbyJS starter for those looking to get up and running with Gatsby
Stars: ✭ 23 (-97.28%)
Mutual labels:  styled-components
Styled System
⬢ Style props for rapid UI development
Stars: ✭ 7,126 (+741.32%)
Mutual labels:  styled-components

hedron logo

Travis npm David All Contributors Spectrum Chat

Quick Jump

Features

  • Add unlimited breakpoints
  • Any property can be altered by a breakpoint
  • Debug mode that allows easy visualization of your layout

Requirements

The follow dependencies must be installed in your project in order for hedron to work.

Installation

Using yarn

yarn add [email protected]

Using npm

npm install [email protected]

Usage

Basic Example

import React from "react";
import ReactDOM from "react-dom";
import Grid from "hedron";

const App = () => (
  <Grid.Bounds direction="vertical">
    <Grid.Box>Header</Grid.Box>
    <Grid.Box>Content</Grid.Box>
    <Grid.Box>Footer</Grid.Box>
  </Grid.Bounds>
);

ReactDOM.render(<App />, document.getElementById("root"));

Responsive Example

To make your layout responsive, use the Grid.Provider to define breakpoints. You can add as many or as few breakpoints as you'd like.

import React from "react";
import ReactDOM from "react-dom";
import Grid from "hedron";

const App = () => (
  <Grid.Provider
    padding="20px"
    breakpoints={{ sm: "-500", md: "501-750", lg: "+750" }}
  >
    <Grid.Bounds direction="vertical">
      <Grid.Box sm={{ hidden: true }}>
        This header hides on small screens
      </Grid.Box>
      <Grid.Box>Content</Grid.Box>
      <Grid.Box lg={{ padding: "50px" }}>
        This footer gains extra padding on large screens
      </Grid.Box>
    </Grid.Bounds>
  </Grid.Provider>
);

ReactDOM.render(<App />, document.getElementById("root"));

If you want to be more verbose with your naming convention, that's perfectly fine too! Go ahead and name your breakpoints whatever feels right

import React from "react";
import ReactDOM from "react-dom";
import Grid from "hedron";

const App = () => (
  <Grid.Provider
    breakpoints={{ mobile: "-500", tablet: "501-750", wide: "+750" }}
  >
    <Grid.Bounds direction="vertical">
      <Grid.Box mobile={{ hidden: true }}>Header</Grid.Box>
      <Grid.Box>Content</Grid.Box>
      <Grid.Bounds direction="vertical" wide={{ direction: "horizontal" }}>
        <Grid.Box>These boxes render side by side on wide screens</Grid.Box>
        <Grid.Box>These boxes render side by side on wide screens</Grid.Box>
      </Grid.Bounds>
    </Grid.Bounds>
  </Grid.Provider>
);

ReactDOM.render(<App />, document.getElementById("root"));

You don't need to fill all screen sizes either, if you only need elements to change on a single resolution, just add a single breakpoint! To learn more about breakpoints, check out the documentation for Grid.Provider.

Upgrading

Unfortunately, there's no simple way to upgrade from the pre 1.0.0 version, but here's a few tips to make your life easier if you decide to upgrade (which we recommend doing!)

  • The Page and Section components have been retired. In an effort to simplify, there are only two main components now with one Provider that helps configure the global grid.
  • Row has been replaced by Grid.Bounds. This change was made because Row implies that it can only go in one direction, while Grid.Bounds is capable of arranging children either horizontally or vertically.
  • Column has been replaced by Grid.Box. Again, this change was made because Column implies it only goes in one direction.
  • BreakpointProvider has been replaced by Grid.Provider. It was changed because it's can set more than just breakpoints.

Also: There are no longer default breakpoints. You must define breakpoints yourself via Grid.Provider. You can also finally set custom breakpoints, as many as you want!

Documentation

Grid.Provider

Props

  • padding: string - structure: 20px
    • Default padding to use for child Grid.Box components
  • breakpoints: { key: string } - structure: { name: query }
    • Breakpoints for setting resolution-specific properties on child Grid.Box components. Here's a basic outline for writing breakpoint queries:
      • -500 means that the breakpoint will trigger at 500px and smaller
      • 250-800 means that the breakpoint will trigger between 250px and 800px
      • +900 means that the breakpoint will trigger at 900px and larger
Defining Breakpoints

Defining breakpoints gives you strong control over the way your content is rendered at various screen sizes. Any property that can be set on Grid.Box can be set per-breakpoint. Here's a few things to keep in mind when defining breakpoints:

  • Breakpoints can be named whatever you'd like (with a few exceptions laid out in the next section)
  • When defining breakpoints, you must pass an array object containing only two values: the min and max (both must be integers)
  • Breakpoints can have overlapping values. Use responsibly though, as it's possible to produce unexpected results when setting conflicting values on a Grid.Box with overlapping breakpoints. i.e. if mobile and tablet have overlapping pixels, don't make a Grid.Box hide on mobile and show on tablet.
Restricted Breakpoint Names

Although you can name breakpoints whatever you want, there are a few names that we do not recommend using because they will conflict with existing property names. Most of these are pretty obvious and would never come up in real usage, but it's worth having a list here just to be sure!

  • background
  • border
  • checked
  • className
  • dangerouslySetInnerHTML
  • display
  • height
  • hidden
  • htmlFor
  • margin
  • onChange
  • opacity
  • padding
  • selected
  • style
  • suppressContentEditableWarning
  • suppressHydrationWarning
  • value
  • visibility
  • width

Grid.Bounds

Props

  • debug : boolean
    • Outlines the grid system so you can visualize the layout
  • flex: string - structure: grow shrink basis
    • Controls the CSS flex property
  • direction: string - horizontal or vertical
    • Sets the primary axis the children should be in line with
  • wrap: boolean
    • Sets whether the children should wrap when there's no more room on the primary axis
  • valign: string - top, center, or bottom
    • Alignment of children along the vertical axis
  • halign: string - left, center, or right
    • Alignment of children along the horizontal axis

Grid.Bounds also inherits all properties that Stylable has.

Grid.Bounds accepts aliases for the width property.

Available aliases are:

  • half - 50%
  • quarter - 25%
  • third - 33.3333333%
  • twoThirds - 66.666666%
  • threeQuarters - 75%
<Grid.Bounds sm={{ width: "half", height: "200px" }}>
  This box gains height on small devices
</Grid.Bounds>

Grid.Box

Props

  • debug : boolean
    • Outlines the grid system so you can visualize the layout
  • flex: string - structure: grow shrink basis
    • Controls the CSS flex property
  • fill: boolean
    • Sets whether the Box should fill up all available space
  • fluid: boolean
    • Convenience property for disabling padding
  • shiftRight: boolean
    • Shifts the box to the right of the parent Bounds
  • shiftLeft: boolean
    • Shifts the box to the ;eft of the parent Bounds
  • shiftUp: boolean
    • Shifts the box to the top of the parent Bounds
  • shiftDown: boolean
    • Shifts the box to the bottom of the parent Bounds

Grid.Box also inherits all properties that Stylable has.

Grid.Box accepts aliases for the width property.

Available aliases are:

  • half - 50%
  • quarter - 25%
  • third - 33.3333333%
  • twoThirds - 66.666666%
  • threeQuarters - 75%
<Grid.Box sm={{ width: "half", height: "200px" }}>
  This box gains height on small devices
</Grid.Box>

Contributors

Thanks goes to these wonderful people (emoji key):

Garet McKinley
Garet McKinley

💻 📖 👀
Matt Hamil
Matt Hamil

💬
Mikko Matilainen
Mikko Matilainen

💻
Nathaniel Piché
Nathaniel Piché

💻 📖
Brian Stanback
Brian Stanback

💻
Stephen Mathieson
Stephen Mathieson

💻
James G. Best
James G. Best

💻

This project follows the all-contributors specification. Contributions of any kind are welcome!

Want to help? Join our Spectrum.chat community to get started!

Backers

Support us with a monthly donation and help us continue our activities. [Become a backer]

Sponsors

Become a sponsor and get your logo on our README on Github with a link to your site. [Become a sponsor]

sponsored by timber

License

MIT

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].