Skip to content

Instantly share code, notes, and snippets.

@Ivannnnn
Last active April 24, 2020 09:09
Show Gist options
  • Save Ivannnnn/b58a0584f87ea8c70afa40e56739dd16 to your computer and use it in GitHub Desktop.
Save Ivannnnn/b58a0584f87ea8c70afa40e56739dd16 to your computer and use it in GitHub Desktop.
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