Skip to content
This repository was archived by the owner on Oct 22, 2020. It is now read-only.

Commit e78c70d

Browse files
Layout system changed to grid from flexbox
1 parent d1f3d69 commit e78c70d

File tree

2 files changed

+65
-73
lines changed

2 files changed

+65
-73
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
# Grider
2-
***Grider*** is a simple enough and fully customizable SCSS-based grid generator. Create your own responsive CSS grid system easily with offset and equal height features.
2+
***Grider*** is a simple enough and fully customizable SCSS Grid-based layout generator. Create your own responsive CSS layout system easily with offset and equal height features.
33

44
[![GitHub license](https://img.shields.io/github/license/codeforms/Grider)](https://github.com/codeforms/Grider/blob/master/LICENSE)
55
![GitHub release (latest by date)](https://img.shields.io/github/v/release/codeforms/Grider)
66
[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](https://github.com/codeforms/Grider/releases)
77

8-
[Live Demo](https://codepen.io/underlinewords/pen/pogooob)
8+
### Features
9+
* Clean code
10+
* Simple enough (just compile)
11+
* Fully customizable (grid number, class names etc.)
12+
* CSS Grid based, not Flexbox!
13+
* Viewport breakpoints
14+
* Column offsets
15+
* Equal height columns
16+
17+
[Take a Look](https://codepen.io/underlinewords/pen/pogooob)

grider.scss

Lines changed: 54 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,39 @@
44
||||||||||||||||
55
*/
66

7-
/*** BASIC ***/
8-
$grid: 16;
7+
/********************
8+
BASIC ********************/
9+
$grid : 16;
10+
$gutter : 30px;
911

10-
/*** NAMES ***/
11-
$row-name: 'row';
12-
$container-name: 'container';
13-
$column-name: 'col';
14-
$offset: 'offset';
15-
$equal: 'equal';
12+
/********************
13+
NAMES ********************/
14+
$row-name : 'row';
15+
$container-name : 'container';
16+
$column-name : 'column';
17+
$offset : 'offset';
18+
//$equal : 'equal';
1619

17-
/*** CONTAINER ***/
18-
$container-width: 97%;
19-
$container-small-width: 92%;
20-
$container-large-width: 88%;
20+
/********************
21+
COLUMN ********************/
22+
$column-padding : .3rem;
23+
$column-min-height : .125rem;
2124

22-
/*** ROW ***/
23-
$row-width: 100%;
25+
/********************
26+
BREAKPOINTS ********************/
27+
$screen_viewport_xs : 0;
28+
$screen_viewport_sm : 500px;
29+
$screen_viewport_md : 768px;
30+
$screen_viewport_lg : 992px;
31+
$screen_viewport_xl : 1260px;
2432

25-
/*** COLUMN ***/
26-
$column-width: 100%;
27-
$column-padding: 0;
28-
$column-min-height: .125rem;
29-
30-
/*** BREAKPOINTS ***/
31-
$breakpoint-small: 33.75em; // 540px
32-
$breakpoint-medium: 48em; // 768px
33-
$breakpoint-large: 61.25em; // 980px
34-
35-
/*** SPACER ***/
36-
$spacer: 15px;
33+
$viewports: (
34+
(xs, $screen_viewport_xs),
35+
(sm, $screen_viewport_sm),
36+
(md, $screen_viewport_md),
37+
(lg, $screen_viewport_lg),
38+
(xl, $screen_viewport_xl)
39+
);
3740

3841
/*** MIXINS ***/
3942
@mixin breakpoints($size) {
@@ -42,54 +45,34 @@
4245
}
4346
}
4447

45-
.#{$container-name} {
46-
width: $container-width;
47-
padding-right: $spacer;
48-
padding-left: $spacer;
49-
margin-left: auto;
50-
margin-right: auto;
51-
@include breakpoints($breakpoint-small) {
52-
width: $container-small-width;
53-
}
54-
@include breakpoints($breakpoint-large) {
55-
width: $container-large-width;
56-
}
57-
}
5848
.#{$row-name} {
59-
display: flex;
60-
flex-wrap: wrap;
61-
width: $row-width;
62-
[class^="#{$column-name}"] {
63-
float: left;
64-
padding: $column-padding;
65-
height: 100%;
66-
min-height: $column-min-height;
67-
flex-direction: column;
68-
}
69-
&.#{$equal} {
70-
[class^="#{$column-name}"] {
71-
height: auto;
72-
}
73-
}
74-
@for $i from 1 through $grid {
75-
.#{$column-name}-#{$i} {
76-
flex-basis: $column-width;
77-
}
78-
.#{$column-name}-#{$offset}-#{$i} {
79-
margin-left: 0;
80-
flex-basis: $column-width;
81-
}
82-
}
83-
@include breakpoints($breakpoint-medium) {
84-
@for $i from 1 through $grid {
85-
$value : (100 / ($grid / $i) ) * 1%;
86-
.#{$column-name}-#{$i} {
87-
flex-basis: $value;
49+
display: grid;
50+
grid-gap: $gutter;
51+
grid-template-columns: repeat($grid, 1fr);
52+
}
53+
[class^="#{$column-name}"] {
54+
height: auto;
55+
padding: $column-padding;
56+
min-height: $column-min-height;
57+
}
58+
@each $label, $breakpoint, $width in $viewports {
59+
@include breakpoints($breakpoint) {
60+
@for $i from 1 through $grid {
61+
.#{$column-name}-#{$i} {
62+
grid-column: span #{$i};
63+
}
64+
@for $y from 1 through $grid {
65+
.#{$offset}-#{$label}-#{$y}.#{$column-name}-#{$label}-#{$i} {
66+
grid-column: #{$y} / span #{$i};
67+
}
8868
}
89-
.#{$column-name}-#{$offset}-#{$i} {
90-
flex-basis: $value;
91-
margin-left: $value;
69+
.#{$column-name}-#{$label}-#{$i} {
70+
grid-column-start: span #{$i};
9271
}
9372
}
73+
.#{$container-name} {
74+
width: 95%;
75+
margin: 0 auto;
76+
}
9477
}
9578
}

0 commit comments

Comments
 (0)