Skip to content

POC - website playground isolation with CSS cascade layers #2764

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

slorber
Copy link

@slorber slorber commented May 16, 2025

Docusaurus maintainer here, trying to see if we can get a simpler built-in solution to avoid global CSS pollution (facebook/docusaurus#6032).

I'd like to ensure that the solution I plan to implement and suggest works well for your library, can you please confirm if you see any unwanted side effects?

Note, since you also provide your own global CSS pollution through custom.css, I also had to wrap your global styles in a layer and revert it so that the playground is not affected. However, this wrapping can have side effects (for example the search input overrides). Those should be easy to fix, so I'd prefer if we focus our discussions on how the playground renders.


From my point of view, it seems to render well and similarly to the shadow dom version, however I didn't check all pages

CleanShot 2025-05-16 at 16 25 15

Copy link
Owner

@gpbl gpbl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much @slorber for your work. This is a dream coming reality!

Everything seems to run as expected - I will investigate more the change to make sure. (Too bad we need to rely on that "impossible selector" workaround, but I think this is CSS just being CSS :)

Comment on lines +488 to +493
html[data-theme="dark"] .rdp-root {
--rdp-accent-color: var(--ifm-color-primary);
--rdp-accent-background-color: #073845;
--rdp-range_end-color: black;
--rdp-range_start-color: black;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this should be put out of the .rdp-demo selector to work (probably it was added to support the shadow DOM).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your feedback, and glad to hear it seems to be working well!

Honestly I'm not sure exactly how your existing lib CSS rules work so I just tried to refactor things to make it look quite the same as it used to be, otherwise you can organize things differently if you think it's appropriate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants