From ba81ea5d13e764d67ac213d1fb1c5ee7c2333999 Mon Sep 17 00:00:00 2001 From: aveline Date: Wed, 26 Jan 2022 11:03:20 -0800 Subject: [PATCH 1/3] Move `available-names` to layout --- src/styles/foundation/_layout.scss | 32 ++++++++++++++++++++++++- src/styles/foundation/_utilities.scss | 34 --------------------------- 2 files changed, 31 insertions(+), 35 deletions(-) diff --git a/src/styles/foundation/_layout.scss b/src/styles/foundation/_layout.scss index 35ef9ae5a6e..99be4cc5299 100644 --- a/src/styles/foundation/_layout.scss +++ b/src/styles/foundation/_layout.scss @@ -43,6 +43,36 @@ $layout-width-data: ( ), ); +/// Returns the list of available layout names. +/// @param {Number} $map - The level of depth to get names from. +/// @return {String} The list of names in the map. + +@function available-layout-names($level: 1) { + $output: ''; + $newline: '\A '; + + @if $level == 1 { + @each $key, $value in $layout-width-data { + $output: $output + + '#{$newline}- #{$key} #{available-layout-names($value, $level + 1)}'; + } + } @else { + $output: '('; + $i: 1; + + @each $key, $value in $layout-width-data { + $sep: if($i < length($layout-width-data), ', ', ''); + $output: $output + + '#{$key}#{$sep}#{available-layout-names($value, $level + 1)}'; + $i: $i + 1; + } + + $output: $output + ')'; + } + + @return $output; +} + /// Returns the widths of the specified column. /// @param {String} $name - The column name. /// @return {Number} The width for the column. @@ -53,7 +83,7 @@ $layout-width-data: ( @if type-of($fetched-value) { @return $fetched-value; } @else { - @error 'Column `#{$name} - #{$value}` not found. Available columns: #{available-names($layout-width-data)}'; + @error 'Column `#{$name} - #{$value}` not found. Available columns: #{available-layout-names()}'; } } diff --git a/src/styles/foundation/_utilities.scss b/src/styles/foundation/_utilities.scss index 353c0592da1..f95daea0fdc 100644 --- a/src/styles/foundation/_utilities.scss +++ b/src/styles/foundation/_utilities.scss @@ -1,37 +1,3 @@ -/// Returns the list of available names in a given map. -/// @param {Map} $map - The map of data to list the names from. -/// @param {Number} $map - The level of depth to get names from. -/// @return {String} The list of names in the map. - -@function available-names($map, $level: 1) { - @if type-of($map) != 'map' { - @return null; - } - - $output: ''; - $newline: '\A '; - - @if $level == 1 { - @each $key, $value in $map { - $output: $output + - '#{$newline}- #{$key} #{available-names($value, $level + 1)}'; - } - } @else { - $output: '('; - $i: 1; - - @each $key, $value in $map { - $sep: if($i < length($map), ', ', ''); - $output: $output + '#{$key}#{$sep}#{available-names($value, $level + 1)}'; - $i: $i + 1; - } - - $output: $output + ')'; - } - - @return $output; -} - // Merge multiple maps into one. // @param {Map} $map - Initial default map. // @param {ArgList} $maps - Other maps to merge. From 1f7ee750d7e7a478e48f844553dcc5d9a800d176 Mon Sep 17 00:00:00 2001 From: aveline Date: Wed, 26 Jan 2022 11:17:55 -0800 Subject: [PATCH 2/3] Update UNRELEASED-v9.md --- UNRELEASED-v9.md | 1 + 1 file changed, 1 insertion(+) diff --git a/UNRELEASED-v9.md b/UNRELEASED-v9.md index f320f469294..999dab16044 100644 --- a/UNRELEASED-v9.md +++ b/UNRELEASED-v9.md @@ -37,6 +37,7 @@ Use [the changelog guidelines](/documentation/Versioning%20and%20changelog.md) t - Removed the ms-high-contrast-color() function and replaced any instances with values ([#4938](https://github.com/Shopify/polaris-react/pull/4938)) - Removed the `border()` scss function ([#4934](https://github.com/Shopify/polaris-react/pull/4934)) - Removed the font-family() function and replaced any instances with tokens ([#4940](https://github.com/Shopify/polaris-react/pull/4940)) +- Removed the `available-names()` scss function ([#4967](https://github.com/Shopify/polaris-react/pull/4967)) ### New components From 3f46feecf25cd475d159ea21bf62c1e1a578fc73 Mon Sep 17 00:00:00 2001 From: aveline Date: Wed, 26 Jan 2022 13:36:16 -0800 Subject: [PATCH 3/3] Hardcode error string and remove unused function --- src/styles/foundation/_layout.scss | 32 +----------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/src/styles/foundation/_layout.scss b/src/styles/foundation/_layout.scss index 99be4cc5299..f9ca5a07768 100644 --- a/src/styles/foundation/_layout.scss +++ b/src/styles/foundation/_layout.scss @@ -43,36 +43,6 @@ $layout-width-data: ( ), ); -/// Returns the list of available layout names. -/// @param {Number} $map - The level of depth to get names from. -/// @return {String} The list of names in the map. - -@function available-layout-names($level: 1) { - $output: ''; - $newline: '\A '; - - @if $level == 1 { - @each $key, $value in $layout-width-data { - $output: $output + - '#{$newline}- #{$key} #{available-layout-names($value, $level + 1)}'; - } - } @else { - $output: '('; - $i: 1; - - @each $key, $value in $layout-width-data { - $sep: if($i < length($layout-width-data), ', ', ''); - $output: $output + - '#{$key}#{$sep}#{available-layout-names($value, $level + 1)}'; - $i: $i + 1; - } - - $output: $output + ')'; - } - - @return $output; -} - /// Returns the widths of the specified column. /// @param {String} $name - The column name. /// @return {Number} The width for the column. @@ -83,7 +53,7 @@ $layout-width-data: ( @if type-of($fetched-value) { @return $fetched-value; } @else { - @error 'Column `#{$name} - #{$value}` not found. Available columns: #{available-layout-names()}'; + @error 'Column `#{$name} - #{$value}` not found. Available columns:\a - primary (min, max)\a - secondary (min, max)\a - one-half-width (base)\a - one-third-width (base)\a - nav (base)\a - page-with-nav (base)\a - page-content (not-condensed, partially-condensed)\a - inner-spacing (base)\a - outer-spacing (min, max)'; } }