-
-
Notifications
You must be signed in to change notification settings - Fork 4
Dark and Light switch #78
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
Merged
JDSherbert
merged 1 commit into
VerzatileDevOrg:main
from
VerzatileDev:LightDarkSwitchOption1
Feb 8, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <nav aria-label="Auxiliary" class="aux-nav"> | ||
| <ul class="aux-nav-list"> | ||
| {% for link in site.aux_links %} | ||
| <li class="aux-nav-list-item"> | ||
| <a href="{{ link.last }}" class="site-button" | ||
| {% if site.aux_links_new_tab %} | ||
| target="_blank" rel="noopener noreferrer" | ||
| {% endif %} | ||
| > | ||
| {{ link.first }} | ||
| </a> | ||
| </li> | ||
| {% endfor %} | ||
| <li class="aux-nav-list-item"></li> | ||
| <button class="btn js-toggle-dark-mode"aria-label="Switch to dark mode">🌞</button> | ||
|
|
||
| </li> | ||
| </ul> | ||
| </nav> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| {%- comment -%} | ||
| Include as: {%- include head.html -%} | ||
| Depends on: site.ga_tracking, site.ga_tracking_anonymize_ip, | ||
| site.search_enabled, site.static_files, site.favicon_ico. | ||
| Results in: HTML for the head element. | ||
| Includes: | ||
| head_nav.html, head_custom.html. | ||
| Overwrites: | ||
| ga_tracking_ids, ga_property, file, favicon. | ||
| Should not be cached, because included files depend on page. | ||
| {%- endcomment -%} | ||
|
|
||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta http-equiv="X-UA-Compatible" content="IE=Edge"> | ||
|
|
||
| <link rel="stylesheet" href="{{ '/assets/css/just-the-docs-default.css' | relative_url }}"> | ||
|
|
||
| {% include head_nav.html %} | ||
|
|
||
| {% if site.search_enabled != false %} | ||
| <script src="{{ '/assets/js/vendor/lunr.min.js' | relative_url }}"></script> | ||
| {% endif %} | ||
|
|
||
| <script src="{{ '/assets/js/just-the-docs.js' | relative_url }}"></script> | ||
|
|
||
|
|
||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
|
||
| {% include_cached favicon.html %} | ||
|
|
||
| {% seo %} | ||
|
|
||
| {% include head_custom.html %} | ||
|
|
||
| </head> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // Get the stored theme when the page loads | ||
| document.addEventListener('DOMContentLoaded', (event) => { | ||
| const storedTheme = localStorage.getItem('theme'); | ||
| if (storedTheme) { | ||
| jtd.setTheme(storedTheme); | ||
| // Set the button icon and aria-label based on the stored theme | ||
| toggleDarkMode.textContent = storedTheme === 'dark' ? '🌞' : '🌜'; | ||
| toggleDarkMode.setAttribute('aria-label', storedTheme === 'dark' ? 'Switch to light mode' : 'Switch to dark mode'); | ||
| } | ||
| }); | ||
|
|
||
| const toggleDarkMode = document.querySelector('.js-toggle-dark-mode'); | ||
|
|
||
| // Set the initial font size | ||
| toggleDarkMode.style.fontSize = '1.5em'; | ||
|
|
||
| toggleDarkMode.addEventListener('click', function() { | ||
| if (jtd.getTheme() === 'dark') { | ||
| jtd.setTheme('light'); | ||
| toggleDarkMode.textContent = '🌜'; | ||
| toggleDarkMode.setAttribute('aria-label', 'Switch to dark mode'); | ||
| // Store the theme in localStorage | ||
| localStorage.setItem('theme', 'light'); | ||
| } else { | ||
| jtd.setTheme('dark'); | ||
| toggleDarkMode.textContent = '🌞'; | ||
| toggleDarkMode.setAttribute('aria-label', 'Switch to light mode'); | ||
| // Store the theme in localStorage | ||
| localStorage.setItem('theme', 'dark'); | ||
| } | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.