Created
October 26, 2017 08:58
-
-
Save evolutionxbox/bbcee7d0db7350aafb44bb0db0c1a1a5 to your computer and use it in GitHub Desktop.
Takes className(s) and converts it to a CSS string (although a little buggy)
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
/** | |
* "foo bar baz", "bar foo moo" -> ".foo.bar.baz .bar.foo.moo" | |
* @param {String...} classString | |
* @return {String} | |
*/ | |
module.exports = function classNameToSelector(classString) { | |
var selector = []; | |
for (var i = 0, len = arguments.length; i < len; i++) { | |
selector.push(_classNameToSelector(arguments[i])); | |
} | |
return selector.join(' '); | |
}; | |
/** | |
* "foo bar baz" -> ".foo.bar.baz" | |
* @param {String} classString | |
* @return {String} | |
*/ | |
function _classNameToSelector(classString) { | |
return (' ' + classString).split(' ').join('.').trim(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment