From e7487a374a0de1c42bbf5fc4fe0ee5b4e8a25682 Mon Sep 17 00:00:00 2001 From: Nicolas Coden Date: Sat, 3 Dec 2016 13:01:34 +0100 Subject: [PATCH] Factorize function -zf-breakpoint-value into -zf-get-bp-val - 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 | 2 +- scss/util/_breakpoint.scss | 30 ++++++++++-------------------- scss/util/_mixins.scss | 2 +- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/scss/grid/_row.scss b/scss/grid/_row.scss index b84f9c03e..e9718550e 100644 --- a/scss/grid/_row.scss +++ b/scss/grid/_row.scss @@ -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; diff --git a/scss/util/_breakpoint.scss b/scss/util/_breakpoint.scss index f4b142f09..238b83789 100644 --- a/scss/util/_breakpoint.scss +++ b/scss/util/_breakpoint.scss @@ -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; diff --git a/scss/util/_mixins.scss b/scss/util/_mixins.scss index aae42d89c..5aed84d0d 100644 --- a/scss/util/_mixins.scss +++ b/scss/util/_mixins.scss @@ -267,7 +267,7 @@ @else { // breakpoint name @if type-of($name) == 'string' { - $name: -zf-breakpoint-value($name, $map); + $name: -zf-get-bp-val($map, $name); } // breakpoint value -- 2.47.2