Last active
November 30, 2018 05:33
-
-
Save bitfidget/bd5816315a9aceb3ff80eba3b8db3a2c 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
/* | |
* @Author: Kriss Heimanis | |
* @Date: 2017-12-22 12:21:08 | |
* @Last Modified by: Kriss Heimanis | |
* @Last Modified time: 2017-12-22 13:11:43 | |
* Helper function to simplify conditional classNames. | |
* Accepts object as args. | |
* Object item key is the className, the value is the condition that must be met to include that className. | |
* Either item can be dynamic | |
*/ | |
const conditionalClassNames = (args) => { | |
let ret = [] | |
Object.keys(args).map(function (key) { | |
if (args[key]) { | |
ret.push(key) | |
} | |
}) | |
return ret.join(' ') | |
} | |
export default conditionalClassNames |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment