-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrid.scss
111 lines (89 loc) · 2.77 KB
/
grid.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
@import './flexbox.scss';
$gutter: 12px;
@mixin grid-columns($columnWidths: (50% 50%)) {
$numberOfColumns: length($columnWidths);
$className: unquote('col-#{$numberOfColumns}__');
@for $i from 1 through $numberOfColumns {
$width: nth($columnWidths, $i);
$str: inspect($width);
$index: str-index($str, '%');
$name: str-slice($str, 0, $index - 1);
@if $i == 1 {
$className: unquote('#{$className}#{$name}');
} @else {
$className: unquote('#{$className}-#{$name}');
}
}
&.#{$className} {
@for $i from 1 through $numberOfColumns {
$width: nth($columnWidths, $i);
$child: unquote('#{$numberOfColumns}n + #{$i}');
@if $numberOfColumns == $i {
$child: unquote('#{$numberOfColumns}n');
}
& > div:nth-child(#{$child}) {
width: calc(#{$width} - #{$gutter});
}
}
@supports (display: grid) {
grid-template-columns: #{$columnWidths};
& > div {
width: 100% !important;
}
}
.edge & {
@for $i from 1 through $numberOfColumns {
$width: nth($columnWidths, $i);
$child: unquote('#{$numberOfColumns}n + #{$i}');
@if $numberOfColumns == $i {
$child: unquote('#{$numberOfColumns}n');
}
& > div:nth-child(#{$child}) {
width: calc(#{$width} - #{$gutter}) !important;
}
}
}
}
}
.grid {
// IE 11 Fallback
@include flexbox();
@include flex-flow(row wrap);
@include align-items(center);
& > div {
// display: inline-block;
margin-right: $gutter;
}
@supports (display: grid) {
display: grid;
grid-template-columns: auto;
grid-template-rows: auto;
grid-column-gap: $gutter;
grid-gap: .5rem $gutter;
justify-items: stretch;
align-items: center;
justify-content: start;
align-content: start;
// Note: To use this class, it is best to override `grid-template-columns` and `grid-template-rows` for
// the specific needs of the layout
}
// @TODO: Remove. Edge 16 (Released Oct 16, 2017) now supports Grid properly.
.edge & {
@include flexbox();
@include flex-flow(row wrap);
@include align-items(center);
& > div {
// display: inline-block;
margin-right: $gutter;
}
}
&.row-gap--half {
grid-row-gap: .5rem;
}
&.row-gap--none {
grid-row-gap: 0;
}
&.align-items--end {
@include align-items(end);
}
}