Fix dark theme fill, theme toggle visibility and bank account creation
- The Carbon theme class is now also set on html, with a themed background and a full-height root, so the dark theme fills the whole window instead of stopping at the content height. An inline script in index.html applies the saved theme before first paint. - The header theme button gets a tooltip, inline padding and a max width so it is no longer clipped at the window edge. New Invoice also gets a labelled Dark mode toggle wired to the same handler. - A shared BankAccountModal replaces the inline editor in Settings and adds a Create bank account button under the bank selector on New Invoice, which selects the new account on save. Settings keeps one Add bank account button under the table. Bank name and account number are now required.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
export type ThemeName = "g10" | "g100";
|
||||
|
||||
const STORAGE_KEY = "voiced.theme";
|
||||
|
||||
export const normalizeTheme = (value: string | null | undefined): ThemeName => (value === "g100" ? "g100" : "g10");
|
||||
|
||||
/** The theme last applied on this machine; used before settings load so there is no light flash. */
|
||||
export function cachedTheme(): ThemeName {
|
||||
try {
|
||||
return normalizeTheme(localStorage.getItem(STORAGE_KEY));
|
||||
} catch {
|
||||
return "g10";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the Carbon theme tokens on <html> as well as on the <Theme> zone, so the page canvas, the
|
||||
* overscroll area and any window area below the content follow the chosen theme.
|
||||
* index.html runs the same class switch before React mounts.
|
||||
*/
|
||||
export function applyDocumentTheme(theme: ThemeName): void {
|
||||
const root = document.documentElement;
|
||||
root.classList.remove("cds--g10", "cds--g100");
|
||||
root.classList.add(`cds--${theme}`);
|
||||
root.dataset.carbonTheme = theme;
|
||||
try {
|
||||
localStorage.setItem(STORAGE_KEY, theme);
|
||||
} catch {
|
||||
/* storage may be blocked; the class is already applied */
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user