aboutsummaryrefslogtreecommitdiffstats
path: root/src/bem/_theme.scss
diff options
context:
space:
mode:
Diffstat (limited to 'src/bem/_theme.scss')
-rw-r--r--src/bem/_theme.scss61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/bem/_theme.scss b/src/bem/_theme.scss
new file mode 100644
index 0000000..b4bcc76
--- /dev/null
+++ b/src/bem/_theme.scss
@@ -0,0 +1,61 @@
1////
2/// @group BEM
3///
4/// @access public
5////
6
7///
8/// Declare new rules for the current block for when this theme is active.
9///
10/// @param {string} $name - First theme block name
11/// @param {string} $names - More theme block names
12///
13/// @content
14///
15@mixin iro-bem-at-theme($name, $names...) {
16 $result: iro-bem-at-theme($name, $names...);
17 $selector: nth($result, 1);
18 $context: nth($result, 2);
19
20 @include iro-bem-validate(
21 'at-theme',
22 (name: $name, names: $names),
23 $selector,
24 $context
25 );
26
27 @include iro-context-push($iro-bem-context-id, $context...);
28 @at-root #{$selector} {
29 @content;
30 }
31 @include iro-context-pop($iro-bem-context-id);
32}
33
34///
35/// Declare new rules for the current block for when this theme is active.
36/// Check the respective mixin documentation for more information.
37///
38/// @return {list} A list with two items: 1. selector, 2. context or `null`
39///
40/// @see {mixin} iro-bem-at-theme
41///
42@function iro-bem-at-theme($name, $names...) {
43 $noop: iro-context-assert-stack-must-contain($iro-bem-context-id, 'block');
44
45 $parent-context: iro-context-get($iro-bem-context-id, 'block');
46 $parent-selector: map-get(nth($parent-context, 2), 'selector');
47
48 @if not iro-selector-suffix-match(&, $parent-selector) {
49 @error 'An at-theme rule must be an immediate child of a block';
50 }
51
52 $selector: iro-bem-theme-selector($name, $names...);
53 $selector: selector-nest($selector, &);
54
55 $context: 'at-theme', (
56 'name': join($name, $names),
57 'selector': $selector
58 );
59
60 @return $selector $context;
61}