Commit ea2c704
authored
Dark and Light switch (#78)
The current modification implements local storage for the selected theme
using an event listener. This ensures that the chosen theme persists
even when users leave and return to the site. By default, the website
adopts a white theme, but users can change it. The selected theme should
remain fixed upon subsequent visits.
For the theme selection, I've utilized default Windows emojis for the
Sun and moon icons, enhancing the visual appeal. Notably, I've
maintained a visible border on the icon to signify its selectability.
There don't seem to be any performance issues, but there's a minor
inconvenience where the page initially loads with a white theme before
flickering to the selected theme. This may be more noticeable on slower
internet connections, potentially revealing the behind-the-scenes of the
website. Whether this is a significant issue is open to discussion.
Key changes can be found in the following files:
1. config: Sets the default color scheme.
2. Aux_nav: Adds a new navigation list item to the top-right panel,
labeled "Contribute to.."
3 Head.html: Modifies stylesheets and introduces a script for the
default "just the docs" theme.js, essentially fixing it to the original
code.
4. Default.html: Incorporates the local script "colorThemeSelection.js,"
responsible for controlling the theme button, selection, and loading.
5. ColorThemeSelection.js: Enhances readability and functionality as
described.
Issues
---
The following issues are as listed:
- Theme by default is forced to be " light " themed, which means that
upon page change it has to be overwritten which introduces flickering to
the website when it is changed.
- May have issues on very slow internet where the user could see the
backsite, but shouldn't be too worried about it performance seem to be
valid for the site still.
Fixes
---
It would be possible to force load stylesheets globally so that the
theme changes it for the entire site, but it has underlying issues with
the way ruby website is setup and might need internal code changes.5 files changed
Lines changed: 92 additions & 2 deletions
File tree
- _includes/components
- _layouts
- assets/js
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
| |||
61 | 60 | | |
62 | 61 | | |
63 | 62 | | |
| 63 | + | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
0 commit comments