diff options
author | Volpeon <git@volpeon.ink> | 2021-03-17 17:56:38 +0100 |
---|---|---|
committer | Volpeon <git@volpeon.ink> | 2021-03-17 17:56:38 +0100 |
commit | e361a8f73a7c0ef8fa9dc013f136d295a3d01de5 (patch) | |
tree | 62872558fcbed9c9300db74d718dd278eb19adca /src | |
parent | Added namespaces and shortcodes for property trees (diff) | |
download | iro-sass-e361a8f73a7c0ef8fa9dc013f136d295a3d01de5.tar.gz iro-sass-e361a8f73a7c0ef8fa9dc013f136d295a3d01de5.tar.bz2 iro-sass-e361a8f73a7c0ef8fa9dc013f136d295a3d01de5.zip |
Improved property tree function names
Diffstat (limited to 'src')
-rw-r--r-- | src/_props.scss | 30 | ||||
-rw-r--r-- | src/props-shortcodes.scss | 26 |
2 files changed, 29 insertions, 27 deletions
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; | |||
77 | /// | 77 | /// |
78 | /// Get the current namespace name. | 78 | /// Get the current namespace name. |
79 | /// | 79 | /// |
80 | @function iro-props-ns-name() { | 80 | @function iro-props-namespace() { |
81 | $noop: iro-context-assert-stack-must-contain($iro-props-namespace-context-id, 'namespace'); | 81 | $noop: iro-context-assert-stack-must-contain($iro-props-namespace-context-id, 'namespace'); |
82 | 82 | ||
83 | $data: nth(iro-context-get($iro-props-namespace-context-id, 'namespace'), 2); | 83 | $data: nth(iro-context-get($iro-props-namespace-context-id, 'namespace'), 2); |
@@ -172,7 +172,7 @@ $iro-props-namespace-context-id: 'namespace' !default; | |||
172 | /// | 172 | /// |
173 | /// @throw If there was no match for $key and $default is null | 173 | /// @throw If there was no match for $key and $default is null |
174 | /// | 174 | /// |
175 | @function iro-props-get($key: (), $tree: $iro-props-default-tree, $default: null, $global: false) { | 175 | @function iro-props-get-static($key: (), $tree: $iro-props-default-tree, $default: null, $global: false) { |
176 | @if not map-has-key($iro-props-trees, $tree) { | 176 | @if not map-has-key($iro-props-trees, $tree) { |
177 | @error 'Unknown tree "#{$tree}".'; | 177 | @error 'Unknown tree "#{$tree}".'; |
178 | } | 178 | } |
@@ -205,9 +205,9 @@ $iro-props-namespace-context-id: 'namespace' !default; | |||
205 | 205 | ||
206 | @if type-of($result) == list and nth($result, 1) == 'iro-prop-ref' { | 206 | @if type-of($result) == list and nth($result, 1) == 'iro-prop-ref' { |
207 | @if length($result) == 2 { | 207 | @if length($result) == 2 { |
208 | $result: iro-props-get($tree: nth($result, 2), $global: true); | 208 | $result: iro-props-get-static($tree: nth($result, 2), $global: true); |
209 | } @else { | 209 | } @else { |
210 | $result: iro-props-get(nth($result, 3), nth($result, 2), $global: true); | 210 | $result: iro-props-get-static(nth($result, 3), nth($result, 2), $global: true); |
211 | } | 211 | } |
212 | } | 212 | } |
213 | } @else { | 213 | } @else { |
@@ -223,9 +223,9 @@ $iro-props-namespace-context-id: 'namespace' !default; | |||
223 | 223 | ||
224 | @if type-of($result) == list and nth($result, 1) == 'iro-prop-ref' { | 224 | @if type-of($result) == list and nth($result, 1) == 'iro-prop-ref' { |
225 | @if length($result) == 2 { | 225 | @if length($result) == 2 { |
226 | $result: iro-props-get($tree: nth($result, 2), $global: true); | 226 | $result: iro-props-get-static($tree: nth($result, 2), $global: true); |
227 | } @else { | 227 | } @else { |
228 | $result: iro-props-get(nth($result, 3), nth($result, 2), $global: true); | 228 | $result: iro-props-get-static(nth($result, 3), nth($result, 2), $global: true); |
229 | } | 229 | } |
230 | } | 230 | } |
231 | } | 231 | } |
@@ -250,9 +250,9 @@ $iro-props-namespace-context-id: 'namespace' !default; | |||
250 | /// | 250 | /// |
251 | /// @return {string} var() | 251 | /// @return {string} var() |
252 | /// | 252 | /// |
253 | @function iro-props-get-native($key, $tree: null, $default: null, $global: false) { | 253 | @function iro-props-get($key, $tree: $iro-props-default-tree, $default: null, $global: false) { |
254 | @if $tree != null { | 254 | @if $tree != null { |
255 | $noop: iro-props-get($key, $tree, $default); | 255 | $noop: iro-props-get-static($key, $tree, $default); |
256 | } | 256 | } |
257 | 257 | ||
258 | @if not $global { | 258 | @if not $global { |
@@ -295,8 +295,8 @@ $iro-props-namespace-context-id: 'namespace' !default; | |||
295 | /// @param {string} $tree [$iro-props-default-tree] - ID of the property tree to use | 295 | /// @param {string} $tree [$iro-props-default-tree] - ID of the property tree to use |
296 | /// @param {string} $root [()] - Sub-tree to use for assignment | 296 | /// @param {string} $root [()] - Sub-tree to use for assignment |
297 | /// | 297 | /// |
298 | @mixin iro-props-assign-native($tree: $iro-props-default-tree, $root: (), $skip: (), $prefix: '', $global: false) { | 298 | @mixin iro-props-assign($tree: $iro-props-default-tree, $root: (), $skip: (), $prefix: '', $global: false) { |
299 | $map: iro-props-get($root, $tree); | 299 | $map: iro-props-get-static($root, $tree); |
300 | $map: map-remove($map, $skip...); | 300 | $map: map-remove($map, $skip...); |
301 | 301 | ||
302 | @if type-of($prefix) == list { | 302 | @if type-of($prefix) == list { |
@@ -311,22 +311,22 @@ $iro-props-namespace-context-id: 'namespace' !default; | |||
311 | } | 311 | } |
312 | } | 312 | } |
313 | 313 | ||
314 | @include iro-props-assign-native-internal($map, $prefix); | 314 | @include iro-props-assign-internal($map, $prefix); |
315 | } | 315 | } |
316 | 316 | ||
317 | /// | 317 | /// |
318 | /// @access private | 318 | /// @access private |
319 | /// | 319 | /// |
320 | @mixin iro-props-assign-native-internal($map, $prefix: '', $ref-depth: $iro-props-native-assing-max-depth) { | 320 | @mixin iro-props-assign-internal($map, $prefix: '', $ref-depth: $iro-props-native-assing-max-depth) { |
321 | @each $key, $value in $map { | 321 | @each $key, $value in $map { |
322 | $rd: $ref-depth; | 322 | $rd: $ref-depth; |
323 | @if type-of($value) == list and nth($value, 1) == 'iro-prop-ref' { | 323 | @if type-of($value) == list and nth($value, 1) == 'iro-prop-ref' { |
324 | @if $ref-depth != 0 { | 324 | @if $ref-depth != 0 { |
325 | $rd: $rd - 1; | 325 | $rd: $rd - 1; |
326 | @if length($value) == 2 { | 326 | @if length($value) == 2 { |
327 | $value: iro-props-get($tree: nth($value, 2)); | 327 | $value: iro-props-get-static($tree: nth($value, 2)); |
328 | } @else { | 328 | } @else { |
329 | $value: iro-props-get(nth($value, 3), nth($value, 2)); | 329 | $value: iro-props-get-static(nth($value, 3), nth($value, 2)); |
330 | } | 330 | } |
331 | } @else { | 331 | } @else { |
332 | $value: null; | 332 | $value: null; |
@@ -335,7 +335,7 @@ $iro-props-namespace-context-id: 'namespace' !default; | |||
335 | @if type-of($value) != map { | 335 | @if type-of($value) != map { |
336 | #{$prefix + $key}: #{$value}; | 336 | #{$prefix + $key}: #{$value}; |
337 | } @else { | 337 | } @else { |
338 | @include iro-props-assign-native-internal($value, $prefix + $key, $rd); | 338 | @include iro-props-assign-internal($value, $prefix + $key, $rd); |
339 | } | 339 | } |
340 | } | 340 | } |
341 | } | 341 | } |
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 @@ | |||
10 | /// @alias iro-props-namespace | 10 | /// @alias iro-props-namespace |
11 | /// | 11 | /// |
12 | @mixin namespace($name) { | 12 | @mixin namespace($name) { |
13 | @include iro-props-namespace($name); | 13 | @include iro-props-namespace($name) { |
14 | @content; | ||
15 | } | ||
14 | } | 16 | } |
15 | 17 | ||
16 | /// | 18 | /// |
17 | /// @alias iro-props-ns-name | 19 | /// @alias iro-props-namespace |
18 | /// | 20 | /// |
19 | @function namespace() { | 21 | @function namespace() { |
20 | @return iro-props-ns-name(); | 22 | @return iro-props-namespace(); |
21 | } | 23 | } |
22 | 24 | ||
23 | /// | 25 | /// |
@@ -49,24 +51,24 @@ | |||
49 | } | 51 | } |
50 | 52 | ||
51 | /// | 53 | /// |
52 | /// @alias iro-props-get | 54 | /// @alias iro-props-get-static |
53 | /// | 55 | /// |
54 | @function prop($key: (), $tree: $iro-props-default-tree, $default: null, $global: false) { | 56 | @function static($key: (), $tree: $iro-props-default-tree, $default: null, $global: false) { |
55 | @return iro-props-get($key, $tree, $default, $global); | 57 | @return iro-props-get-static($key, $tree, $default, $global); |
56 | } | 58 | } |
57 | 59 | ||
58 | /// | 60 | /// |
59 | /// @alias iro-props-get-native | 61 | /// @alias iro-props-get |
60 | /// | 62 | /// |
61 | @function n-prop($key, $tree: null, $default: null, $global: false) { | 63 | @function prop($key, $tree: $iro-props-default-tree, $default: null, $global: false) { |
62 | @return iro-props-get-native($key, $tree, $default, $global); | 64 | @return iro-props-get($key, $tree, $default, $global); |
63 | } | 65 | } |
64 | 66 | ||
65 | /// | 67 | /// |
66 | /// @alias iro-props-assign-native | 68 | /// @alias iro-props-assign |
67 | /// | 69 | /// |
68 | @mixin n-assign($tree: $iro-props-default-tree, $root: (), $skip: (), $prefix: '', $global: false) { | 70 | @mixin assign($tree: $iro-props-default-tree, $root: (), $skip: (), $prefix: '', $global: false) { |
69 | @include iro-props-assign-native($tree, $root, $skip, $prefix, $global); | 71 | @include iro-props-assign($tree, $root, $skip, $prefix, $global); |
70 | } | 72 | } |
71 | 73 | ||
72 | /// | 74 | /// |