]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Factorize function -zf-breakpoint-value into -zf-get-bp-val
authorNicolas Coden <nicolas@ncoden.fr>
Sat, 3 Dec 2016 12:01:34 +0000 (13:01 +0100)
committerNicolas Coden <nicolas@ncoden.fr>
Sat, 3 Dec 2016 12:01:34 +0000 (13:01 +0100)
- Allow the `-zf-get-bp-val` function to take a single value as
responsive config `$map` and return it regardless of `$value`.
- Remove useless function `-zf-breakpoint-value`

scss/grid/_row.scss
scss/util/_breakpoint.scss
scss/util/_mixins.scss

index b84f9c03e27f6512b471c989b11fce5a3e5f78de..e9718550eaadcd009ea8ab0bd8d07b5d4d1fcd69 100644 (file)
@@ -80,7 +80,7 @@
 /// @param {Number|Map} $gutters [$grid-column-gutter] - Gutter map or single value to use when inverting margins. Responsive gutter settings by default.
 @mixin grid-row-nest($gutters: $grid-column-gutter) {
   @include -zf-each-breakpoint {
-    $margin: rem-calc(-zf-breakpoint-value($-zf-size, $gutters)) / 2 * -1;
+    $margin: rem-calc(-zf-get-bp-val($gutters, $-zf-size)) / 2 * -1;
 
     margin-right: $margin;
     margin-left: $margin;
index f4b142f0928e2fdb831b05431c93411b8aadfea7..238b83789aa2f7be2b3035d594aa01860e564745 100644 (file)
@@ -211,14 +211,22 @@ $breakpoint-classes: (small medium large) !default;
 
 }
 
-/// Get a value for a breakpoint from a responsive config map. If the config map has the key `$value`, the exact breakpoint value is returned. If the config map does *not* have the breakpoint, the value matching the next lowest breakpoint in the config map is returned.
+/// Get a value for a breakpoint from a responsive config map or single value.
+/// - If the config is a single value, return it regardless of `$value`.
+/// - If the config is a map and has the key `$value`, the exact breakpoint value is returned.
+/// - If the config is a map and does *not* have the breakpoint, the value matching the next lowest breakpoint in the config map is returned.
 /// @access private
 ///
-/// @param {Map} $map - Input config map.
+/// @param {Number|Map} $map - Responsive config map or single value.
 /// @param {Keyword} $value - Breakpoint name to use.
 ///
 /// @return {Mixed} The corresponding breakpoint value.
 @function -zf-get-bp-val($map, $value) {
+  // If the given map is a single value, return it
+  @if type-of($map) == 'number' {
+    @return $map;
+  }
+
   // Check if the breakpoint name exists globally
   @if not map-has-key($breakpoints, $value) {
     @return null;
@@ -248,24 +256,6 @@ $breakpoint-classes: (small medium large) !default;
   }
 }
 
-/// Get a value in a map for a given breakpoint name
-/// @param {Keyword} $bp-name [small] - Breakpoint name.
-/// @param {Number|Map} $bp-values-map - Map of breakpoints and values or single value to use.
-///
-/// @returns {Number} Breakpoint-related value from `$bp-values-map`.
-@function -zf-breakpoint-value(
-  $bp-name: $-zf-zero-breakpoint,
-  $bp-values-map: null
-) {
-  // If the map is a single value, return it
-  @if type-of($bp-values-map) == 'number' {
-    @return $bp-values-map;
-  }
-
-  // Else, return the corresponding breakpoint value
-  @return -zf-get-bp-val($bp-values-map, $bp-name);
-}
-
 // Legacy breakpoint variables
 // These will be removed in 6.3
 $small-up: null;
index aae42d89c254e166b00d42ecef4518d766f9aa58..5aed84d0da3f114fd6b22f6a7735de6f6bda0944 100644 (file)
   @else {
     // breakpoint name
     @if type-of($name) == 'string' {
-      $name: -zf-breakpoint-value($name, $map);
+      $name: -zf-get-bp-val($map, $name);
     }
 
     // breakpoint value