Closed jon-robertson closed 6 months ago
Hey @Jon-Robertson, thanks for taking the time to open a PR!
Before adding a new feature, I'd like to better understand where this is coming from. What's the issue you're running into? Why weren't the built-in styling options (described in the docs) sufficient? Is there something that prevents Tailwind users from simply passing the classes as e.g. containerStyles
?
Also, svelte-micromodal
shouldn't assume Tailwind usage, so if we need to improve how styling works, I'd prefer to avoid tailwind-merge
. (Instead we can probably write it ourselves by concatenating classes, no need for complex logic IÂ think. But I might be missing something, looking forward to hearing about your use case.)
Thanks again!
P.S. I haven't used Tailwind for a while, which might explain my blind spot here. Thanks in advance for some extra context!
Hey Robin. The HTML style attribute can only contain CSS declarations, not classes. Tailwind works by giving the user predefined classes which need to be added to an element's class attribute. There is of course the option of picking apart the class and manually entering each declaration in the style attribute but this would get messy when trying to do any moderate amount of styling. This isn't just an issue for Tailwind either, anyone that wants to add a class they have defined would be unable to apply it to the modal as well. I used Tailwind merge because it's what I'm used to but since we're just taking in a string of classes I don't see an issue with string concatenation instead.
:facepalm: I thought we were already exposing class
es, just realized it's just style
s. Apologies!
Then this makes a LOT of sense. If you don't mind I'd still prefer a "manual" concatenation over a new lib. Would you be okay with making the changes to your branch?
Thanks!
Hi Robin, I've added a commit to remove Tailwind merge. Let me know if you'd like anything else changed and thanks for creating this repo.
Hi @Jon-Robertson, sorry for the late reply here and thanks a lot for this! It looks good to me — I'll go ahead and merge it, and handle the release in a few hours max. I'll send an updated here when the new version is live.
Thanks for the contribution and thanks for bearing with me!
Released to NPM under version 0.0.10, please let me know if you find any issues!
Note: when trying this out, IÂ realized that using classes might be a little bit tricky out of the box because of Svelte's behavior and specificity issues.
See https://github.com/robinmetral/svelte-micromodal/issues/10 for details! In the meantime, passing custom classes to the modal should work, with caveats.
Adds support for tailwind users as well as anyone that wants to use classes.