-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Dark theme #44
Conversation
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! |
Thank you for your important work! I would like to make background a little bit darker, with less contrast of text. |
Dark scrollbar? |
Just idea - maybe like in Reddit for Android - it is good idea to have Dark theme and AMOLED dark, with #000 as a background? |
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. |
It's already very awesome. I like this colour. |
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. |
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 |
I did some further improvements and updated the TODO list above... |
Seems to be missing styles for 'sidebars'. See asyncio. |
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. |
Updated the demo page |
I just want to say big THANK YOU again for continuing adding dark theme, this is important for many users. |
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... |
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 |
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... |
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. |
I dimmed the color a bit and added an indicator what the current theme is in the button. |
ok, anyway, thank you again for such important work. |
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. |
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). |
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: |
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. |
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! 👏 🎉 |
Fixed |
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!
With #109, I think we can click merge on this? |
Almost! Let's deal with #108 (comment) first. |
@hugovk now that the #108 (comment) has been fixed with #113 , can this now be merged? 😀 |
Yes, let's do it. @septatrix Thank you for all your work on this PR! And to everyone else for the feedback. |
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. |
It's now live: https://docs.python.org/dev/ |
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 |
Please see PR #128 to add the class to the theme. |
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? |
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.rst
file from the official docs as an example, though this does not use all styles which need to be changed.TODO
General areas
.refcount
and.stableabi
are 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 (
#121212
from 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.css
overwriting 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