-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_helper.scss
executable file
·108 lines (97 loc) · 2.76 KB
/
_helper.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
// Fylgja (getfylgja.com)
// Licensed under MIT Open Source
@use "@fylgja/mq" as *;
@use "sass:list";
@use "sass:map";
@use "sass:math";
$enable-flex-gap: true !default;
$enable-flex-fill: false !default;
$enable-flex-offset: false !default;
$enable-flex-chunks: true !default;
$flex-grid-breakpoints: (
xxs: 0,
xs: $xs,
sm: $sm,
md: $md,
lg: $lg,
xl: $xl,
) !default;
$gap-size: 1rem !default;
$flex-grid-gaps: () !default;
$flex-grid-cells: (
xxs: 2,
xs: 3,
sm: 3,
md: 4,
lg: 4,
xl: 5,
) !default;
/// @param {String} $mq - breakpoint
/// @param {Map} $map - map to check breakpoints from
/// @return {*} - styles wrapped in a media query
@mixin flex-grid-mq($mq, $map: $flex-grid-breakpoints) {
$mq-value: map.get($map, $mq);
@if ($mq-value != 0) {
@media ($mq-value) {
@content;
}
} @else {
@content;
}
}
/// Creates grid gaps via the margin/padding trick
/// @param {Number} $size - the gap size
/// @param {String} $class - class to use
/// @return {*} - gap styles
@mixin flex-grid-gap($size, $class: "cell") {
$x: if(list.length($size) == 2, list.nth($size, 2), list.nth($size, 1));
$y: list.nth($size, 1);
margin-right: math.div($x, -2);
margin-left: math.div($x, -2);
> .#{$class} {
margin-bottom: $y;
padding-right: math.div($x, 2);
padding-left: math.div($x, 2);
}
}
/// Creates grid cells
/// @param {Number} $i - How much iterations
/// @param {String} $mq - the cell media query
/// @param {Boolean} $chunks - If to render chunked sizes
/// @return {*} - cell styles
@mixin flex-grid-cells($mq, $size, $chunks: true) {
@for $i from 1 through $size {
> .cell.#{$mq}-#{$i} {
flex: 0 0 auto;
width: if($i == 1, 100%, calc(100% / #{$i}));
}
@if $chunks and ($i > 2) {
@for $fi from 2 through ($i - 1) {
> .cell.#{$mq}-#{$i}-#{$fi} {
flex: 0 0 auto;
width: calc((100% / #{$i}) * #{$fi});
}
}
}
}
}
/// Creates grid cells offsets
/// @param {Number} $i - How much iterations
/// @param {String} $mq - the cell media query
/// @param {Boolean} $chunks - If to render chunked sizes
/// @return {*} - cell offset styles
@mixin flex-grid-offsets($mq, $size, $chunks: true) {
@for $i from 1 through $size {
$name: if($i == 1, "none", $i);
> .offset-#{$mq}-#{$name} {
margin-left: if($i == 1, 0, calc(100% / #{$i}));
}
@if $chunks and ($i > 2) {
@for $fi from 2 through ($i - 1) {
> .offset-#{$mq}-#{$i}-#{$fi} {
margin-left: calc((100% / #{$i}) * #{$fi});
}
}
}
}
}