-
Notifications
You must be signed in to change notification settings - Fork 0
/
mixins.scss
82 lines (68 loc) · 1.53 KB
/
mixins.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
@function calculate-grid-column-size($columnCount) {
@return 100% / $columnCount;
}
@mixin css-grid($columns: 12, $columnGap: 0, $rowGap: 0) {
display: grid;
grid-column-gap: $columnGap;
grid-row-gap: $rowGap;
@if $columns != 'auto' {
grid-template-columns: repeat($columns, 1fr);
.col {
@for $i from 1 through $columns {
&.span-#{$i} {
grid-column: span #{$i};
}
}
}
} @else {
$columns: 12;
grid-template-columns: repeat(auto-fit, minmax(100/$columns * 1em, 1fr) );
}
}
@mixin flexbox-grid($columns: 12, $columnGap: 0, $rowGap: 0) {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
.col {
&:not(:last-child) {
padding-right: $columnGap;
}
margin-bottom: $rowGap;
}
@if $columns != 'auto' {
$one-column-width: calculate-grid-column-size($columns);
.col {
flex: 1 0 $one-column-width;
@for $i from 1 through $columns {
&.span-#{$i} {
flex: 1 0 $i * $one-column-width;
}
}
}
} @else {
.col {
flex: 1;
}
}
}
@mixin float-grid($columns: 12, $columnGap: 0, $rowGap: 0) {
&::after {
content: '';
display: table;
clear: both;
}
.col {
$one-column-width: calculate-grid-column-size($columns);
float: left;
width: $one-column-width;
@for $i from 1 through $columns {
&.span-#{$i} {
width: $i * $one-column-width;
}
}
&:not(:last-child) {
margin-right: $columnGap;
}
margin-bottom: $rowGap;
}
}