-
Notifications
You must be signed in to change notification settings - Fork 25
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
No Tailwind selectors #1894
No Tailwind selectors #1894
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
I changed base to |
To be clear, good things about this PR:
|
This part bothered me, so I implemented |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to trust you here. Don't fully understand this, but your comment definitely seems reasonable.
At this point, I'm not very worried about non-tailwind-components-users.
Fixes #1892.
Built on top of #1828; this doesn't belong in that PR, but also that PR is currently subtly broken, so if we accept this change then we should merge this PR instead.
Unfortunately, this PR makes squiggle-components harder to adopt for those who don't use Tailwind. But easier for those who do use Tailwind, including our team.
This is mostly Tailwind's fault; it doesn't provide a good solution for how to scope its preflight styles.
I got lucky with this PR that the solution for Docusaurus exists: facebook/docusaurus#2961 (comment), and it works pretty well. Though I don't like that it loads an extra CSS file from the CDN. But we'll probably migrate from Docusaurus to Nextra (#1801) before this causes us any problems.
In the future, if we want to simplify the adoption of squiggle-components by non-Tailwind teams, we'll have to do something like this:
@quri/ui
, with a default name.@quri/ui
and@quri/squiggle-components
for Tailwind classes, and if we ever split our packages further, consumers will have to update their tailwind.config.js file.@quri/ui
, this was done bytailwindSelector
prop; in the future, this could be achieved by the top-level<TailwindContext.Provider value={{selector: "squiggle"}}>
, which would be picked up by@quri/ui
components and injected into portals. Then we'd have to ask squiggle-components consumers to put that provider somewhere at the top level of their app. (It's not possible to passtailwindSelector
explicitly, because modals are rendered by squiggle-components, so the necessary selector class must be passed through the provider.)To clarify, not everyone has to include a scoped preflight for components to work. But Tailwind's non-scoped preflight is pretty aggressive (i.e., it resets h1/h2/h3 styles), so it would usually break user's other styles. In case of Docusaurus, the solution that I linked above injects Tailwind's unscoped preflight before Docusaurus global styles, which makes them compatible. In other setups, this might be harder/impossible to do.