2.0.0 • Published 2 years ago

emotion-flex v2.0.0

Weekly downloads
10
License
MIT
Repository
github
Last release
2 years ago

emotion-flex

Build Status Coverage Status NPM MIT License code style: prettier

Fully customizable responsive grid system build with emotion, based on Bootstrap.

Install

⚠ WARNING For emotion 10 use v1.x.x of emotion-flex

npm i --save emotion-flex @emotion/react @emotion/styled

# or

yarn add emotion-flex @emotion/react @emotion/styled

Usage

Bootstrap is developed mobile first, a strategy in which we optimize code for mobile devices first and then scale up components as necessary using CSS media queries. To ensure proper rendering and touch zooming for all devices, add the responsive viewport meta tag to your <head>. from Bootstrap docs

<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

Make sure you reset box-sizing somewhere in global styles:

*,
*::before,
*::after {
  box-sizing: inherit;
}

html {
  box-sizing: border-box;
}
import React, { Component } from 'react'

import { Container, Row, Col } from 'emotion-flex'

class Example extends Component {
  render () {
    return (
      <Container>
        <Row>
          <Col xs={12} sm={6} md={4} lg={3}>1st column</Col>
          <Col xs={12} sm={6} md={4} lg={3}>2nd column</Col>
        </Row>
      </Container>
    )
  }
}

API

Container

propstypedescription
fluidbooleanEquivalent to Bootstrap's container and container-fluid

Row

propstypedescription
noGuttersbooleanRemove Row's negative margins

Col

propstypedescription
noGuttersbooleanRemoves the padding around Column
xsOffsetnumber (2-11)The number of columns to offset on extra small devices
xsOrdernumber or "first" or "last"Sets the order on extra small devices
xsnumber (1-12)The number of columns to span on extra small devices
smOffsetnumber (2-11)The number of columns to offset on small devices
smOrdernumber or "first" or "last"Sets the order on small devices
smnumber (1-12)The number of columns to span on small devices
mdOffsetnumber (2-11)The number of columns to offset on medium devices
mdOrdernumber or "first" or "last"Sets the order on medium devices
mdnumber (1-12)The number of columns to span on medium devices
lgOffsetnumber (2-11)The number of columns to offset on large devices
lgOrdernumber or "first" or "last"Sets the order on large devices
lgnumber (1-12)The number of columns to span on large devices
xlOffsetnumber (2-11)The number of columns to offset on extra large devices
xlOrdernumber or "first" or "last"Sets the order on extra large devices
xlnumber (1-12)The number of columns to span on extra large devices

Theming

import React, { Component } from 'react'
import { ThemeProvider } from '@emotion/react'

import { Container, Row, Col } from 'emotion-flex'

const customTheme = {
  breakpoints: {
    sm: 600,
    md: 960,
    lg: 1280,
    xl: 1920,
  },
  maxWidths: {
    sm: 576,
    md: 768,
    lg: 992,
    xl: 1200,
  },
  gutters: 16
};

class Example extends Component {
  render () {
    return (
      <ThemeProvider theme={customTheme}>
        <Container>
          <Row>
            <Col xs={12} sm={6} md={4} lg={3}>1st column</Col>
            <Col xs={12} sm={6} md={4} lg={3}>2nd column</Col>
          </Row>
        </Container>
      </ThemeProvider>
    )
  }
}

Default theme:

{
  breakpoints: {
    sm: 576,
    md: 768,
    lg: 992,
    xl: 1200,
  },
  maxWidths: {
    sm: 540,
    md: 720,
    lg: 960,
    xl: 1140,
  },
  gutters: 15,
}

Other projects

License

MIT © janczizikow

1.0.1

2 years ago

2.0.0

2 years ago

1.0.0

5 years ago

0.0.1-dev

5 years ago