diff options
Diffstat (limited to 'src/bem/_multi.scss')
-rw-r--r-- | src/bem/_multi.scss | 56 |
1 files changed, 36 insertions, 20 deletions
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 @@ | |||
4 | /// @access public | 4 | /// @access public |
5 | //// | 5 | //// |
6 | 6 | ||
7 | @use '../functions'; | ||
8 | @use '../contexts'; | ||
9 | @use './block'; | ||
10 | @use './element'; | ||
11 | @use './modifier'; | ||
12 | @use './state'; | ||
13 | @use './suffix'; | ||
14 | @use './theme'; | ||
15 | @use './vars'; | ||
16 | |||
7 | /// | 17 | /// |
8 | /// Generate multiple entities (BEM or not) at once. | 18 | /// Generate multiple entities (BEM or not) at once. |
9 | /// | 19 | /// |
@@ -15,10 +25,10 @@ | |||
15 | /// @content | 25 | /// @content |
16 | /// | 26 | /// |
17 | /// @example scss - Creating multiple elements, a modifier and an anchor | 27 | /// @example scss - Creating multiple elements, a modifier and an anchor |
18 | /// @include iro-bem-object('buttonstrip') { | 28 | /// @include object('buttonstrip') { |
19 | /// display: none; | 29 | /// display: none; |
20 | /// | 30 | /// |
21 | /// @include iro-bem-multi('modifier' 'mod', 'element' 'button' 'separator', '> a') { | 31 | /// @include multi('modifier' 'mod', 'elem' 'button' 'separator', '> a') { |
22 | /// display: block; | 32 | /// display: block; |
23 | /// } | 33 | /// } |
24 | /// } | 34 | /// } |
@@ -43,10 +53,10 @@ | |||
43 | /// } | 53 | /// } |
44 | /// | 54 | /// |
45 | /// @example scss - Creating multiple elements, a modifier and an anchor - optional colons included | 55 | /// @example scss - Creating multiple elements, a modifier and an anchor - optional colons included |
46 | /// @include iro-bem-object('buttonstrip') { | 56 | /// @include object('buttonstrip') { |
47 | /// display: none; | 57 | /// display: none; |
48 | /// | 58 | /// |
49 | /// @include iro-bem-multi('modifier:' 'mod', 'element:' 'button' 'separator', '> a') { | 59 | /// @include multi('modifier:' 'mod', 'elem:' 'button' 'separator', '> a') { |
50 | /// display: block; | 60 | /// display: block; |
51 | /// } | 61 | /// } |
52 | /// } | 62 | /// } |
@@ -70,14 +80,16 @@ | |||
70 | /// display: block; | 80 | /// display: block; |
71 | /// } | 81 | /// } |
72 | /// | 82 | /// |
73 | @mixin iro-bem-multi($first, $others...) { | 83 | @mixin multi($first, $others...) { |
74 | @include iro-context-assert-stack-count($iro-bem-context-id, $iro-bem-max-depth); | 84 | @include contexts.assert-stack-count(vars.$context-id, vars.$max-depth); |
75 | 85 | ||
76 | @each $entity in iro-list-prepend($others, $first) { | 86 | @each $entity in functions.list-prepend($others, $first) { |
77 | $is-manual-selector: false; | 87 | $is-manual-selector: false; |
78 | 88 | ||
79 | @if type-of($entity) == string and not function-exists('iro-bem-' + $entity) { | 89 | @if type-of($entity) == string { |
80 | $is-manual-selector: true; | 90 | @if find-bem-function($entity) == null { |
91 | $is-manual-selector: true; | ||
92 | } | ||
81 | } | 93 | } |
82 | 94 | ||
83 | @if $is-manual-selector { | 95 | @if $is-manual-selector { |
@@ -91,23 +103,17 @@ | |||
91 | 103 | ||
92 | @if type-of($entity) == list { | 104 | @if type-of($entity) == list { |
93 | $entity-func-id: nth($entity, 1); | 105 | $entity-func-id: nth($entity, 1); |
94 | $entity: iro-list-slice($entity, 2); | 106 | $entity: functions.list-slice($entity, 2); |
95 | } @else { | 107 | } @else { |
96 | $entity-func-id: $entity; | 108 | $entity-func-id: $entity; |
97 | $entity: (); | 109 | $entity: (); |
98 | } | 110 | } |
99 | 111 | ||
100 | @if str-slice($entity-func-id, str-length($entity-func-id)) == ':' { | 112 | @if str-slice($entity-func-id, str-length($entity-func-id)) == ':' { |
101 | $entity-func-id: str-slice($entity-func-id, 1, str-length($entity-func-id) - 1); | 113 | $entity-func-id: unquote(str-slice($entity-func-id, 1, str-length($entity-func-id) - 1)); |
102 | } | 114 | } |
103 | 115 | ||
104 | $sel-func: null; | 116 | $sel-func: find-bem-function($entity-func-id); |
105 | |||
106 | @if function-exists('iro-bem-' + $entity-func-id) { | ||
107 | $sel-func: get-function('iro-bem-' + $entity-func-id); | ||
108 | } @else if function-exists($entity-func-id) { | ||
109 | $sel-func: get-function($entity-func-id); | ||
110 | } | ||
111 | 117 | ||
112 | @if $sel-func == null { | 118 | @if $sel-func == null { |
113 | @error 'Function "#{inspect($entity-func-id)}" was not found.'; | 119 | @error 'Function "#{inspect($entity-func-id)}" was not found.'; |
@@ -118,14 +124,24 @@ | |||
118 | $entity-result-context: nth($entity-result, 2); | 124 | $entity-result-context: nth($entity-result, 2); |
119 | 125 | ||
120 | @if $entity-result-context != null { | 126 | @if $entity-result-context != null { |
121 | @include iro-context-push($iro-bem-context-id, $entity-result-context...); | 127 | @include contexts.push(vars.$context-id, $entity-result-context...); |
122 | } | 128 | } |
123 | @at-root #{$entity-result-selector} { | 129 | @at-root #{$entity-result-selector} { |
124 | @content; | 130 | @content; |
125 | } | 131 | } |
126 | @if $entity-result-context != null { | 132 | @if $entity-result-context != null { |
127 | @include iro-context-pop($iro-bem-context-id); | 133 | @include contexts.pop(vars.$context-id); |
128 | } | 134 | } |
129 | } | 135 | } |
130 | } | 136 | } |
131 | } | 137 | } |
138 | |||
139 | @function find-bem-function($name) { | ||
140 | @each $module in (block element modifier state suffix theme) { | ||
141 | @if function-exists($name, $module) { | ||
142 | @return get-function($name, $module: $module); | ||
143 | } | ||
144 | } | ||
145 | |||
146 | @return null; | ||
147 | } | ||