jongacnik / gr8

Customizable, functional css utilities
MIT License
174 stars 11 forks source link

3.0.0 #17

Closed jongacnik closed 7 years ago

jongacnik commented 7 years ago

3.0.0 is a full rewrite of gr8 internals. The resulting css is still the same (with a few additions), but how you go about generating it has been refined. Documentation has been fully rewritten.

Some larger updates:

Just a function

gr8 is now just a function which returns a string of css:

var gr8 = require('gr8')
var css = gr8({/* options */})

gr8-util

The functionality for generating a css utility is pulled out into it's own module called gr8-util. This is just a little function where given some options, returns a string of css. gr8 is now just a collection of calls to gr8-util.

Custom utilities as options

Add custom utilities by passing objects into the utils option. These objects are passed directly into gr8-util.

var bgcolor = {
  prop: {
    bgc: 'background-color'
  },
  vals: ['red', 'blue', 'green']
}

var fontcolor = {
  prop: {
    fc: 'color'
  },
  vals: ['red', 'blue', 'green']
}

var css = gr8({
  utils: [
    bgcolor,
    fontcolor
  ]
})

Split (.s) classes

Nested columns are removed and replaced with split classes. These classes are meant to split a container. For example, .s2 splits a container in half, aka width:50%. By combining column and split classes almost any level of column nesting can be achieved.

.s1{width:100%}
.s2{width:50%}
.s3{width:33.33%}
.s4{width:25%}
.s5{width:20%}
.s6{width:16.67%}
.s7{width:14.29%}
.s8{width:12.5%}
.s9{width:11.11%}
.s10{width:10%}
.s11{width:9.09%}
.s12{width:8.33%}
<div class="c12 x xw dev">
  <div class="c10 x">
    <div class="s5">Nested</div>
    <div class="s5">Nested</div>
    <div class="s5">Nested</div>
    <div class="s5">Nested</div>
    <div class="s5">Nested</div>
  </div>
  <div class="c2">
    2-Column
  </div>
</div>

Avoids generating obscene amounts of nested column and column offset classes.

Selectors as functions

Define selectors as functions for more flexibility:

// es6
var css = gr8({
  selector: s => `.gr8-${s}`
})

// es5
var css = gr8({
  selector: function (selectorName) {
    return '.gr8-' + selectorName
  }
})

Custom media queries

Breakpoints will now accept media query strings as values:

var css = gr8({
  breakpoints: {
    sm: 768,
    portrait: 'screen and (orientation: portrait)'
  }
})

Breaking Changes

✌️✨

tttimur commented 7 years ago

nice!

jondashkyle commented 7 years ago

looking awesome