Giter Club home page Giter Club logo

smart-grid's Introduction

Create adaptive CSS? It's fast and easy! With smart-grid!

Install

$ npm i smart-grid

Usage

var smartgrid = require('smart-grid');

/* It's principal settings in smart grid project */
var settings = {
    outputStyle: 'less', /* less || scss || sass || styl */
    columns: 12, /* number of grid columns */
    offset: "30px", /* gutter width px || % */
    container: {
        maxWidth: '1200px', /* max-width оn very large screen */
        fields: '30px' /* side fields */
    },
    breakPoints: {
        lg: {
            'width': '1100px', /* -> @media (max-width: 1100px) */
            'fields': '30px' /* side fields */
        },
        md: {
            'width': '960px',
            'fields': '15px'
        },
        sm: {
            'width': '780px',
            'fields': '15px'
        },
        xs: {
            'width': '560px',
            'fields': '15px'
        }
        /* 
        We can create any quantity of break points.

        some_name: {
            some_width: 'Npx',
            some_offset: 'N(px|%)'
        }
        */
    }
};

smartgrid('./path-to-your-folder', settings);

Why? How does it work?

We set JS array with settings and get LESS, SCSS, SASS or Stylus file with Smart Grid.

And what?

The fact that the standard bootstrap grid, makes us write a lot of classes in html, that spoils the structure of the code.

In the proposed version, we do not touch at all the classes in the html code, but only add the mixins to the existing selectors.

Sample. We write

.items{
    .row-flex();
    .justify-content-md(center);

    .item{
        .col();
        .col-3();
        .col-md-5();
        .col-xs-10();
    }
}

And we get big CSS

.items {
    display: flex;
    flex-wrap: wrap;
    margin-left: -15px;
    margin-right: -15px;
}
@media screen and (max-width: 992px) {
    .items {
        justify-content: center;
    }
}
.items .item {
    box-sizing: border-box;
    margin-left: 15px;
    margin-right: 15px;
    word-wrap: break-word;
    width: calc(25% - 30px);
}
@media screen and (max-width: 992px) {
    .items .item {
        width: calc(41.66666666666667% - 30px);
    }
}
@media screen and (max-width: 576px) {
    .items .item {
        width: calc(83.33333333333334% - 30px);
    }
}

It's nice! But it's generate a lot of media queries.

But after use group-css-media-queries get the same code written by hand.

.items {
    display: flex;
    flex-wrap: wrap;
    margin-left: -15px;
    margin-right: -15px;
}
.items .item {
    box-sizing: border-box;
    margin-left: 15px;
    margin-right: 15px;
    word-wrap: break-word;
    width: calc(25% - 30px);
}
@media screen and (max-width: 992px) {
    .items {
        justify-content: center;
    }
    .items .item {
        width: calc(41.66666666666667% - 30px);
    }
}
@media screen and (max-width: 576px) {
    .items .item {
        width: calc(83.33333333333334% - 30px);
    }
}

So, ideal CSS scheme

  1. Smart Grid generate libruary for LESS, SCSS, SASS or Stylus
  2. We used mixins to write code quickly
  3. And finaly, we used:
    • group-css-media-queries
    • autoprefixer
    • clean-css

Video and text tutorials on Smart Grid

Coming in 2017!

smart-grid's People

Watchers

James Cloos 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.