Fix error when hide-desktop-navigation is true

This commit is contained in:
Svilen Markov 2025-05-13 20:35:34 +01:00
parent 9de6843a2e
commit 95702a2e53
2 changed files with 14 additions and 10 deletions

View File

@ -689,9 +689,13 @@ async function changeTheme(key, onChanged) {
} }
function initThemeSwitcher() { function initThemeSwitcher() {
find(".mobile-navigation .theme-choices").replaceWith( const themeChoicesInHeader = find(".header-container .theme-choices");
find(".header-container .theme-choices").cloneNode(true)
if (themeChoicesInHeader) {
themeChoicesInHeader.replaceWith(
find(".mobile-navigation .theme-choices").cloneNode(true)
); );
}
const presetElems = findAll(".theme-choices .theme-preset"); const presetElems = findAll(".theme-choices .theme-preset");
let themePreviewElems = document.getElementsByClassName("current-theme-preview"); let themePreviewElems = document.getElementsByClassName("current-theme-preview");

View File

@ -38,12 +38,7 @@
{{ .Request.Theme.PreviewHTML }} {{ .Request.Theme.PreviewHTML }}
</div> </div>
<div data-popover-html> <div data-popover-html>
<div class="theme-choices"> <div class="theme-choices"></div>
{{ .App.Config.Theme.PreviewHTML }}
{{ range $_, $preset := .App.Config.Theme.Presets.Items }}
{{ $preset.PreviewHTML }}
{{ end }}
</div>
</div> </div>
</div> </div>
{{- if .App.RequiresAuth }} {{- if .App.RequiresAuth }}
@ -73,7 +68,12 @@
<div class="mobile-navigation-actions flex flex-column margin-block-10"> <div class="mobile-navigation-actions flex flex-column margin-block-10">
<div class="theme-picker flex justify-between items-center" data-popover-type="html" data-popover-position="above" data-popover-show-delay="0" data-popover-hide-delay="100" data-popover-anchor=".current-theme-preview" data-popover-trigger="click"> <div class="theme-picker flex justify-between items-center" data-popover-type="html" data-popover-position="above" data-popover-show-delay="0" data-popover-hide-delay="100" data-popover-anchor=".current-theme-preview" data-popover-trigger="click">
<div data-popover-html> <div data-popover-html>
<div class="theme-choices"></div> <div class="theme-choices">
{{ .App.Config.Theme.PreviewHTML }}
{{ range $_, $preset := .App.Config.Theme.Presets.Items }}
{{ $preset.PreviewHTML }}
{{ end }}
</div>
</div> </div>
<div class="size-h3 pointer-events-none select-none">Change theme</div> <div class="size-h3 pointer-events-none select-none">Change theme</div>