From: Nicolas Coden Date: Sun, 15 Jul 2018 20:16:59 +0000 (+0200) Subject: refactor: move current breakpoint resolution to its own function `-zf-current-breakpoint` X-Git-Tag: v6.6.0~3^2~68^2~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=095a8464e94ab13f963e575d91eea5a4164dd87b;p=thirdparty%2Ffoundation%2Ffoundation-sites.git refactor: move current breakpoint resolution to its own function `-zf-current-breakpoint` --- diff --git a/scss/util/_breakpoint.scss b/scss/util/_breakpoint.scss index 897db2332..8f7fab632 100644 --- a/scss/util/_breakpoint.scss +++ b/scss/util/_breakpoint.scss @@ -328,6 +328,28 @@ $breakpoint-classes: (small medium large) !default; } } +/// Return the best breakpoint to use according to the calling context. It returns in order: +/// 1. the given `$value` argument if it is not null. +/// 2. the global breakpoint context `$-zf-size` if it is not null (like if called inside then `breakpoint()` mixin) +/// 3. the given `$default` argument. +/// @access private +/// +/// @param {Keyword} $value [null] - Breakpoint to use in priority if non-null. +/// @param {Keyword} $default [null] - Breakpoint to use by default if no other value can be used. +/// +/// @return {Keyword} The resolved breakpoint. +@function -zf-current-breakpoint($value: null, $default: null) { + @if ($value != null) { + @return $value; + } + @else if (variable-exists(-zf-size) and type-of($-zf-size) != 'number') and $-zf-size != null { + @return $-zf-size; + } + @else { + @return $default; + } +} + $small-up: ''; $small-only: ''; diff --git a/scss/xy-grid/_cell.scss b/scss/xy-grid/_cell.scss index d98a72a5e..7873e66be 100644 --- a/scss/xy-grid/_cell.scss +++ b/scss/xy-grid/_cell.scss @@ -122,15 +122,11 @@ } } + // Use the contextual breakpoint by default. Otherwise revert to the smallest breakpoint + $breakpoint: -zf-current-breakpoint($breakpoint); @if($breakpoint == null) { - // If `$bp-size` is available then use this, otherwise revert to the smallest bp. - @if(variable-exists(-zf-size) and type-of($-zf-size) != 'number') and $-zf-size != null { - $breakpoint: $-zf-size; - } - @else { - $breakpoint: $-zf-zero-breakpoint; - $bp-is-fallback: true; - } + $breakpoint: $-zf-zero-breakpoint; + $bp-is-fallback: true; } // Get the default gutter position according to cell direction