Created
October 21, 2014 10:52
-
-
Save AndrewIngram/e073bf740cd0a7b34a35 to your computer and use it in GitHub Desktop.
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
function cx(classNames, namespace, theme) { | |
var classes; | |
var bemClasses = []; | |
if (typeof classNames == 'object') { | |
classes = Object.keys(classNames).filter(function(className) { | |
return classNames[className]; | |
}); | |
} else { | |
classes = classNames; | |
} | |
classes.forEach(function(className) { | |
var baseClassName = namespace + '-' + className; | |
bemClasses.push(baseClassName); | |
if (theme) { | |
bemClasses.push(baseClassName + '--theme-' + theme); | |
} | |
}); | |
return bemClasses.join(' ');; | |
} | |
module.exports = cx; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment