fix(ui): move theme checkmark when theme changes in Appearance menu
The checkmark in the Appearance theme menu was rendered server-side (if user.Theme == opt.Name), so it never moved after switching themes in the browser. - Always render the check for every theme option, hidden by default, using a new themeCheckClass(name, current) helper that returns the hidden class unless the option is the active theme. - Give each theme button a data-theme attribute and add updateThemeIndicators() to web/src/theme.ts, which reads the applied theme from the body class (theme-<name>) and toggles the hidden class on each check accordingly. - Call updateThemeIndicators() from changeTheme (before the async save and on failure), initializeTheme, and loadUserTheme so the menu stays in sync with the applied theme. - Add unit test for themeCheckClass (templates/utils_test.go) and regenerate templ output.
This commit is contained in:
@@ -45,3 +45,12 @@ func TestGroupTunableSettingsEmpty(t *testing.T) {
|
||||
t.Errorf("expected empty groups, got live=%d restart=%d", len(live), len(restart))
|
||||
}
|
||||
}
|
||||
|
||||
func TestThemeCheckClass(t *testing.T) {
|
||||
if got := themeCheckClass("dracula", "dracula"); got != "" {
|
||||
t.Errorf("active theme should be visible, got %q", got)
|
||||
}
|
||||
if got := themeCheckClass("nord", "dracula"); got != " hidden" {
|
||||
t.Errorf("inactive theme should be hidden, got %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user