-
-
Notifications
You must be signed in to change notification settings - Fork 100
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Scoped preflight for gradual migration #134
Comments
To clarify, I think I want to keep the preflight in place. I tried |
Why do you want them to be removed? They are in a style element. Your emotion styles are kept as well. |
There's is some overlap between the twind base styles/resets and the existing styles on the page that I am trying to resolve. We're introducing twind incrementally, and the overlap in styles makes it hard to do so. Maybe what I'm looking for is a virtual sheet that is mounted alongside each component that uses twind? |
I see! Got you. The preflight causes issues. You want a scoped preflight. That may be difficult because the additional scope like To solve that you must then increase the specificity of all Twind generated classes for example using the Sadly Twind does not have a configurable way to increase the specificity for all generated classes. |
Oh perfect, this might be exactly what I need. Will report back. Thank you for the quick help! |
Oof, yeah, the specificity does not play nicely with other things. For example, all of react-select's default styles get reset when in a Any other ideas? |
@holic Did the last comment help? |
Thanks for checking back in. I think it helped somewhat. There’s this disappearing bottom border thing I discovered when there’s no preflight that I’m trying to debug, but needed to move on to something else yesterday. Will be poking at this some more on Monday.
… On Mar 5, 2021, at 6:51 AM, Sascha Tandel ***@***.***> wrote:
@holic Did the last comment help?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Here's the issue I was seeing. With preflight disabled, some of the borders don't appear. If you remove As far as I can tell from the Chrome inspector, these borders should appear - they aren't grayed out/struckthrough like I would expect if they were being overridden by other styles. |
Ah, maybe it's the lack of this in the base style? If I add It's not until I add both |
Have you checked this comment: #134 (comment) It is working there. Example |
BTW: I changed the title because we may be on to something here. That could evolve into an own module like twind/scoped import { tw, setup } from 'twind/scoped' |
I did but Typescript was complaining about those spreads. Even if I add Here's a better reproduction of how I'm using twind and where it's not working. Maybe it's because the Edit: Nope, that's bad too, because then all downstream components get unset (e.g. a Bootstrap input field loses its border). Maybe we need all descendant selectors/classes to be prefixed with I might just live with the simple |
You need to cast them: import type { CSSRules } from 'twind'
setup({
// Define base style for all Twind rules
preflight: ({ html, body, '*,::before,::after': borderBox, }) => ({
'.tw': {
// Order is important
...(body as CSSRules),
...(html as CSSRules),
...(borderBox as CSSRules),
margin: '0',
padding: '0',
'&::before,&::after': borderBox
}
}),
})
Then we ran into specificity issues again. Maybe we should get the I will stop looking for solutions. But if you need any help or have questions please reach out to me. I would like to move this issue into discussions because I do not really see this as an issue with twind or something that could be solved by twind. Would that be OK with you? |
That seems reasonable! Thanks for all the help 🙏 |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
I'm adding twind to an existing React project with its own CSS (via emotion). I noticed that twind styles are well isolated to the components that use them, but once the component unmounts, some of the base styles (resets, I think) linger on the page.
Is there a recommended approach to cleanly removing these when the component is unmounted?
The text was updated successfully, but these errors were encountered: