Skip to content

Instantly share code, notes, and snippets.

@emanuel-sanabria-developer
Last active June 12, 2019 09:24
Show Gist options
  • Save emanuel-sanabria-developer/a48be5422e857160e77bdb4ab0e65a6f to your computer and use it in GitHub Desktop.
Save emanuel-sanabria-developer/a48be5422e857160e77bdb4ab0e65a6f to your computer and use it in GitHub Desktop.
bem className generator
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