agent: layout — wire preferences store to layout, replace class-based theme toggle
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -6,11 +6,14 @@
|
|||||||
import TaskSidebar from "$lib/components/TaskSidebar.svelte";
|
import TaskSidebar from "$lib/components/TaskSidebar.svelte";
|
||||||
import Titlebar from "$lib/components/Titlebar.svelte";
|
import Titlebar from "$lib/components/Titlebar.svelte";
|
||||||
import { page, settings, saveSettings } from "$lib/stores/page.svelte.js";
|
import { page, settings, saveSettings } from "$lib/stores/page.svelte.js";
|
||||||
|
import { getPreferences, updatePreferences } from "$lib/stores/preferences.svelte.js";
|
||||||
|
|
||||||
import { page as sveltePage } from "$app/stores";
|
import { page as sveltePage } from "$app/stores";
|
||||||
|
|
||||||
let { children } = $props();
|
let { children } = $props();
|
||||||
|
|
||||||
|
const prefs = getPreferences();
|
||||||
|
|
||||||
// Detect secondary windows (float, viewer) — they use +layout@.svelte
|
// Detect secondary windows (float, viewer) — they use +layout@.svelte
|
||||||
// but as a fallback, hide chrome if the URL matches
|
// but as a fallback, hide chrome if the URL matches
|
||||||
let isSecondaryWindow = $derived(
|
let isSecondaryWindow = $derived(
|
||||||
@@ -27,23 +30,15 @@
|
|||||||
mouseY = e.clientY;
|
mouseY = e.clientY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Theme application
|
// Theme — migrate from old class-based to new data-attribute system
|
||||||
|
// The preferences store handles DOM application via data-theme attribute
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
const theme = settings.theme;
|
// Sync legacy settings.theme → preferences store
|
||||||
if (theme === "Light") {
|
const legacyTheme = settings.theme;
|
||||||
document.documentElement.classList.add("light");
|
const mapped = legacyTheme === "Light" ? "light" : legacyTheme === "Dark" ? "dark" : "system";
|
||||||
return;
|
if (prefs.theme !== mapped) {
|
||||||
|
updatePreferences({ theme: mapped });
|
||||||
}
|
}
|
||||||
if (theme === "Dark") {
|
|
||||||
document.documentElement.classList.remove("light");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// System mode
|
|
||||||
const mq = window.matchMedia("(prefers-color-scheme: light)");
|
|
||||||
const apply = () => document.documentElement.classList.toggle("light", mq.matches);
|
|
||||||
apply();
|
|
||||||
mq.addEventListener("change", apply);
|
|
||||||
return () => mq.removeEventListener("change", apply);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Global hotkey registration
|
// Global hotkey registration
|
||||||
@@ -71,7 +66,7 @@
|
|||||||
registerGlobalHotkey(settings.globalHotkey);
|
registerGlobalHotkey(settings.globalHotkey);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Apply font size setting as CSS variable
|
// Apply font size setting as CSS variable (legacy — kept for backwards compat)
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
document.documentElement.style.setProperty("--font-size-transcript", `${settings.fontSize}px`);
|
document.documentElement.style.setProperty("--font-size-transcript", `${settings.fontSize}px`);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user