mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 18:20:30 +08:00
Organise files more consistently
Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { writable } from "svelte/store";
|
||||
|
||||
export type Theme = "dark" | "light";
|
||||
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;
|
||||
displayName: string;
|
||||
}[] = [
|
||||
{
|
||||
storedName: "jetbrains",
|
||||
fontFamily: "JetBrains Mono",
|
||||
displayName: "JetBrains Mono",
|
||||
},
|
||||
{ storedName: "system", fontFamily: "monospace", displayName: "System" },
|
||||
];
|
||||
|
||||
function loadTheme(): Theme {
|
||||
const storedTheme = window.localStorage.getItem("theme");
|
||||
|
||||
if (storedTheme === null) {
|
||||
return "dark";
|
||||
} else {
|
||||
return storedTheme as Theme;
|
||||
}
|
||||
}
|
||||
|
||||
export function storeTheme(theme: Theme): void {
|
||||
window.localStorage.setItem("theme", theme);
|
||||
}
|
||||
Reference in New Issue
Block a user