Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 75
Dark theme#44
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
Dark theme #44
Uh oh!
There was an error while loading. Please reload this page.
Conversation
septatrix commented Feb 5, 2020 • edited by hugovk
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by hugovk
Uh oh!
There was an error while loading. Please reload this page.
the-knights-who-say-ni commented Feb 5, 2020
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). Recognized GitHub usernameWe couldn't find a bugs.python.org (b.p.o) account corresponding to the following GitHub usernames: This might be simply due to a missing "GitHub Name" entry in one's b.p.o account settings. This is necessary for legal reasons before we can look at this contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
vitaly-zdanevich commented Feb 6, 2020
Thank you for your important work! I would like to make background a little bit darker, with less contrast of text. |
Uh oh!
There was an error while loading. Please reload this page.
vitaly-zdanevich commented Feb 6, 2020
Dark scrollbar? |
vitaly-zdanevich commented Feb 6, 2020
Just idea - maybe like in Reddit for Android - it is good idea to have Dark theme and AMOLED dark, with #000 as a background? |
JulienPalard commented Feb 6, 2020
Thanks for the work on this, I'm bad at UI/UX so I won't say anything more, I just appreciate someone is handling this. |
opensource-assist commented Feb 7, 2020
It's already very awesome. I like this colour. |
septatrix commented Feb 8, 2020
Thanks for the feedback so far. I will try to incorporate it as far as I can next week but before I finalize it I would like to await the response for dark theme support in Sphinx first. |
septatrix commented Feb 11, 2020
Styling of scrollbars is not easy across browser vendors though I think we may use I currently have a few exams coming up so I probably won't get to implementing it until this weekend |
septatrix commented Feb 13, 2020
I did some further improvements and updated the TODO list above... |
zacps commented Feb 14, 2020
Seems to be missing styles for 'sidebars'. See asyncio. |
septatrix commented Mar 8, 2020
I am currently working on finalizing the upstream changes. Additionally I have implemented a persistent disabling of the dark theme however no activation of the dark theme when prefers-color-scheme is light as this would be a bit trickier and ugly. |
septatrix commented Mar 8, 2020
Updated the demo page |
vitaly-zdanevich commented Mar 20, 2020
I just want to say big THANK YOU again for continuing adding dark theme, this is important for many users. |
septatrix commented Mar 20, 2020
Thanks :D It is almost finished now. All that is left to do is think about how to handle images and maybe add an option to the theme to completely disable dark mode in the config. The upstream changes in Sphinx have been merged for 3.x so we should be good merging this next month when Sphinx 3 is released... |
septatrix commented Apr 4, 2020
As the Sphinx 3 release is right around the corner I did some fine tuning (e.g. reducing bright contrast to reduce eye strain) and switched to If someone would be so kind to make a last review I would be very happy - I updated the live demo and otherwise would say it is ready to be merged :D |
vitaly-zdanevich commented Apr 4, 2020
septatrix commented Apr 5, 2020
Do you have a color in mind? I was using material design, some code editor themes and a few websites as reference. Most of them were close to the one I choose or at least did not use very dark backgrounds. However using the current mechanism it would be very easy to implement an additional full black AMOLED theme if that is what you want... |
vitaly-zdanevich commented Apr 5, 2020
Yes, I want darker background, and I believe many other guys like me :) In some apps they have not only light or dark themes, but also AMOLED dark, for example Reddit on Android, but I am not sure if we need three states. Maybe #111? Also I think that vertical line at the left is too bright. |
septatrix commented Apr 21, 2020
I dimmed the color a bit and added an indicator what the current theme is in the button. |
vitaly-zdanevich commented Apr 22, 2020
ok, anyway, thank you again for such important work. |
septatrix commented May 12, 2020
Is there anything you want to be resolved before merging? Otherwise I would be pleased if you would merge this. In case you still want to adjust some colors I am certain you can do so on your own. |
hugovk commented Feb 7, 2023
I think this is looking really good! I agree minor things can be dealt with later, and if we don't find any really major things it would be good to merge and iterate from there. And I agree Pygments "Monokai" code contrast issues don't really deserve a fix here, they should usually be reported/fixed upstream at https://github.com/pygments/pygments (I've already done a few things for the "Native" dark style used by https://github.com/python/peps). |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
hugovk commented Feb 7, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
On my phone (Android, Samsung S10, Chrome), the search box expands off the screen, which the current docs don't do: This is partly an existing problem in that -- for some pages -- the whole page can be scrolled to the right (new theme and existing theme), but now the search box now extend to the off-screen section: |
nmstoker commented Feb 24, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
I'm late to hearing about this but it's good to see this being worked on. Is the plan to get this out and then refine the design / colour options? (EDIT: sorry, I missed two comments directly above confirming about tuning the colours can come later. In light of that, my points below are more for the next stage 🙂) I'm viewing it on Firefox Nightly on Android (I'll try to compare with other browsers/computers later on in case there are significant differences). Right now the colour choices, especially around the various shades of grey, seem quite jarring. I'm no colour expert but I suspect it might look more consistent if most of the background shades came from essentially the same "colour" / hue of grey and largely varied the lightness (subtly). Also having shades of grey and then a pure black header looks odd too. |
pdcastro commented Feb 24, 2023
My 2 cents is that I have been using the dark theme preview for a while instead of the of official docs, and I find that the dark theme is a massive improvement just as it is right now. This PR was created 3 years ago and the worse outcome would be for the recent momentum to be lost and the PR to be abandoned. So I would say:
As soon as this PR is merged and released, invite everyone who commented here on the remaining unaddressed issues to create new corresponding GitHub issues, to be fixed in future PRs by whoever is willing to contribute further. This is not to dismiss the remaining issues as unimportant. On the contrary, getting this PR merged increases the chance of the remaining issues being addressed because they become doable as smaller pieces of work, by a wider pool of contributors. Congrats to everyone who put effort creating this PR, contributing and reviewing, especially @septatrix - great job! 👏 🎉 |
septatrix commented Feb 24, 2023
Fixed |
hugovk left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current preview link: https://python-docs-theme-previews--44.org.readthedocs.build/en/44/
I asked people on Mastodon to try it out and only got positive feedback.
I agree this is good to merge now, and other things can be adjusted in followups.
Thank you!
pradyunsg commented Mar 10, 2023
With #109, I think we can click merge on this? |
hugovk commented Mar 11, 2023
Almost! Let's deal with #108 (comment) first. |
joshhacksthings commented Mar 16, 2023
@hugovk now that the #108 (comment) has been fixed with #113 , can this now be merged? 😀 |
hugovk commented Mar 16, 2023
Yes, let's do it. @septatrix Thank you for all your work on this PR! And to everyone else for the feedback. |
JulienPalard commented Mar 18, 2023
Just ran: manually so maybe in a few hours docs.python.org/dev/ will use the dark theme, I think it's a good way to test it. |
hugovk commented Mar 18, 2023
It's now live: https://docs.python.org/dev/ |
hugovk commented Apr 28, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
See also python/cpython#103960. Not a theme issue, we need to adjust some images in CPython docs for dark mode. Edit: or shall we add CSS to the theme here, like in python/peps#2409 + python/peps#2949? img.invert-in-dark-mode{filter:invert(1) hue-rotate(.5turn)}Then we can use it in the docs like: .. figure:: hashlib-blake2-tree.png:alt:Explanation of tree mode parameters.:class:invert-in-dark-mode |
hugovk commented Apr 28, 2023
Please see PR #128 to add the class to the theme. |
j-ntw commented Jun 1, 2023
It's live on python 3.13 docs, but not on previous doc versions as recent as python 3.11. Any chance to push the changes there too? |
hugovk commented Aug 14, 2023
This is now live at the main https://docs.python.org site (and 3.12 and 3.13), thanks again @septatrix for all your work and patience! ![]() |








