diff --git a/frontend/src/lib/components/AppShell.svelte b/frontend/src/lib/components/AppShell.svelte index 5210464..402bf97 100644 --- a/frontend/src/lib/components/AppShell.svelte +++ b/frontend/src/lib/components/AppShell.svelte @@ -27,17 +27,32 @@ const RAIL = { min: 176, max: 480, key: 'rail-width', def: 240 }; const PANEL = { min: 220, max: 560, key: 'panel-width', def: 288 }; + // Ширина разделителя (w-1) между панелью и содержимым. + const HANDLE_PX = 4; let railWidth = $state(RAIL.def); let panelWidth = $state(PANEL.def); let isFullscreen = $state(false); + let isWide = $state(false); + let isExtraWide = $state(false); + + // Ширина, которую занимают панели в текущей раскладке: рейл и панель + // встают рядом с содержимым на широких экранах, на узких — поверх него. + const reserved = $derived( + (isWide ? railWidth + HANDLE_PX : 0) + + (isExtraWide && panel && panelVisible ? panelWidth + HANDLE_PX : 0) + ); $effect(() => { // Режим скрытия действует только там, где он доступен (просмотр альбома). if (!panelsToggle) panels.reset(); }); + $effect(() => { + panels.reserved = reserved; + }); + onMount(() => { const r = parseInt(localStorage.getItem(RAIL.key) ?? '', 10); if (r >= RAIL.min && r <= RAIL.max) railWidth = r; @@ -47,7 +62,22 @@ const onFs = () => (isFullscreen = !!document.fullscreenElement); document.addEventListener('fullscreenchange', onFs); onFs(); - return () => document.removeEventListener('fullscreenchange', onFs); + + const mqLg = window.matchMedia('(min-width: 1024px)'); + const mqXl = window.matchMedia('(min-width: 1280px)'); + const sync = () => { + isWide = mqLg.matches; + isExtraWide = mqXl.matches; + }; + sync(); + mqLg.addEventListener('change', sync); + mqXl.addEventListener('change', sync); + + return () => { + document.removeEventListener('fullscreenchange', onFs); + mqLg.removeEventListener('change', sync); + mqXl.removeEventListener('change', sync); + }; }); async function toggleFullscreen() { diff --git a/frontend/src/lib/components/PhotoGrid.svelte b/frontend/src/lib/components/PhotoGrid.svelte index 9b49089..62d743d 100644 --- a/frontend/src/lib/components/PhotoGrid.svelte +++ b/frontend/src/lib/components/PhotoGrid.svelte @@ -1,6 +1,6 @@