From dd5f3c463fab336d694f426dcad11a1783590fc9 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sat, 5 Feb 2022 07:52:13 +0100 Subject: Ported from import syntax to modules --- src/bem/_multi.scss | 56 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 20 deletions(-) (limited to 'src/bem/_multi.scss') diff --git a/src/bem/_multi.scss b/src/bem/_multi.scss index 9e47ce4..1de5cdc 100644 --- a/src/bem/_multi.scss +++ b/src/bem/_multi.scss @@ -4,6 +4,16 @@ /// @access public //// +@use '../functions'; +@use '../contexts'; +@use './block'; +@use './element'; +@use './modifier'; +@use './state'; +@use './suffix'; +@use './theme'; +@use './vars'; + /// /// Generate multiple entities (BEM or not) at once. /// @@ -15,10 +25,10 @@ /// @content /// /// @example scss - Creating multiple elements, a modifier and an anchor -/// @include iro-bem-object('buttonstrip') { +/// @include object('buttonstrip') { /// display: none; /// -/// @include iro-bem-multi('modifier' 'mod', 'element' 'button' 'separator', '> a') { +/// @include multi('modifier' 'mod', 'elem' 'button' 'separator', '> a') { /// display: block; /// } /// } @@ -43,10 +53,10 @@ /// } /// /// @example scss - Creating multiple elements, a modifier and an anchor - optional colons included -/// @include iro-bem-object('buttonstrip') { +/// @include object('buttonstrip') { /// display: none; /// -/// @include iro-bem-multi('modifier:' 'mod', 'element:' 'button' 'separator', '> a') { +/// @include multi('modifier:' 'mod', 'elem:' 'button' 'separator', '> a') { /// display: block; /// } /// } @@ -70,14 +80,16 @@ /// display: block; /// } /// -@mixin iro-bem-multi($first, $others...) { - @include iro-context-assert-stack-count($iro-bem-context-id, $iro-bem-max-depth); +@mixin multi($first, $others...) { + @include contexts.assert-stack-count(vars.$context-id, vars.$max-depth); - @each $entity in iro-list-prepend($others, $first) { + @each $entity in functions.list-prepend($others, $first) { $is-manual-selector: false; - @if type-of($entity) == string and not function-exists('iro-bem-' + $entity) { - $is-manual-selector: true; + @if type-of($entity) == string { + @if find-bem-function($entity) == null { + $is-manual-selector: true; + } } @if $is-manual-selector { @@ -91,23 +103,17 @@ @if type-of($entity) == list { $entity-func-id: nth($entity, 1); - $entity: iro-list-slice($entity, 2); + $entity: functions.list-slice($entity, 2); } @else { $entity-func-id: $entity; $entity: (); } @if str-slice($entity-func-id, str-length($entity-func-id)) == ':' { - $entity-func-id: str-slice($entity-func-id, 1, str-length($entity-func-id) - 1); + $entity-func-id: unquote(str-slice($entity-func-id, 1, str-length($entity-func-id) - 1)); } - $sel-func: null; - - @if function-exists('iro-bem-' + $entity-func-id) { - $sel-func: get-function('iro-bem-' + $entity-func-id); - } @else if function-exists($entity-func-id) { - $sel-func: get-function($entity-func-id); - } + $sel-func: find-bem-function($entity-func-id); @if $sel-func == null { @error 'Function "#{inspect($entity-func-id)}" was not found.'; @@ -118,14 +124,24 @@ $entity-result-context: nth($entity-result, 2); @if $entity-result-context != null { - @include iro-context-push($iro-bem-context-id, $entity-result-context...); + @include contexts.push(vars.$context-id, $entity-result-context...); } @at-root #{$entity-result-selector} { @content; } @if $entity-result-context != null { - @include iro-context-pop($iro-bem-context-id); + @include contexts.pop(vars.$context-id); } } } } + +@function find-bem-function($name) { + @each $module in (block element modifier state suffix theme) { + @if function-exists($name, $module) { + @return get-function($name, $module: $module); + } + } + + @return null; +} -- cgit v1.3.1