Closes#43.
Closes#101.
Update: I now consider this ready
I have made a crude dark them as requested in #43, however there are still many unfinished areas.
So far I've always tested based on the
datetime.rstfile from the official docs as an example, though this does not use all styles which need to be changed.TODO
General areas
.refcountand.stableabiare used)Components / Classes
Notes
Design decisions
I choose the current main background color based on the header on python.org and went for a different one (
#121212from material design guidelines) for the background color around the edges as I thought this added a bit more depth to it. On second thought however it may be better to go with the single color approach as it is in the official docs. If we then were to the use the darker one this would also improve contrast and leave more space for fine tuning e.g. the anchor/link color.Most other colors are just from experimenting with the color wheel and by what felt right. The background for syntax however still needs to change but for that topic also see below.
Syntax highlighting
As neither Sphinx nor Pygments support switching themes based on a media query right now this would need to be a bit hacky. I might create an issue there and ask if they would be fine with pull request implementing such functionality (in whatever way though I already have an idea). Otherwise we would need to include another stylesheet after
pygments.cssoverwriting the normal one.Theme toggling
As not everybody likes to always have a dark theme it may be a good idea to implement theme switching functionality. This could be achieved using either CSS and some label/input magic or plain ole JS (or server side). CSS would be very accessible but not persistent. Therefore I think we should use the CSS way but save the state in a cookie (like we already do for whether the sidebar is expanded or not).
Try it out
Live version
Updated somewhat regularly:
https://septatrix.github.io/cpython-dark-docs/
Screenshot (outdated)
Full size screenshot - rather large