Last active
April 24, 2020 09:09
-
-
Save Ivannnnn/b58a0584f87ea8c70afa40e56739dd16 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
export const classes = (...args) => { | |
return args | |
.map((arg) => { | |
if (arg === null || arg === undefined) return null | |
return typeof arg === 'string' | |
? arg | |
: Object.keys(arg) | |
.filter((key) => arg[key]) | |
.join(' ') | |
}) | |
.filter(Boolean) | |
.join(' ') | |
} | |
classes('a', 'b', { fill: true, disable: false }) // "a b fill" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment