fix: Fix default theme value
This commit is contained in:
parent
17deb772cf
commit
b6244030a3
4 changed files with 7 additions and 5 deletions
|
@ -2,8 +2,8 @@ import * as params from '@params';
|
||||||
const PERSISTENCE_KEY = 'theme-scheme'
|
const PERSISTENCE_KEY = 'theme-scheme'
|
||||||
|
|
||||||
const themeOptions = params.theme || {}
|
const themeOptions = params.theme || {}
|
||||||
const THEME_DARK = typeof themeOptions.dark === 'undefined' ? false : themeOptions.dark;
|
const THEME_DARK = typeof themeOptions.dark === 'undefined' ? true : themeOptions.dark;
|
||||||
const THEME_LIGHT = typeof themeOptions.light === 'undefined' ? false : themeOptions.light;
|
const THEME_LIGHT = typeof themeOptions.light === 'undefined' ? true : themeOptions.light;
|
||||||
const THEME_DEFAULT = typeof themeOptions.default === 'undefined' ? "system" : themeOptions.default;
|
const THEME_DEFAULT = typeof themeOptions.default === 'undefined' ? "system" : themeOptions.default;
|
||||||
|
|
||||||
window.addEventListener('load', async () => {
|
window.addEventListener('load', async () => {
|
||||||
|
@ -55,7 +55,7 @@ window.addEventListener('load', async () => {
|
||||||
|
|
||||||
// save preference to local storage
|
// save preference to local storage
|
||||||
saveScheme(newScheme)
|
saveScheme(newScheme)
|
||||||
|
|
||||||
setImages(theme)
|
setImages(theme)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<!--================= add analytics if enabled =========================-->
|
<!--================= add analytics if enabled =========================-->
|
||||||
{{- partial "analytics.html" . -}}
|
{{- partial "analytics.html" . -}}
|
||||||
<script>
|
<script>
|
||||||
theme = localStorage.getItem('theme-scheme') || localStorage.getItem('darkmode:color-scheme') || 'system';
|
theme = localStorage.getItem('theme-scheme') || localStorage.getItem('darkmode:color-scheme') || 'light';
|
||||||
if (theme == 'system') {
|
if (theme == 'system') {
|
||||||
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||||
theme = 'dark';
|
theme = 'dark';
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<!--================= add analytics if enabled =========================-->
|
<!--================= add analytics if enabled =========================-->
|
||||||
{{- partial "analytics.html" . -}}
|
{{- partial "analytics.html" . -}}
|
||||||
<script>
|
<script>
|
||||||
theme = localStorage.getItem('theme-scheme') || localStorage.getItem('darkmode:color-scheme') || 'system';
|
theme = localStorage.getItem('theme-scheme') || localStorage.getItem('darkmode:color-scheme') || 'light';
|
||||||
if (theme == 'system') {
|
if (theme == 'system') {
|
||||||
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||||
theme = 'dark';
|
theme = 'dark';
|
||||||
|
|
|
@ -22,8 +22,10 @@
|
||||||
<img class="theme-icon" src="{{ "icons/moon-svgrepo-com.svg" | relURL }}" width=20 alt="Dark Theme">
|
<img class="theme-icon" src="{{ "icons/moon-svgrepo-com.svg" | relURL }}" width=20 alt="Dark Theme">
|
||||||
</a>
|
</a>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ if and $lightEnabled $darkEnabled }}
|
||||||
<a class="dropdown-item nav-link" href="#" data-scheme="system">
|
<a class="dropdown-item nav-link" href="#" data-scheme="system">
|
||||||
<img class="theme-icon" src="{{ "icons/computer-svgrepo-com.svg" | relURL }}" width=20 alt="System Theme">
|
<img class="theme-icon" src="{{ "icons/computer-svgrepo-com.svg" | relURL }}" width=20 alt="System Theme">
|
||||||
</a>
|
</a>
|
||||||
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue