-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Add manual dark/light mode toggle to sphinx13 theme #13766
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
base: master
Are you sure you want to change the base?
Add manual dark/light mode toggle to sphinx13 theme #13766
Conversation
Hi maintainers 👋 A header toggle button LocalStorage for persistence Full CSS implementation for dark mode Kindly review and share your feedback. Would love to improve it further if needed! 😊 |
doc/_themes/sphinx13/layout.html
Outdated
const savedTheme = localStorage.getItem('theme'); | ||
if (savedTheme === 'dark') { | ||
htmlTag.classList.add('dark-mode'); | ||
toggleBtn.textContent = '☀️ Light Mode'; |
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.
☀ï
looks wrong here
doc/_themes/sphinx13/layout.html
Outdated
@@ -6,6 +6,24 @@ | |||
{%- if not embedded and pagename == root_doc %} | |||
<style>.related { display: none; }</style> | |||
{%- endif %} | |||
<script> |
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.
We should avoid inline scripts, let's move to a .js
file for better caching.
doc/_themes/sphinx13/layout.html
Outdated
d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z" | ||
></path> | ||
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16"> | ||
<path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54..."></path> |
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.
This has truncated the SVG data
tests/roots/test-root/wrongenc.inc
Outdated
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.
Please revert
I'm not a HTML/CSS/js expert, but would it make sense to add some (or all) of the functionality to the |
Thanks for the feedback! Moved the inline dark mode script to dark-mode.js as suggested Reverted the unintended change to wrongenc.inc |
Hi again! 👋 Thanks for the review — I’ve:
However, I noticed some CI checks failed. From the logs, they don’t seem related to the changes I’ve made (which only touch layout, JS, and restore a test file). Please let me know if there’s anything further you’d like me to change. 😊 |
The failures are related; you continue to have a broken SVG. Are you using an LLM to assist with this PR? A |
d7b0231
to
1e9178f
Compare
1e9178f
to
4fd6360
Compare
This PR introduces a manual dark/light mode toggle to the sphinx13 theme in the Sphinx documentation project.
✨ Features:
Added a dark/light mode toggle button to the top-right corner of the header.
Implemented dark mode styles via CSS using a dark-mode class on the .
Utilized localStorage to remember the user's theme preference across sessions.
Ensured responsiveness and accessibility for a better user experience.