From 7fe731bd48168fa81b337cadebb2e3082cc2d45b Mon Sep 17 00:00:00 2001 From: Markus Pfeifenberger Date: Fri, 21 Feb 2020 14:55:07 +0100 Subject: [PATCH 1/3] [task] add configuration $combined-modifier-selectors and extend @mixin modifier to provide strong modifier selectors --- sass/_bemify.scss | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/sass/_bemify.scss b/sass/_bemify.scss index 32b4269..8cc5cf9 100644 --- a/sass/_bemify.scss +++ b/sass/_bemify.scss @@ -16,6 +16,12 @@ // .block__element--is-active {} $combined-state-selectors: true !default; +// Output combined modifier selectors like: +// .block__element.block__element--modifier {} +// Set to false to output single, non-combined modifier class: +// .block__element--modifier {} +$combined-modifier-selectors: false !default; + // .block[separator]element: $element-separator: "__" !default; @@ -48,9 +54,21 @@ $state-prefix: "is" !default; @mixin modifier($name) { - @at-root { - &#{$modifier-separator}#{$name} { - @content; + @if $combined-modifier-selectors == true { + @at-root { + $self: &; + + #{$self}#{$self}#{$modifier-separator}#{$name} { + @content; + } + } + + } + @else { + @at-root { + &#{$modifier-separator}#{$name} { + @content; + } } } } From 6e157d9d5f3849d16ff69fc1ce5bfb8e0e1a5b31 Mon Sep 17 00:00:00 2001 From: Markus Pfeifenberger Date: Fri, 21 Feb 2020 15:10:36 +0100 Subject: [PATCH 2/3] [task] add mixin selection and configuration for $section-prefix - where a section is a block prefixed with the configured prefix, eg .section-header {} --- sass/_bemify.scss | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sass/_bemify.scss b/sass/_bemify.scss index 8cc5cf9..fce80ec 100644 --- a/sass/_bemify.scss +++ b/sass/_bemify.scss @@ -31,6 +31,8 @@ $modifier-separator: "--" !default; // The default prefix for state modifier selectors, will be combined with $modifier-separator: $state-prefix: "is" !default; +// The default prefix for section selectors, will be combined with the given $name +$section-prefix: 'section' !default; @@ -92,6 +94,11 @@ $state-prefix: "is" !default; } +@mixin section($name) { + @include block(#{$section-prefix}-#{$name}) { + @content; + } +} // ALIASES From 78aa7e8219212a9f251f2c8d8fa31c4cca1a3a2b Mon Sep 17 00:00:00 2001 From: Markus Pfeifenberger Date: Fri, 21 Feb 2020 15:12:37 +0100 Subject: [PATCH 3/3] [task] fix scss-lint issues --- sass/_bemify.scss | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/sass/_bemify.scss b/sass/_bemify.scss index fce80ec..3bac717 100644 --- a/sass/_bemify.scss +++ b/sass/_bemify.scss @@ -23,13 +23,13 @@ $combined-state-selectors: true !default; $combined-modifier-selectors: false !default; // .block[separator]element: -$element-separator: "__" !default; +$element-separator: '__' !default; // .block[separator]modifier: -$modifier-separator: "--" !default; +$modifier-separator: '--' !default; // The default prefix for state modifier selectors, will be combined with $modifier-separator: -$state-prefix: "is" !default; +$state-prefix: 'is' !default; // The default prefix for section selectors, will be combined with the given $name $section-prefix: 'section' !default; @@ -65,8 +65,7 @@ $section-prefix: 'section' !default; } } - } - @else { + } @else { @at-root { &#{$modifier-separator}#{$name} { @content; @@ -83,8 +82,7 @@ $section-prefix: 'section' !default; @content; } } - } - @else { + } @else { @at-root { &#{$modifier-separator}#{$prefix}-#{$state} { @content;