1
1
@import " sass-list-maps" ;
2
2
3
3
// Transform the gutter property into a padding property for web
4
- @function addPadding ($breakpoints ) {
4
+ @function add-padding ($breakpoints ) {
5
5
$cleanBreakpoints : ();
6
6
@each $name , $breakpoint in $breakpoints {
7
7
$cleanBreakpoints : map-merge (
8
8
$cleanBreakpoints ,
9
-
10
9
(
11
- $name : map-merge ($breakpoint , (padding : calc (#{map-get (
12
- $breakpoint ,
13
- gutter
14
- )} / 2 )))
10
+ $name :
11
+ map-merge (
12
+ $breakpoint ,
13
+ (padding : calc (#{map-get ($breakpoint , gutter )} / 2 ))
14
+ )
15
15
)
16
16
);
17
17
}
20
20
}
21
21
22
22
// Merge standard and custom breakpoints into list
23
- @function allBreakpoints ($breakpoints , $extraBreakpoints , $first , $last ) {
23
+ @function all-breakpoints ($breakpoints , $extraBreakpoints , $first , $last ) {
24
24
$allBreakpoints : $breakpoints ;
25
25
@each $currentBreakpoint in $extraBreakpoints {
26
26
$extraBreakpointName : nth ($currentBreakpoint , 1 );
29
29
$match : null;
30
30
@each $majorBreakpoint in $breakpoints {
31
31
@if $found == false {
32
- @if map-get (nth ($majorBreakpoint , 2 ), breakpoint ) > $extraBreakpointWidth {
32
+ @if map-get (nth ($majorBreakpoint , 2 ), breakpoint ) >
33
+ $extraBreakpointWidth
34
+ {
33
35
$found : true;
34
36
} @else {
35
37
$match : $majorBreakpoint ;
51
53
52
54
$newBreakpoint : map-merge (
53
55
nth ($match , 2 ),
54
- (breakpoint: $extraBreakpointWidth )
56
+ (breakpoint: $extraBreakpointWidth )
55
57
);
56
58
$currentBreakpoint : (
57
- $extraBreakpointName : map-merge (nth ($match , 2 ), (breakpoint: $extraBreakpointWidth ))
59
+ $extraBreakpointName :
60
+ map-merge (nth ($match , 2 ), (breakpoint: $extraBreakpointWidth ))
58
61
);
59
62
$allBreakpoints : map-merge ($allBreakpoints , $currentBreakpoint );
60
63
}
61
64
62
65
@return maps-sort ($allBreakpoints , breakpoint );
63
66
}
64
67
65
- @function columnStringWidth ($string , $multiple ) {
68
+ @function column-string-width ($string , $multiple ) {
66
69
@return 1rem ;
67
70
}
68
71
69
- @function columnWidth ($breakpoint , $first , $last , $i , $columnAmount ) {
72
+ @function column-width ($breakpoint , $first , $last , $i , $columnAmount ) {
70
73
$columnSize : 100 / map-get ($breakpoint , columns ) * $i *
71
74
map-get ($breakpoint , columns ) / $columnAmount ;
72
75
$margin : 0 ;
73
76
$type : " vw" ;
74
77
@if map-get ($breakpoint , margin ) {
75
78
$margin : map-get ($breakpoint , margin ) * 2 ;
76
79
}
77
- @if (map-get ($breakpoint , margin ) != null and
78
- map-get ($breakpoint , margin ) != 0 ) {
80
+ @if (
81
+ map-get ($breakpoint , margin ) != null and map-get ($breakpoint , margin ) != 0
82
+ ) {
79
83
$columnSize : calc (
80
- (#{100vw } - #{$margin } ) * #{roundDecimal ($i / $columnAmount , 3 , floor )}
84
+ (#{100vw } - #{$margin } ) * #{round-decimal ($i / $columnAmount , 3 , floor )}
81
85
);
82
86
$type : " " ;
83
87
}
84
88
85
89
@return #{$columnSize }#{$type } ;
86
90
}
87
91
88
- @function isSameBreakpoint ($a , $b ) {
92
+ @function is-same-breakpoint ($a , $b ) {
89
93
@return map-get ($a , breakpoint ) == map-get ($b , breakpoint );
90
94
}
91
95
92
96
// _decimal.scss | MIT License | gist.github.com/terkel/4373420
93
- @function roundDecimal ($number , $digits : 0 , $mode : round ) {
97
+ @function round-decimal ($number , $digits : 0 , $mode : round ) {
94
98
$n : 1 ;
95
99
// $number must be a number
96
100
@if type-of ($number ) != number {
97
- @warn ' #{ $number } is not a number.' ;
101
+ @warn " #{ $number } is not a number." ;
98
102
@return $number ;
99
103
}
100
104
// $digits must be a unitless number
101
105
@if type-of ($digits ) != number {
102
- @warn ' #{ $digits } is not a number.' ;
106
+ @warn " #{ $digits } is not a number." ;
103
107
@return $number ;
104
108
} @else if not unitless ($digits ) {
105
- @warn ' #{ $digits } has a unit.' ;
109
+ @warn " #{ $digits } has a unit." ;
106
110
@return $number ;
107
111
}
108
112
@for $i from 1 through $digits {
@@ -115,14 +119,14 @@ map-get($breakpoint, margin) != 0) {
115
119
} @else if $mode == floor {
116
120
@return floor ($number * $n ) / $n ;
117
121
} @else {
118
- @warn ' #{ $mode } is undefined keyword.' ;
122
+ @warn " #{ $mode } is undefined keyword." ;
119
123
@return $number ;
120
124
}
121
125
}
122
126
123
127
/// String to number converter
124
128
/// @author Hugo Giraudel
125
- @function stringToNumber ($value ) {
129
+ @function string-to-number ($value ) {
126
130
@if type-of ($value ) == " number" {
127
131
@return $value ;
128
132
} @else if type-of ($value ) != " string" {
@@ -148,7 +152,7 @@ map-get($breakpoint, margin) != 0) {
148
152
@for $i from if ($minus , 2 , 1 ) through str-length ($value ) {
149
153
$character : str-slice ($value , $i , $i );
150
154
151
- @if not (index (map-keys ($numbers ), $character ) or $character == " ." ) {
155
+ @if not (index (map-keys ($numbers ), $character ) or $character == " ." ) {
152
156
@return to-length (if ($minus , - $result , $result ), str-slice ($value , $i ));
153
157
}
154
158
@@ -164,3 +168,15 @@ map-get($breakpoint, margin) != 0) {
164
168
165
169
@return if ($minus , - $result , $result );
166
170
}
171
+
172
+ /// Traverse maps and retrieve deeply nested values: https://css-tricks.com/snippets/sass/deep-getset-maps/
173
+ /// @author Hugo Giraudel
174
+ /// @param {Map} $map A sass map and any number of keys.
175
+ /// @param {*} $keys Nested values.
176
+ /// @return Nested values or nested map.
177
+ @function map-deep-get ($map , $keys ... ) {
178
+ @each $key in $keys {
179
+ $map : map-get ($map , $key );
180
+ }
181
+ @return $map ;
182
+ }
0 commit comments