🪇 Implements major structure and service refactors

This commit is contained in:
Rune Harlyk
2024-08-19 20:13:57 +02:00
committed by Rune Harlyk
parent 9978918bf9
commit 3da1717341
23 changed files with 139 additions and 121 deletions
+4
View File
@@ -0,0 +1,4 @@
export const daisyColor = (name: string, opacity: number = 100) => {
const color = getComputedStyle(document.documentElement).getPropertyValue(name);
return `oklch(${color} / ${opacity}%)`;
};
+3
View File
@@ -5,3 +5,6 @@ export * from './math-utilities';
export * from './buffer-utilities';
export * from './model-utilities';
export * from './location-utilities';
export * from './position-utilities';
export * from './string-utilities';
export * from './color-utilities';
+6 -6
View File
@@ -3,14 +3,14 @@ import { browser } from '$app/environment';
export const isEmbeddedApp = import.meta.env.VITE_EMBEDDED_BUILD === 'true';
export const persistentStore = (key: string, initialValue: any) => {
const savedValue = browser ? JSON.parse(localStorage.getItem(key) as string) : null;
const data = savedValue !== null ? savedValue : initialValue;
const store = writable(data);
export const persistentStore = <T>(key: string, initialValue: T) => {
const savedValue = browser ? localStorage.getItem(key) : null;
const data: T = savedValue !== null ? JSON.parse(savedValue) : initialValue;
const store = writable<T>(data);
store.subscribe((value) => {
browser && localStorage.setItem(key, JSON.stringify(value));
if (browser) localStorage.setItem(key, JSON.stringify(value));
});
return store;
};
};