-
Notifications
You must be signed in to change notification settings - Fork 45
CSS styles being overridden #13
Comments
Hey @raulfdm, thanks for the detailed bug report. Super helpful. The style scoping can definitely be improved; not sure if it's possible to fully override / reset the styles unless we use a shadow DOM, but I'm sure that tailwind has some ability to add scoping at their level too. Will follow up on this when I have time, but tbh I'm pretty swamped these days so it may be awhile. cc @DaniGuardiola 😄 |
Hey @transitive-bullshit , thanks for the answer. I'm not 100% sure if I can do something related to tailwind/typography because the overall goal is exactly having global styles for any element inside A strategy from library could be:
Any option will have pros and cons. If you're open, I can try to come up with some solution. |
I've worked with the typography plugin too. The issue is that the plugin doesn't just style direct descendants of
Unfortunately, this is not the case for this plugin, and in fact, I'd argue it's a larger issue. Normally, when styling the elements inside an article, you're gonna want to target nested ones so that, for instance, bulleted lists inside quotes are styled properly. This results in a situation where every What this boils down to is that those styles are going to affect any elements even if inside the tweets. There is an issue in the Tailwind plugin repo that discusses this, with a few workarounds. There's also this Twitter thread by Adam Wathan (tailwind creator). It's just a hard problem. Here are a few solutions from this package's perspective: As @transitive-bullshit pointed out, a clean way to prevent elements inside tweets from getting selected is to use shadow dom. This could be a very nice way to achieve this, as I'd argue:
However, there is one big blocking issue with this approach: there is no SSR support for shadow DOM. There is a proposal for declarative shadow DOW that would allow it, but for now it's just not an option. Another option (let's call it "option B") is to have resets for everything (as mentioned by @raulfdm). This option doesn't really work in my opinion, because:
ℹ️ PD: before I finished writing this comment I realized that something like Option C could be just using plain divs for everything (instead of semantic elements) as those often don't get styled in these situations (the typography plugin doesn't, for instance), and a few minor resets for basic props (like margin, padding, etc) are affordable. Personally, I'd go for option B, and option A when SSR shadow DOM is a reality (very long term). In conclusion, this is (unfortunately) not a unique problem with An issue I'm personally gonna have to deal with. I'll work on this a bit soon. |
Working on this... #18 |
Hey there 👋.
First, I'd say well done for this project. Really useful.
Just want to bring a point about styling. I currently try to use
react-static-tweets
in myblog
and my global styles are gaining precedence over tweets style no matter where I addimport 'react-static-tweets/styles.css';
(e.g._app.tsx
or component specifics).That's probably because I'm using tailwind with typography plugin and the second one is being added way after react-static styles:
In a nutshell, all my global styles are impacting directly the tweets.
I was wondering the package could provide some sort of CSS scoping + reset (with whatever style it needs to be applied like no margins, no borders, etc).
Info
The text was updated successfully, but these errors were encountered: