From f0f84513f8efe533b6ee670a6f1a0c074387b2ec Mon Sep 17 00:00:00 2001 From: Volpeon Date: Wed, 13 Aug 2025 12:01:46 +0200 Subject: Make use of SASS modules --- src/bem/_suffix.scss | 95 +++++++++++++++++++++++++++------------------------- 1 file changed, 49 insertions(+), 46 deletions(-) (limited to 'src/bem/_suffix.scss') diff --git a/src/bem/_suffix.scss b/src/bem/_suffix.scss index 2ddb54d..93e4066 100644 --- a/src/bem/_suffix.scss +++ b/src/bem/_suffix.scss @@ -4,6 +4,9 @@ /// @access public //// +@use 'sass:list'; +@use 'sass:map'; +@use 'sass:selector'; @use './validators'; @use './vars'; @use '../functions'; @@ -54,22 +57,22 @@ /// } /// @mixin suffix($name) { - $result: suffix($name); - $selector: nth($result, 1); - $context: nth($result, 2); + $result: suffix($name); + $selector: list.nth($result, 1); + $context: list.nth($result, 2); - @include validators.validate( - 'suffix', - (name: $name), - $selector, - $context - ); + @include validators.validate( + 'suffix', + (name: $name), + $selector, + $context + ); - @include contexts.push(vars.$context-id, $context...); - @at-root #{$selector} { - @content; - } - @include contexts.pop(vars.$context-id); + @include contexts.push(vars.$context-id, $context...); + @at-root #{$selector} { + @content; + } + @include contexts.pop(vars.$context-id); } /// @@ -80,44 +83,44 @@ /// @see {mixin} suffix /// @function suffix($name) { - // - // Suffixes can be used on block, element and modifier. - // + // + // Suffixes can be used on block, element and modifier. + // - $noop: contexts.assert-stack-count(vars.$context-id, vars.$max-depth); - $noop: contexts.assert-stack-must-contain(vars.$context-id, 'block'); - $noop: contexts.assert-stack-must-not-contain(vars.$context-id, 'suffix'); + $noop: contexts.assert-stack-count(vars.$context-id, vars.$max-depth); + $noop: contexts.assert-stack-must-contain(vars.$context-id, 'block'); + $noop: contexts.assert-stack-must-not-contain(vars.$context-id, 'suffix'); - $parent-context: contexts.get(vars.$context-id, 'block' 'element' 'modifier'); - $parent-selector: map-get(nth($parent-context, 2), 'selector'); + $parent-context: contexts.get(vars.$context-id, 'block' 'element' 'modifier'); + $parent-selector: map.get(list.nth($parent-context, 2), 'selector'); - @if not functions.selector-suffix-match(&, $parent-selector) { - // - // The current selector doesn't match the parent selector. - // The user manually added a selector between parent context and this suffix call. - // This case is forbidden because any outcome semantically wouldn't make sense: - // - {b,e,m} [manual selector] {b,e,m}@suffix - // - {b,e,m}@suffix [manual selector] - // The first case would make the modifier behave like an element. - // The second case is unintuitive, the code would be more clear by nesting the manual - // selector in the suffix instead. - // + @if not functions.selector-suffix-match(&, $parent-selector) { + // + // The current selector doesn't match the parent selector. + // The user manually added a selector between parent context and this suffix call. + // This case is forbidden because any outcome semantically wouldn't make sense: + // - {b,e,m} [manual selector] {b,e,m}@suffix + // - {b,e,m}@suffix [manual selector] + // The first case would make the modifier behave like an element. + // The second case is unintuitive, the code would be more clear by nesting the manual + // selector in the suffix instead. + // - @error 'A suffix must be an immediate child of the parent context'; - } + @error 'A suffix must be an immediate child of the parent context'; + } - // - // The suffix part can simply be appended. - // Possible outcomes: - // - {b,e,m}@suffix - // + // + // The suffix part can simply be appended. + // Possible outcomes: + // - {b,e,m}@suffix + // - $selector: selector-append(&, vars.$suffix-separator + $name); + $selector: selector.append(&, vars.$suffix-separator + $name); - $context: 'suffix', ( - 'name': $name, - 'selector': $selector - ); + $context: 'suffix', ( + 'name': $name, + 'selector': $selector + ); - @return $selector $context; + @return $selector $context; } -- cgit v1.2.3-70-g09d2