-
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should arrays be supported? #1
Comments
Awesome that you ported tailwind-merge to Ruby, love it! Here's the reason why I added support for arrays in tailwind-merge: Sometimes there are styles which only get applied with conditions. E.g. a button which gets some styles when it twMerge('…', isSomeVariant && '…', isSomeVariant && isLarge && '…') The twMerge(
'…',
someArray.length === 0 && !isNotSomeOtherVariant && '…',
someArray.length === 0 && !isNotSomeOtherVariant && isLarge && '…'
) It's easy to make mistakes here, especially if you need to change something about the condition in the future and forget to update the other condition. In the last example I'd probably move the condition But this can be solved with an array as well which makes it possible to inline the variant condition while not needing to duplicate it. twMerge(
'…',
someArray.length === 0 && !isNotSomeOtherVariant && [
'…',
isLarge && '…'
]
) |
Hey hey! Thank you so much for building the original NPM package. I had been trying the same thing with some hideous regular expressions. As for me, I hit a performance issue with the way I was composing Tailwind classes as a string; I decided to just throw an Array at this gem instead. But, just now, I figured out a way to workaround my issue, so this is now less necessary for me. |
cc dcastil/tailwind-merge#127
The text was updated successfully, but these errors were encountered: