Last active
June 23, 2022 13:09
-
-
Save alenaksu/e2fd8e1d1be02dc2e21967f8afb0697d to your computer and use it in GitHub Desktop.
classNames.ts
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
export const classNames = ( | |
...classes: Array<string | string[] | Record<string]: boolean }> | |
): string | undefined => classes | |
.map(cls => cls?.constructor.name === 'Object' ? Object.keys(cls).filter(key => cls[key]) : cls) | |
.flat() | |
.filter(Boolean) | |
.join(' ') || undefined; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment