diff options
| author | Feuerfuchs <git@feuerfuchs.dev> | 2020-11-01 20:55:14 +0100 | 
|---|---|---|
| committer | Feuerfuchs <git@feuerfuchs.dev> | 2020-11-01 20:55:14 +0100 | 
| commit | d07f664450ddaaebb44127a4bd057763d13d3f82 (patch) | |
| tree | 234cfd673ac527869a8dda4f32afbec48c87b512 /src/bem/_theme.scss | |
| download | iro-sass-d07f664450ddaaebb44127a4bd057763d13d3f82.tar.gz iro-sass-d07f664450ddaaebb44127a4bd057763d13d3f82.tar.bz2 iro-sass-d07f664450ddaaebb44127a4bd057763d13d3f82.zip | |
Init
Diffstat (limited to 'src/bem/_theme.scss')
| -rw-r--r-- | src/bem/_theme.scss | 61 | 
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 | } | ||
