Skip to content
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

Scope tailwind preflight styles #740

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

Conversation

Bjoern-Rapp
Copy link

@Bjoern-Rapp Bjoern-Rapp commented Jan 29, 2025

Anywidget loads CSS from the _css attribute to the global scope. A widget most take care not to conflict with any other CSS selectors. The stylesheet from the tailwind preflight, loaded with @tailwind base, will conflict with stylesheets from Sphinx themes (#698) or the VScode interactive display (#696).

To scope the preflight stylesheet to descendants of a wrapper should fix that.

@kylebarron
Copy link
Member

Oo interesting; so this would solve #696?

@vgeorge any thoughts?

@Bjoern-Rapp
Copy link
Author

Yes, that will fix the problem with "leaking" CSS for both #696 and #698.
#696 don't just affects the widget, but the whole notebook/interactive window.

Existing PR
image image

It will not fix the unrelated problem/ feature request of adhering to dark or light themes inside the widget itself.

@Bjoern-Rapp Bjoern-Rapp marked this pull request as ready for review January 30, 2025 14:05
@Bjoern-Rapp Bjoern-Rapp changed the title Attempt too scope tailwind preflight styles Scope tailwind preflight styles Jan 30, 2025
@kylebarron kylebarron requested a review from vgeorge January 30, 2025 15:27
@vgeorge
Copy link
Member

vgeorge commented Jan 30, 2025

@Bjoern-Rapp this is working for me. I tested in vscode and it doesn't seem to be leaking styles anymore. Would you be able to run npm run prettier on your branch and commit the results? This should fix the failing checks.

Comment on lines +2 to +26
color: #11181c;
color: hsl(var(--nextui-foreground));
background-color: #fff;
background-color: hsl(var(--nextui-background));
margin: 0;
line-height: 1.5;
-webkit-text-size-adjust: 100%;
tab-size: 4;
font-family:
ui-sans-serif,
system-ui,
-apple-system,
Segoe UI,
Roboto,
Ubuntu,
Cantarell,
Noto Sans,
sans-serif,
"Apple Color Emoji",
"Segoe UI Emoji",
Segoe UI Symbol,
"Noto Color Emoji";
font-feature-settings: normal;
font-variation-settings: normal;
-webkit-tap-highlight-color: transparent;
Copy link
Member

Choose a reason for hiding this comment

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

@Bjoern-Rapp it didn't notice this when I reviewed yesterday. Could you explain why this was added?

Copy link
Author

Choose a reason for hiding this comment

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

Some selectors in the preflight stylesheet targets html, body and :root elements. They become useless when scoped to the div.lonboard wrapper, since there are no html or body elements inside the wrapper. The only alternative then is to copy / duplicate those properties from the resulting stylesheet and apply them directly to the wrapper.

@kylebarron kylebarron requested a review from vgeorge January 31, 2025 16:23
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.

3 participants