VerzatileDevOrg / Programming_HandBook

The Programmer's Handbook is an open source initiative to collect, archive, and localize all programming knowledge in one collective space.
https://verzatiledevorg.github.io/Programming_HandBook/
MIT License
7 stars 5 forks source link

Dark and Light switch #78

Closed VerzatileDev closed 7 months ago

VerzatileDev commented 7 months ago

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.
  3. Default.html: Incorporates the local script "colorThemeSelection.js," responsible for controlling the theme button, selection, and loading.
  4. ColorThemeSelection.js: Enhances readability and functionality as described.

Issues

The following issues are as listed:

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.

VerzatileDev commented 7 months ago

References https://github.com/VerzatileDevOrg/Programming_HandBook/issues/44 as Feature [ADD] Needs to be addressed in some areas https://github.com/VerzatileDevOrg/Programming_HandBook/issues/74 [ADDRESS]