From 08a6d7bd1d38e3a320addda8c94dfad5e2ad89f4 Mon Sep 17 00:00:00 2001 From: Gabriel20xx Date: Wed, 16 Sep 2026 23:39:23 +0200 Subject: [PATCH] fix: apply wide page preference instantly --- frontend/src/lib/layout.svelte.js | 23 ++++++++++++++--------- shared/packages/web-ui/src/lib/styles.css | 7 +++++++ shared/shared-styles.css | 7 +++++++ 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/frontend/src/lib/layout.svelte.js b/frontend/src/lib/layout.svelte.js index 99539d0..75e9072 100644 --- a/frontend/src/lib/layout.svelte.js +++ b/frontend/src/lib/layout.svelte.js @@ -4,7 +4,11 @@ const STORAGE_KEY = 'collabtable-wide-layout'; function loadInitialWide() { if (!browser) return false; - return localStorage.getItem(STORAGE_KEY) === 'true'; + try { + return localStorage.getItem(STORAGE_KEY) === 'true'; + } catch { + return false; + } } let wide = $state(loadInitialWide()); @@ -15,17 +19,18 @@ export const layoutState = { }, setWide(next) { wide = next; - if (browser) localStorage.setItem(STORAGE_KEY, String(next)); + if (!browser) return; + + document.documentElement.toggleAttribute('data-wide-layout', next); + try { + localStorage.setItem(STORAGE_KEY, String(next)); + } catch { + // Ignore storage failures; the current page can still use the selected layout width. + } }, toggle() { layoutState.setWide(!wide); }, }; -if (browser) { - $effect.root(() => { - $effect(() => { - document.documentElement.toggleAttribute('data-wide-layout', wide); - }); - }); -} +if (browser) document.documentElement.toggleAttribute('data-wide-layout', wide); diff --git a/shared/packages/web-ui/src/lib/styles.css b/shared/packages/web-ui/src/lib/styles.css index 45eaf82..cc7bf04 100644 --- a/shared/packages/web-ui/src/lib/styles.css +++ b/shared/packages/web-ui/src/lib/styles.css @@ -34,6 +34,13 @@ padding: 1rem 0 1rem; } +/* The page-width preference is owned by each consumer application. The shared shell only + provides the common width cap, so this global hook lets the current app widen that shell as + soon as its settings checkbox updates the document attribute. */ +html[data-wide-layout='true'] .sc-main { + width: calc(100% - 2rem); +} + .sc-header { position: sticky; z-index: 20; diff --git a/shared/shared-styles.css b/shared/shared-styles.css index bdfa980..75128d8 100644 --- a/shared/shared-styles.css +++ b/shared/shared-styles.css @@ -36,6 +36,13 @@ padding: 1rem 0 1rem; } +/* The page-width preference is owned by each consumer application. The shared shell only + provides the common width cap, so this global hook lets the current app widen that shell as + soon as its settings checkbox updates the document attribute. */ +html[data-wide-layout='true'] .sc-main { + width: calc(100% - 2rem); +} + .sc-header { position: sticky; z-index: 20;