From ddb803d9b561782723fb016f65cc5faaf2c1ab51 Mon Sep 17 00:00:00 2001 From: James Read Date: Mon, 26 Aug 2024 00:47:43 +0100 Subject: [PATCH] feature: Sidebar hiding now pure CSS & theme reloading for devs (#391) --- internal/config/config.go | 2 ++ internal/httpservers/webuiServer.go | 2 +- webui.dev/js/marshaller.js | 4 ---- webui.dev/style.css | 7 ++++--- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index 7af7e12..a2bd1ea 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -87,6 +87,7 @@ type PrometheusConfig struct { type Config struct { UseSingleHTTPFrontend bool ThemeName string + ThemeCacheDisabled bool ListenAddressSingleHTTPFrontend string ListenAddressWebUI string ListenAddressRestActions string @@ -188,6 +189,7 @@ func DefaultConfigWithBasePort(basePort int) *Config { config.DefaultIconForActions = "😀" config.DefaultIconForDirectories = "📁" config.DefaultIconForBack = "«" + config.ThemeCacheDisabled = false config.ListenAddressSingleHTTPFrontend = fmt.Sprintf("0.0.0.0:%d", basePort) config.ListenAddressRestActions = fmt.Sprintf("localhost:%d", basePort+1) diff --git a/internal/httpservers/webuiServer.go b/internal/httpservers/webuiServer.go index a9c73e8..7ed8844 100644 --- a/internal/httpservers/webuiServer.go +++ b/internal/httpservers/webuiServer.go @@ -88,7 +88,7 @@ func setupCustomWebuiDir() { func generateThemeCss(w http.ResponseWriter, r *http.Request) { themeCssFilename := path.Join(findCustomWebuiDir(), "themes", cfg.ThemeName, "theme.css") - if !customThemeCssRead { + if !customThemeCssRead || cfg.ThemeCacheDisabled { customThemeCssRead = true if _, err := os.Stat(themeCssFilename); err == nil { diff --git a/webui.dev/js/marshaller.js b/webui.dev/js/marshaller.js index 8bbf017..17dc7ae 100644 --- a/webui.dev/js/marshaller.js +++ b/webui.dev/js/marshaller.js @@ -170,16 +170,12 @@ function setSectionNavigationVisible (visible) { btn.innerHTML = '«' nav.classList.add('shown') - nav.style.display = 'flex' } else { btn.setAttribute('aria-pressed', true) btn.setAttribute('aria-label', 'Close sidebar navigation') btn.innerHTML = '☰' nav.classList.remove('shown') - setTimeout(() => { - nav.style.display = 'none' - }, 600) } } else { btn.disabled = true diff --git a/webui.dev/style.css b/webui.dev/style.css index 67c6276..47e6f5a 100644 --- a/webui.dev/style.css +++ b/webui.dev/style.css @@ -95,7 +95,6 @@ nav ul li a:hover { } nav { - display: none; left: -250px; } @@ -115,14 +114,16 @@ nav.sidebar { width: 180px; height: 100dvh; top: 0; - transition: left 0.5s ease; + transition: left 0.5s ease, visibility 0.5s ease; box-shadow: 0 0 10px 0 #444; z-index: -1; flex-direction: column; display: flex; + visibility: hidden; } -nav.shown { +nav.sidebar.shown { + visibility: visible; left: 0; }