Last active
June 12, 2019 09:24
-
-
Save emanuel-sanabria-developer/a48be5422e857160e77bdb4ab0e65a6f to your computer and use it in GitHub Desktop.
bem className generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default (block) => { | |
return (element, modifiers) => { | |
let className = block; | |
if (element) { | |
className = `${block}_${element}`; | |
} | |
if (modifiers) { | |
for (const modifier of Object.keys(modifiers)) { | |
if (modifiers[modifier]) { | |
className += ` ${className}--${modifier}`; | |
} | |
} | |
} | |
return className; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment