From e361a8f73a7c0ef8fa9dc013f136d295a3d01de5 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Wed, 17 Mar 2021 17:56:38 +0100 Subject: Improved property tree function names --- src/_props.scss | 30 +++++++++++++++--------------- src/props-shortcodes.scss | 26 ++++++++++++++------------ 2 files changed, 29 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/_props.scss b/src/_props.scss index 86a2215..5577f3a 100644 --- a/src/_props.scss +++ b/src/_props.scss @@ -77,7 +77,7 @@ $iro-props-namespace-context-id: 'namespace' !default; /// /// Get the current namespace name. /// -@function iro-props-ns-name() { +@function iro-props-namespace() { $noop: iro-context-assert-stack-must-contain($iro-props-namespace-context-id, 'namespace'); $data: nth(iro-context-get($iro-props-namespace-context-id, 'namespace'), 2); @@ -172,7 +172,7 @@ $iro-props-namespace-context-id: 'namespace' !default; /// /// @throw If there was no match for $key and $default is null /// -@function iro-props-get($key: (), $tree: $iro-props-default-tree, $default: null, $global: false) { +@function iro-props-get-static($key: (), $tree: $iro-props-default-tree, $default: null, $global: false) { @if not map-has-key($iro-props-trees, $tree) { @error 'Unknown tree "#{$tree}".'; } @@ -205,9 +205,9 @@ $iro-props-namespace-context-id: 'namespace' !default; @if type-of($result) == list and nth($result, 1) == 'iro-prop-ref' { @if length($result) == 2 { - $result: iro-props-get($tree: nth($result, 2), $global: true); + $result: iro-props-get-static($tree: nth($result, 2), $global: true); } @else { - $result: iro-props-get(nth($result, 3), nth($result, 2), $global: true); + $result: iro-props-get-static(nth($result, 3), nth($result, 2), $global: true); } } } @else { @@ -223,9 +223,9 @@ $iro-props-namespace-context-id: 'namespace' !default; @if type-of($result) == list and nth($result, 1) == 'iro-prop-ref' { @if length($result) == 2 { - $result: iro-props-get($tree: nth($result, 2), $global: true); + $result: iro-props-get-static($tree: nth($result, 2), $global: true); } @else { - $result: iro-props-get(nth($result, 3), nth($result, 2), $global: true); + $result: iro-props-get-static(nth($result, 3), nth($result, 2), $global: true); } } } @@ -250,9 +250,9 @@ $iro-props-namespace-context-id: 'namespace' !default; /// /// @return {string} var() /// -@function iro-props-get-native($key, $tree: null, $default: null, $global: false) { +@function iro-props-get($key, $tree: $iro-props-default-tree, $default: null, $global: false) { @if $tree != null { - $noop: iro-props-get($key, $tree, $default); + $noop: iro-props-get-static($key, $tree, $default); } @if not $global { @@ -295,8 +295,8 @@ $iro-props-namespace-context-id: 'namespace' !default; /// @param {string} $tree [$iro-props-default-tree] - ID of the property tree to use /// @param {string} $root [()] - Sub-tree to use for assignment /// -@mixin iro-props-assign-native($tree: $iro-props-default-tree, $root: (), $skip: (), $prefix: '', $global: false) { - $map: iro-props-get($root, $tree); +@mixin iro-props-assign($tree: $iro-props-default-tree, $root: (), $skip: (), $prefix: '', $global: false) { + $map: iro-props-get-static($root, $tree); $map: map-remove($map, $skip...); @if type-of($prefix) == list { @@ -311,22 +311,22 @@ $iro-props-namespace-context-id: 'namespace' !default; } } - @include iro-props-assign-native-internal($map, $prefix); + @include iro-props-assign-internal($map, $prefix); } /// /// @access private /// -@mixin iro-props-assign-native-internal($map, $prefix: '', $ref-depth: $iro-props-native-assing-max-depth) { +@mixin iro-props-assign-internal($map, $prefix: '', $ref-depth: $iro-props-native-assing-max-depth) { @each $key, $value in $map { $rd: $ref-depth; @if type-of($value) == list and nth($value, 1) == 'iro-prop-ref' { @if $ref-depth != 0 { $rd: $rd - 1; @if length($value) == 2 { - $value: iro-props-get($tree: nth($value, 2)); + $value: iro-props-get-static($tree: nth($value, 2)); } @else { - $value: iro-props-get(nth($value, 3), nth($value, 2)); + $value: iro-props-get-static(nth($value, 3), nth($value, 2)); } } @else { $value: null; @@ -335,7 +335,7 @@ $iro-props-namespace-context-id: 'namespace' !default; @if type-of($value) != map { #{$prefix + $key}: #{$value}; } @else { - @include iro-props-assign-native-internal($value, $prefix + $key, $rd); + @include iro-props-assign-internal($value, $prefix + $key, $rd); } } } diff --git a/src/props-shortcodes.scss b/src/props-shortcodes.scss index 2c678a7..e3e3d06 100644 --- a/src/props-shortcodes.scss +++ b/src/props-shortcodes.scss @@ -10,14 +10,16 @@ /// @alias iro-props-namespace /// @mixin namespace($name) { - @include iro-props-namespace($name); + @include iro-props-namespace($name) { + @content; + } } /// -/// @alias iro-props-ns-name +/// @alias iro-props-namespace /// @function namespace() { - @return iro-props-ns-name(); + @return iro-props-namespace(); } /// @@ -49,24 +51,24 @@ } /// -/// @alias iro-props-get +/// @alias iro-props-get-static /// -@function prop($key: (), $tree: $iro-props-default-tree, $default: null, $global: false) { - @return iro-props-get($key, $tree, $default, $global); +@function static($key: (), $tree: $iro-props-default-tree, $default: null, $global: false) { + @return iro-props-get-static($key, $tree, $default, $global); } /// -/// @alias iro-props-get-native +/// @alias iro-props-get /// -@function n-prop($key, $tree: null, $default: null, $global: false) { - @return iro-props-get-native($key, $tree, $default, $global); +@function prop($key, $tree: $iro-props-default-tree, $default: null, $global: false) { + @return iro-props-get($key, $tree, $default, $global); } /// -/// @alias iro-props-assign-native +/// @alias iro-props-assign /// -@mixin n-assign($tree: $iro-props-default-tree, $root: (), $skip: (), $prefix: '', $global: false) { - @include iro-props-assign-native($tree, $root, $skip, $prefix, $global); +@mixin assign($tree: $iro-props-default-tree, $root: (), $skip: (), $prefix: '', $global: false) { + @include iro-props-assign($tree, $root, $skip, $prefix, $global); } /// -- cgit v1.2.3-70-g09d2