Sha256: 700796bfbe645bcebe6e930eaa24a5826a2d60246c52b18b851b85bdf9c3dbfa

Contents?: true

Size: 1.46 KB

Versions: 9

Compression:

Stored size: 1.46 KB

Contents

// ----------------------------------------------------------------------
// Modifier constructor
// ----------------------------------------------------------------------

/// Initializes a new modifier for the current block or element(s)
/// @private
/// @param {String | Arglist} $modifiers - List of new modifier names
/// @returns The final selector for the new modifier(s)


@function _modifier($modifiers...) {

    // Log new modifier(s)
    $new-modifier: _bem-log-modifier($modifiers...);

    // Error checks
    $inside-check: _should-be-called-within('block');
    $outside-check: _should-not-be-called-within('modifier');

    // Return false in case error throwing is disabled
    @if $inside-check == false or $outside-check == false {
        @return false;
    }

    $selector: ();

    @each $modifier in $modifiers {
        $new-selector: ();

        @each $sel in & {
            $modified-selector: #{$sel}#{$bem-modifier-separator}#{$modifier};
            $new-selector: append($new-selector, $modified-selector, 'comma');
        }

        $selector: append($selector, $new-selector, 'comma');
    }

    $set-current: set-current-context('modifier', $modifiers, $selector);

    @return $selector;
}


/// Creates new modifier(s)
/// @param {String | Arglist} $modifiers  - Name of the new modifier(s)

@mixin modifier($modifiers...) {

    @at-root #{_modifier($modifiers...)} {
        @content;
    }

    $unset-current: unset-current-context('modifier');
}

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
bem-constructor-1.0.0 stylesheets/_modifier.scss
bem-constructor-0.9.0 stylesheets/_modifier.scss
bem-constructor-0.8.0 stylesheets/_modifier.scss
bem-constructor-0.7.1 stylesheets/_modifier.scss
bem-constructor-0.7.0 stylesheets/_modifier.scss
bem-constructor-0.6.0 stylesheets/_modifier.scss
bem-constructor-0.5.0 stylesheets/_modifier.scss
bem-constructor-0.4.0 stylesheets/_modifier.scss
bem-constructor-0.3.2 stylesheets/_modifier.scss