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

Define CSS variables when html[data-theme] does not exist #1221

Open
glemaitre opened this issue Nov 3, 2023 · 6 comments
Open

Define CSS variables when html[data-theme] does not exist #1221

glemaitre opened this issue Nov 3, 2023 · 6 comments

Comments

@glemaitre
Copy link
Contributor

Currently in sphinx-gallery as set of CSS variables (e.g. sg-background-color) are defined to handle dark/light modes based on a CSS selector defined by pydata-sphinx-theme (i.e. data-theme=light/dark).

It makes that sphinx-gallery is coupled with pydata-sphinx-theme and the CSS variable will exist only if the <html> tag define the data-theme selector as show here:

https://github.com/scikit-learn/scikit-learn/pull/27659/files#diff-7dc66b1264ca920ea9fd1be8da9eb0d0c1250435d13b83cd69dd14c74e9de59bR12-R14

Somehow, these CSS variables are useful on our hand because it allows to detect the context where we draw the diagram (notebook, IDE, HTML page).

I was wondering if in the context of not using pydata-sphinx-theme, these CSS variables could still exist with a default light mode without the need to create the CSS selector from pydata-sphinx-theme, that could be quite tricky to debug when something goes wrong.

NB: I am far to be fluent with the HTML/CSS principles and stacks and I am open to any solution if it appears that we should do differently on sckit-learn side.

@drammock
Copy link
Contributor

drammock commented Nov 3, 2023

just a note to say that this isn't especially unique to pydata-sphinx-theme. For example bootstrap uses the same approach to dynamically changing color theme, and calls it data-bs-theme=light/dark, and there are several other examples out there (one two three four) that use the same data-theme variable name that pydata-sphinx-theme does.

@glemaitre glemaitre changed the title Define CSS variables when pydata-sphinx-theme is not used Define CSS variables when html[data-theme] does not exist Nov 3, 2023
@lucyleeow
Copy link
Contributor

@larsoner thoughts on this? CSS stuff goes over my head.

@lucyleeow
Copy link
Contributor

Also I wonder if we (scikit-learn) should put efforts into converting to pydata theme, but I am not sure who is well versed in html and has the interest...

@GaelVaroquaux
Copy link
Contributor

GaelVaroquaux commented Nov 9, 2023 via email

@glemaitre
Copy link
Contributor Author

Also I wonder if we (scikit-learn) should put efforts into converting to pydata theme,

Yes we should for sure. +1 with @GaelVaroquaux thoughts.

but I am not sure who is well versed in html and has the interest...

I would be interested to have the thing move forward. I assume that the theme should reduce the tricks that we are doing (or we should contribute upstream). I am also far to be know what I am doing with HTML/CSS but we can have a first good-looking enough version and one day, we might get feedbacks/help from UX + frontend developers.

@lucyleeow
Copy link
Contributor

Yes, and maybe it is enough to have someone good with HTML/CSS to review the work.

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

No branches or pull requests

4 participants