feature: Sidebar hiding now pure CSS & theme reloading for devs (#391)

This commit is contained in:
James Read 2024-08-26 00:47:43 +01:00 committed by GitHub
parent c9095b4d67
commit ddb803d9b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 7 additions and 8 deletions

View File

@ -87,6 +87,7 @@ type PrometheusConfig struct {
type Config struct { type Config struct {
UseSingleHTTPFrontend bool UseSingleHTTPFrontend bool
ThemeName string ThemeName string
ThemeCacheDisabled bool
ListenAddressSingleHTTPFrontend string ListenAddressSingleHTTPFrontend string
ListenAddressWebUI string ListenAddressWebUI string
ListenAddressRestActions string ListenAddressRestActions string
@ -188,6 +189,7 @@ func DefaultConfigWithBasePort(basePort int) *Config {
config.DefaultIconForActions = "😀" config.DefaultIconForActions = "😀"
config.DefaultIconForDirectories = "&#128193" config.DefaultIconForDirectories = "&#128193"
config.DefaultIconForBack = "«" config.DefaultIconForBack = "«"
config.ThemeCacheDisabled = false
config.ListenAddressSingleHTTPFrontend = fmt.Sprintf("0.0.0.0:%d", basePort) config.ListenAddressSingleHTTPFrontend = fmt.Sprintf("0.0.0.0:%d", basePort)
config.ListenAddressRestActions = fmt.Sprintf("localhost:%d", basePort+1) config.ListenAddressRestActions = fmt.Sprintf("localhost:%d", basePort+1)

View File

@ -88,7 +88,7 @@ func setupCustomWebuiDir() {
func generateThemeCss(w http.ResponseWriter, r *http.Request) { func generateThemeCss(w http.ResponseWriter, r *http.Request) {
themeCssFilename := path.Join(findCustomWebuiDir(), "themes", cfg.ThemeName, "theme.css") themeCssFilename := path.Join(findCustomWebuiDir(), "themes", cfg.ThemeName, "theme.css")
if !customThemeCssRead { if !customThemeCssRead || cfg.ThemeCacheDisabled {
customThemeCssRead = true customThemeCssRead = true
if _, err := os.Stat(themeCssFilename); err == nil { if _, err := os.Stat(themeCssFilename); err == nil {

View File

@ -170,16 +170,12 @@ function setSectionNavigationVisible (visible) {
btn.innerHTML = '«' btn.innerHTML = '«'
nav.classList.add('shown') nav.classList.add('shown')
nav.style.display = 'flex'
} else { } else {
btn.setAttribute('aria-pressed', true) btn.setAttribute('aria-pressed', true)
btn.setAttribute('aria-label', 'Close sidebar navigation') btn.setAttribute('aria-label', 'Close sidebar navigation')
btn.innerHTML = '☰' btn.innerHTML = '☰'
nav.classList.remove('shown') nav.classList.remove('shown')
setTimeout(() => {
nav.style.display = 'none'
}, 600)
} }
} else { } else {
btn.disabled = true btn.disabled = true

View File

@ -95,7 +95,6 @@ nav ul li a:hover {
} }
nav { nav {
display: none;
left: -250px; left: -250px;
} }
@ -115,14 +114,16 @@ nav.sidebar {
width: 180px; width: 180px;
height: 100dvh; height: 100dvh;
top: 0; top: 0;
transition: left 0.5s ease; transition: left 0.5s ease, visibility 0.5s ease;
box-shadow: 0 0 10px 0 #444; box-shadow: 0 0 10px 0 #444;
z-index: -1; z-index: -1;
flex-direction: column; flex-direction: column;
display: flex; display: flex;
visibility: hidden;
} }
nav.shown { nav.sidebar.shown {
visibility: visible;
left: 0; left: 0;
} }