new ui font

This commit is contained in:
2025-12-30 21:12:14 +00:00
parent ba7de85d65
commit b919c22cd7
4 changed files with 36 additions and 20 deletions

View File

@@ -1,19 +0,0 @@
import type {CookieRef} from "#app";
export function ui_color_cookie(): CookieRef<string> {
const c = useCookie("ui_color",{
default: () => "green",
});
watch(c, (newVal, oldVal) => {
// remove old class (if it's been put)
if (oldVal != undefined) document.body.classList.remove("ui-" + oldVal);
// add new class
document.body.classList.add("ui-" + newVal);
}, { immediate: true})
return c;
}

View File

@@ -0,0 +1,22 @@
import type {CookieRef} from "#app";
function ui_cookie(name:string, def:string,prefix:string): CookieRef<string> {
const c = useCookie(name,{
default: () => def,
});
watch(c, (newVal, oldVal) => {
// remove old class (if it's been put)
if (oldVal != undefined) document.body.classList.remove(prefix + oldVal.toLowerCase());
// add new class
document.body.classList.add(prefix + newVal.toLowerCase());
}, { immediate: true})
return c;
}
export function ui_color_cookie() { return ui_cookie("ui_color","green","ui-"); }
export function ui_font_cookie() { return ui_cookie("ui_font","pubsans","font-"); }