ENH: Add dark mode support for some pydata packages#723
ENH: Add dark mode support for some pydata packages#723choldgraf merged 20 commits intopydata:mainfrom
Conversation
| } | ||
|
|
||
| div.cell_output tbody tr:nth-child(odd) { | ||
| background: #f5f5f5; |
There was a problem hiding this comment.
are you sure about a hard coded color ?
|
you also moved the search item right ? |
|
sorry for making a commit I didn't know how to make a suggestion. Now I do. |
| } | ||
|
|
||
| // customize xarray display | ||
| .xr-wrap { |
There was a problem hiding this comment.
| .xr-wrap { | |
| .xr-wrap .x-var-list { |
|
Oops I did not see that you had left some comments, sorry about that! I actually decided to take a slightly different approach here. Rather than special-casing each library, I decided to special case the execution / notebook libraries that people often use. So this PR now adds some rough dark theme support for Also sorry about the search bar stuff, that was just some accidental cruft from another experiment! I think it's ready for a look now - the failing test is because MyST-NB pins the upper bound of Python to 3.10 |
|
cc @tupui - I'm not sure what tool you're using to generate plots/outputs/etc in the scipy docs. This PR adds support for MyST NB and jupyter-sphinx, but we can add another if there's a different one needed to test (as long as it doesn't conflict w/ the previous two tools) |
On SciPy we are using |
|
OK added in a simple example w/ the plot directive in matplotlib...it seems to look OK-enough to me 🤷 |
|
I will have a look tmr thanks 😊 |
tupui
left a comment
There was a problem hiding this comment.
Thanks @choldgraf.
For the figures it's a matter of taste. I will keep the inversion in SciPy as I think it looks better because I can blend it with the background.
The code cells look a bit boxy here with the thin white border which is not present with the light theme.
Maybe consider adding a mathjax example? Or just some CSS for it. It's a "heavy" dependency if just for one example.
| We store our PyData-specific SCSS in two relevant files, both in the `src/pydata_sphinx_theme/assets/styles/` folder: | ||
|
|
||
| - `extensions/_execution.scss` - styles for Sphinx libraries that execute and insert code into the documentation. For example, MyST-NB, Jupyter Sphinx, and the Matplotlib `plot` directive. Most PyData support should go here via generic improvements that all packages benefit from. | ||
| - `extensions/_pydata.scss` - styles for specific libraries in the PyData ecosystem. In general we should try to keep this minimal because it is mostly special-casing single library quirks. |
There was a problem hiding this comment.
Does it mean we should contribute specific changes we have in SciPy for instance? Is this like a showcase section or it would be used somehow?
There was a problem hiding this comment.
My assumption is that there might be many different communities using the functionality of a given PyData package, so if there's a SCSS change that improves something in this category, we should put it in this theme (in the _pydata.scss) file so others benefit from it. See the example in there, it is for an xarray output bug that was conflicting with Bootstrap
Co-authored-by: Pamphile Roy <roy.pamphile@gmail.com>
|
Yeah I agree on the boxiness of the cells (especially with the Jupyter Sphinx extension...I think it looks pretty fine w/ the MyST outputs). re: inversion, my main concern was that this is changing all of the colors in the plot, which I imagine might have negative consequences for the reader's perception of the plot. re: MathJax example, what kinds of things did you have in mind? I just added a docs section in our |
|
For the maths I noticed that the color did not match. It was light gray so not very readable. I added: html[data-theme=dark] .MathJax_SVG * {
fill: var(--pst-color-text-base);
} |
|
ah good call - we weren't testing SVG math output here (we're using the HTML version). Latest commit adds that rule 👍 |
|
I think that this one is now ready to go, anything else to add here? |
|
LGTM too |
|
OK merging this one in since we have a bunch of approvals! |
This does two things:
As part of that, it also adds a (documentation only) dependency on
myst-nb, and uses this execute our new pydata demo page. That should make it easier to cache the execution of that page so that it doesn't have to re-execute every time.I think there's still some improvement to make (e.g., in the xarray CSS styling) but hopefully this makes it easy to naturally extend the CSS as new edge-cases are found with these libraries.
Also fixes two bugs:
Check out the demo docs here: https://pydata-sphinx-theme--723.org.readthedocs.build/en/723/demo/pydata.html