hugo-toha/layouts/partials/navigators/theme-selector.html
donfiguerres 65049cfbb7
Dark theme via DarkReader (#595)
* Initial commit for dark theme.

* Use DarkReader.auto() to watch for system theme.

* Tunning default parameters.

* Allow configurable number of recent posts.

* Added invisible element to hack theme initialization.

* Added default value.

* Use Darkreader CDN.

* Cleanup to keep darkreader in as few files as possible.

* Renamed darkmode.js to darkmode-darkreader.js.

* Bring back the initialization.

* Added provider property.

* Added theme selector to the posts navbar.

* Removed extra line breaks.

* Changed darkreader CDN to local copy.

* Renamed to darkMode.

* Fixed CodeQL failures.

* Added icons.

* Renamed function.

* Added SVG inversion.

* Used icons for selection.

* Toggle initial dark only in the dynamic navbar.

Co-authored-by: donfiguerres <donfiguerres@github.com>
Co-authored-by: Emruz Hossain <hossainemruz@gmail.com>
2022-06-10 15:18:49 +00:00

20 lines
No EOL
1.1 KiB
HTML

<li class="nav-item dropdown">
<!-- This is for initializing the color scheme selection for new visitors. See /js/darkmode.js -->
<div id="theme-initialization" style="display: none;"
default-theme="{{ site.Params.darkMode.default }}"></div>
<a class="nav-link dropdown-toggle" href="#" id="themeSelector" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<img id="navbar-theme-icon-svg" src="{{ "/icons/moon-svgrepo-com.svg" }}" width=20>
</a>
<div class="dropdown-menu dropdown-menu-icons-only" aria-labelledby="themeSelector">
<a class="dropdown-item nav-link" href="#" onclick="enableLightTheme()">
<img class="menu-icon-center" src="{{ "/icons/sun-svgrepo-com.svg" }}" width=20>
</a>
<a class="dropdown-item nav-link" href="#" onclick="enableDarkTheme()">
<img class="menu-icon-center" src="{{ "/icons/moon-svgrepo-com.svg" }}" width=20>
</a>
<a class="dropdown-item nav-link" href="#" onclick="useSystemTheme()">
<img class="menu-icon-center" src="{{ "/icons/computer-svgrepo-com.svg" }}" width=20>
</a>
</div>
</li>