Sha256: 82e24933532b90cf5ef3db4fb04ce475df7d90267b836521b828331d59951cfa

Contents?: true

Size: 1.2 KB

Versions: 3

Compression:

Stored size: 1.2 KB

Contents

/**
 * Parser to support BEM syntax
 *
 * @access private
 *
 * @param {List} $selectors - string of selectors to parse
 *
 * @return {List} - parsed list of selectors according to syntax
 *
 * @group Internal Functions
 */
@function flint-support-syntax-bem($selectors) {
    // Clean up selector, remove double underscores for spaces
    //  add pseudo character to differentiate selectors
    $selectors: flint-replace-substring(inspect(unquote($selectors)), "__", "/");
    // Parse string back to list without pseudo character
    $selectors: flint-string-to-list($selectors, "/");
    // Define top-most parent of selector
    $parent: nth($selectors, 1);
    // Create new list of parsed selectors
    $selector-list: ("#{$parent}",);

    // Loop over each selector and build list of selectors
    @each $selector in $selectors {
        // Make sure current selector is not the parent
        @if $selector != $parent {
            // Save to selector list
            $selector-list: append($selector-list, "#{$parent}__#{$selector}", "comma");
            // Define new parent
            $parent: "#{$parent}__#{$selector}";
        }
    }

    // Return the list of parsed selectors
    @return $selector-list;
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flint-gs-2.0.6 stylesheets/flint/functions/lib/_support-syntax-bem.scss
flint-gs-2.0.5 stylesheets/flint/functions/lib/_support-syntax-bem.scss
flint-gs-2.0.4 stylesheets/flint/functions/lib/_support-syntax-bem.scss