mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-15 11:20:36 +08:00
Load theme in top-level App.svelte
Previously the theme was only loaded when the <ThemeSettings> component was loaded in the footer. This stopped working since we removed the layout around the loading spinner.
This commit is contained in:
+18
-16
@@ -6,20 +6,6 @@ export const theme = writable<Theme>(loadTheme());
|
||||
export type CodeFont = "jetbrains" | "system";
|
||||
export const codeFont = writable<CodeFont>(loadCodeFont());
|
||||
|
||||
export function storeCodeFont(codeFont: CodeFont): void {
|
||||
window.localStorage.setItem("codefont", codeFont);
|
||||
}
|
||||
|
||||
function loadCodeFont(): CodeFont {
|
||||
const storedCodeFont = window.localStorage.getItem("codefont");
|
||||
|
||||
if (storedCodeFont === null) {
|
||||
return "jetbrains";
|
||||
} else {
|
||||
return storedCodeFont as CodeFont;
|
||||
}
|
||||
}
|
||||
|
||||
export const codeFonts: {
|
||||
storedName: CodeFont;
|
||||
fontFamily: string;
|
||||
@@ -33,6 +19,16 @@ export const codeFonts: {
|
||||
{ storedName: "system", fontFamily: "monospace", displayName: "System" },
|
||||
];
|
||||
|
||||
function loadCodeFont(): CodeFont {
|
||||
const storedCodeFont = window.localStorage.getItem("codefont");
|
||||
|
||||
if (storedCodeFont === null) {
|
||||
return "jetbrains";
|
||||
} else {
|
||||
return storedCodeFont as CodeFont;
|
||||
}
|
||||
}
|
||||
|
||||
function loadTheme(): Theme {
|
||||
const storedTheme = window.localStorage.getItem("theme");
|
||||
|
||||
@@ -43,6 +39,12 @@ function loadTheme(): Theme {
|
||||
}
|
||||
}
|
||||
|
||||
export function storeTheme(theme: Theme): void {
|
||||
window.localStorage.setItem("theme", theme);
|
||||
export function storeTheme(newTheme: Theme): void {
|
||||
theme.set(newTheme);
|
||||
window.localStorage.setItem("theme", newTheme);
|
||||
}
|
||||
|
||||
export function storeCodeFont(newCodeFont: CodeFont): void {
|
||||
codeFont.set(newCodeFont);
|
||||
window.localStorage.setItem("codefont", newCodeFont);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user