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 {
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 = "&#128193"
config.DefaultIconForBack = "«"
config.ThemeCacheDisabled = false
config.ListenAddressSingleHTTPFrontend = fmt.Sprintf("0.0.0.0:%d", basePort)
config.ListenAddressRestActions = fmt.Sprintf("localhost:%d", basePort+1)

View File

@ -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 {

View File

@ -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

View File

@ -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;
}