11@import " sass-list-maps" ;
22
33// Transform the gutter property into a padding property for web
4- @function addPadding ($breakpoints ) {
4+ @function add-padding ($breakpoints ) {
55 $cleanBreakpoints : ();
66 @each $name , $breakpoint in $breakpoints {
77 $cleanBreakpoints : map-merge (
88 $cleanBreakpoints ,
9-
109 (
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+ )
1515 )
1616 );
1717 }
2020}
2121
2222// Merge standard and custom breakpoints into list
23- @function allBreakpoints ($breakpoints , $extraBreakpoints , $first , $last ) {
23+ @function all-breakpoints ($breakpoints , $extraBreakpoints , $first , $last ) {
2424 $allBreakpoints : $breakpoints ;
2525 @each $currentBreakpoint in $extraBreakpoints {
2626 $extraBreakpointName : nth ($currentBreakpoint , 1 );
2929 $match : null;
3030 @each $majorBreakpoint in $breakpoints {
3131 @if $found == false {
32- @if map-get (nth ($majorBreakpoint , 2 ), breakpoint ) > $extraBreakpointWidth {
32+ @if map-get (nth ($majorBreakpoint , 2 ), breakpoint ) >
33+ $extraBreakpointWidth
34+ {
3335 $found : true;
3436 } @else {
3537 $match : $majorBreakpoint ;
5153
5254 $newBreakpoint : map-merge (
5355 nth ($match , 2 ),
54- (breakpoint: $extraBreakpointWidth )
56+ (breakpoint: $extraBreakpointWidth )
5557 );
5658 $currentBreakpoint : (
57- $extraBreakpointName : map-merge (nth ($match , 2 ), (breakpoint: $extraBreakpointWidth ))
59+ $extraBreakpointName :
60+ map-merge (nth ($match , 2 ), (breakpoint: $extraBreakpointWidth ))
5861 );
5962 $allBreakpoints : map-merge ($allBreakpoints , $currentBreakpoint );
6063 }
6164
6265 @return maps-sort ($allBreakpoints , breakpoint );
6366}
6467
65- @function columnStringWidth ($string , $multiple ) {
68+ @function column-string-width ($string , $multiple ) {
6669 @return 1rem ;
6770}
6871
69- @function columnWidth ($breakpoint , $first , $last , $i , $columnAmount ) {
72+ @function column-width ($breakpoint , $first , $last , $i , $columnAmount ) {
7073 $columnSize : 100 / map-get ($breakpoint , columns ) * $i *
7174 map-get ($breakpoint , columns ) / $columnAmount ;
7275 $margin : 0 ;
7376 $type : " vw" ;
7477 @if map-get ($breakpoint , margin ) {
7578 $margin : map-get ($breakpoint , margin ) * 2 ;
7679 }
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+ ) {
7983 $columnSize : calc (
80- (#{100vw } - #{$margin } ) * #{roundDecimal ($i / $columnAmount , 3 , floor )}
84+ (#{100vw } - #{$margin } ) * #{round-decimal ($i / $columnAmount , 3 , floor )}
8185 );
8286 $type : " " ;
8387 }
8488
8589 @return #{$columnSize }#{$type } ;
8690}
8791
88- @function isSameBreakpoint ($a , $b ) {
92+ @function is-same-breakpoint ($a , $b ) {
8993 @return map-get ($a , breakpoint ) == map-get ($b , breakpoint );
9094}
9195
9296// _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 ) {
9498 $n : 1 ;
9599 // $number must be a number
96100 @if type-of ($number ) != number {
97- @warn ' #{ $number } is not a number.' ;
101+ @warn " #{ $number } is not a number." ;
98102 @return $number ;
99103 }
100104 // $digits must be a unitless number
101105 @if type-of ($digits ) != number {
102- @warn ' #{ $digits } is not a number.' ;
106+ @warn " #{ $digits } is not a number." ;
103107 @return $number ;
104108 } @else if not unitless ($digits ) {
105- @warn ' #{ $digits } has a unit.' ;
109+ @warn " #{ $digits } has a unit." ;
106110 @return $number ;
107111 }
108112 @for $i from 1 through $digits {
@@ -115,14 +119,14 @@ map-get($breakpoint, margin) != 0) {
115119 } @else if $mode == floor {
116120 @return floor ($number * $n ) / $n ;
117121 } @else {
118- @warn ' #{ $mode } is undefined keyword.' ;
122+ @warn " #{ $mode } is undefined keyword." ;
119123 @return $number ;
120124 }
121125}
122126
123127/// String to number converter
124128/// @author Hugo Giraudel
125- @function stringToNumber ($value ) {
129+ @function string-to-number ($value ) {
126130 @if type-of ($value ) == " number" {
127131 @return $value ;
128132 } @else if type-of ($value ) != " string" {
@@ -148,7 +152,7 @@ map-get($breakpoint, margin) != 0) {
148152 @for $i from if ($minus , 2 , 1 ) through str-length ($value ) {
149153 $character : str-slice ($value , $i , $i );
150154
151- @if not (index (map-keys ($numbers ), $character ) or $character == " ." ) {
155+ @if not (index (map-keys ($numbers ), $character ) or $character == " ." ) {
152156 @return to-length (if ($minus , - $result , $result ), str-slice ($value , $i ));
153157 }
154158
@@ -164,3 +168,15 @@ map-get($breakpoint, margin) != 0) {
164168
165169 @return if ($minus , - $result , $result );
166170}
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