KNACSS/styl/grids/_grillade.styl

100 lines
2.7 KiB
Stylus
Raw Normal View History

2017-03-06 17:35:08 +01:00
/* ---------------------------------- */
/* ==Grillade : Simple Grid System */
/* ---------------------------------- */
2017-03-09 10:56:37 +01:00
@import '../vendor/flexbox-stylus/stylus/flexbox.styl'
2017-03-06 17:35:08 +01:00
/* Doc : http://grillade.knacss.com */
// gutter values for grid layouts. Unit can be: %, px, em, rem
grid-gutters = { '': 1rem, '-l': 2rem, '-xl': 4rem }
// IEfixing, see
// https://github.com/alsacreations/KNACSS/issues/133;
iefix = 0.01px
@media (min-width: tiny + 1)
[class*=" grid-"]
[class^="grid-"]
flexbox(flex)
flex-direction(row)
flex-wrap(wrap)
2017-03-06 17:35:08 +01:00
& > *
box-sizing: border-box
min-width: 0
min-height: 0
// Multi-line grid constructor
// example : .grid-perso { @include grid(12, 3rem); }
grid(grid-number = 1, own-gutter = 0)
& > *
width 'calc(100% / %s - %s)' % (grid-number iefix)
2017-03-09 14:21:09 +01:00
for key, size in grid-gutters
2017-03-06 17:35:08 +01:00
&.has-gutter{key}
margin-right -(size / 2)
margin-left -(size / 2)
2017-03-06 17:35:08 +01:00
& > *
width 'calc(100% / %s - %s - %s)' % (grid-number size iefix)
margin-right (size / 2)
margin-left (size / 2)
2017-03-09 14:21:09 +01:00
if own-gutter != 0
margin-right (own-gutter / 2)
margin-left (own-gutter / 2)
2017-03-06 17:35:08 +01:00
// Mono-line grid constructor (.grid)
@media (min-width: tiny + 1)
.grid
.grid--reverse
2017-03-09 14:21:09 +01:00
flexbox(flex)
2017-03-06 17:35:08 +01:00
& > *
2017-03-09 14:21:09 +01:00
flex(1 1 0%)
box-sizing border-box
min-width 0
min-height 0
2017-03-06 17:35:08 +01:00
for key, size in grid-gutters
&.has-gutter{key} > * + *
margin-left 'calc(%s - %s)' % (size iefix)
2017-03-06 17:35:08 +01:00
// Constructing grids : will be compiled in CSS
@media (min-width: tiny + 1)
for i in 2..12
grid-selector = 'grid-%s' % i
2017-03-09 14:21:09 +01:00
[class*=\"{grid-selector}\"]
2017-03-06 17:35:08 +01:00
grid(i, 0)
.push
margin-left auto !important
2017-03-06 17:35:08 +01:00
.pull
margin-right auto !important
2017-03-06 17:35:08 +01:00
.item-first
-webkit-box-ordinal-group 0
-ms-flex-order -1
order -1
2017-03-06 17:35:08 +01:00
.item-last
-webkit-box-ordinal-group 2
-ms-flex-order 1
order 1
2017-03-06 17:35:08 +01:00
[class*="grid-"][class*="--reverse"]
flex-direction(row-reverse)
2017-03-06 17:35:08 +01:00
@media (min-width: tiny + 1)
flowToDivid = {'full': 1, 'one-half': 2, 'one-third': 3, 'one-quarter': 4, 'one-fifth': 5, 'one-sixth': 6, 'two-thirds': 3 * 2, 'three-quarters': 4 * 3, 'five-sixths': 6 * 5}
for flow, divider in flowToDivid
.{flow}
2017-03-09 14:21:09 +01:00
flex(0 0 auto)
width 'calc(100% / %s - %s)' % (divider iefix)
for key, size in grid-gutters
.has-gutter{key} .{flow}
width 'calc(100% / %s - %s - %s)' % (divider size iefix)
2017-03-06 17:35:08 +01:00
/* Responsive Small Breakpoint */
2017-03-09 14:21:09 +01:00
@media (min-width: tiny + 1) and (max-width: medium)
for i in 1..4
index = '-small-%s' % i
2017-03-09 14:21:09 +01:00
[class*=\"{index}\"]
& > *
width: 'calc(100% / %s - %s)' % (i iefix)
for key, size in grid-gutters
&.has-gutter{key} > *
width: 'calc(100% / %s - %s - %s)' % (i size iefix)