fix: some svelte 5 issues

This commit is contained in:
2024-12-19 15:35:22 +01:00
parent 5c1c8c480b
commit 53f400a4f6
10 changed files with 1583 additions and 1156 deletions

View File

@@ -1,5 +1,5 @@
import { appSettings } from "$lib/settings/app-settings.svelte";
import { Color } from "three";
import { Color, LinearSRGBColorSpace } from "three";
const variables = [
"layer-0",
@@ -15,7 +15,7 @@ const variables = [
function getColor(variable: typeof variables[number]) {
const style = getComputedStyle(document.body.parentElement!);
let color = style.getPropertyValue(`--${variable}`);
return new Color().setStyle(color);
return new Color().setStyle(color, LinearSRGBColorSpace);
}
export const colors = Object.fromEntries(variables.map(v => [v, getColor(v)])) as Record<typeof variables[number], Color>;
@@ -25,7 +25,8 @@ $effect.root(() => {
if (!appSettings.theme || !("getComputedStyle" in globalThis)) return;
const style = getComputedStyle(document.body.parentElement!);
for (const v of variables) {
colors[v].setStyle(style.getPropertyValue(`--${v}`));
const hex = style.getPropertyValue(`--${v}`);
colors[v].setStyle(hex, LinearSRGBColorSpace);
}
});
})