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

make CSS agnostic of light/dark schemes #734

Open
2bndy5 opened this issue May 1, 2023 · 3 comments
Open

make CSS agnostic of light/dark schemes #734

2bndy5 opened this issue May 1, 2023 · 3 comments

Comments

@2bndy5
Copy link
Contributor

2bndy5 commented May 1, 2023

I noticed a problem with the furo theme example: The background color for stderr output isn't compatible with the dark scheme:
image
but using a transparency with slightly increased saturation should remedy that in a consistent way for light or dark schemes:

/* nbsphinx-code-cells.css | https://nbsphinx.readthedocs.io/en/furo-theme/_static/nbsphinx-code-cells.css */

div.nboutput.container div.output_area.stderr {
  /* background: #fdd; */
  background: #e8808075;
}

image

There are other styles that use opaque hard-coded colors which don't blend well with light and dark schemes. I'll update this thread with other related findings...

@2bndy5
Copy link
Contributor Author

2bndy5 commented May 2, 2023

hardcoded colors that could be made agnostic of BG color:

The following is subject to #733:

border: 1px solid #e0e0e0;

@mgeier
Copy link
Member

mgeier commented May 3, 2023

Thanks for reporting this!

nbsphinx is not supporting dark themes yet (see also #635).

I would like to fix this at some point, but I'm still too confused about how to do that. Sphinx has hardly any support for a dark theme, and many third party themes use quite different technologies for their dark themes. I think this makes it basically impossible to be working correctly on all themes.

The idea with transparency sounds nice, but I guess it can only be used in a few situation and not as a general strategy, right?

For comparison, this is how the JupyterLab dark theme looks like:

image

@2bndy5
Copy link
Contributor Author

2bndy5 commented May 3, 2023

Sphinx has hardly any support for a dark theme

I don't think dark mode is a Sphinx support issue. It can be done with HTML and CSS templates.

many third party themes use quite different technologies for their dark themes

Sort of. From what I've seen, light/dark modes are typically toggled using an attribute on the DOM <body>. The only thing that is really inconsistent is the name of the attribute that is used.

CSS has a media feature that can be used to compensate for these scenarios, but it might not fit all themes.

The idea with transparency sounds nice, but I guess it can only be used in a few situation and not as a general strategy, right?

If you absolutely want the color to be opaque, then it is harder to satisfy this. But I would recommend the aforementioned CSS media feature when transparency isn't preferrable.

Changing the foreground color makes sense, but it should really only be done if changing the background color to something opaque (as is done for certain rows of tables in nbsphinx).

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

2 participants