Last active
September 17, 2016 22:45
-
-
Save ronen-e/f41173a35732c712322a3a7f2161ab44 to your computer and use it in GitHub Desktop.
css classnames prefix factory
This file contains hidden or 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 prefixFactory(prefix) { | |
| return function prefixer(string) { | |
| return string.split(' ') | |
| .map( s => prefix + s) | |
| .join(' '); | |
| }; | |
| } | |
| export default prefixFactory; |
This file contains hidden or 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
| import prefixFactory from 'prefix-factory'; | |
| var prefixer = prefixFactory('my-class-'); | |
| var className = 'one two three'; | |
| var prefixedClassName = prefixer(className); | |
| console.log(prefixedClassName); // "my-class-one my-class-two my-class-three" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment