|
1 | 1 | "use client"; |
2 | 2 |
|
3 | 3 | import { useIframeLifecycle, useUrlManager } from "@/app/lib/hooks/useIframe"; |
| 4 | +import { useUserPreferences } from "@/app/lib/hooks/useUserPreferences"; |
4 | 5 | import { getEffectiveUrl } from "@/app/lib/utils/iframe-utils"; |
5 | 6 | import type { IframeContainerProps, IframeContainerRef, IframeUrl } from "@/app/types/iframe"; |
6 | 7 | import { Box, useMediaQuery } from "@mui/material"; |
@@ -40,6 +41,21 @@ function getGlobalIframeContainer() { |
40 | 41 | return globalIframeContainer; |
41 | 42 | } |
42 | 43 |
|
| 44 | +// Add a function to update container position based on menu position |
| 45 | +function updateGlobalContainerPosition(menuPosition: "top" | "side") { |
| 46 | + if (!globalIframeContainer) return; |
| 47 | + |
| 48 | + if (menuPosition === "top") { |
| 49 | + globalIframeContainer.style.top = "64px"; // AppBar height |
| 50 | + globalIframeContainer.style.bottom = "0"; |
| 51 | + globalIframeContainer.style.height = "auto"; |
| 52 | + } else { |
| 53 | + globalIframeContainer.style.top = "0"; |
| 54 | + globalIframeContainer.style.bottom = "0"; |
| 55 | + globalIframeContainer.style.height = "100%"; |
| 56 | + } |
| 57 | +} |
| 58 | + |
43 | 59 | // Individual iframe component |
44 | 60 | function IframeElement({ |
45 | 61 | urlData, |
@@ -199,6 +215,14 @@ const IframeContainer = forwardRef<IframeContainerRef, IframeContainerProps>( |
199 | 215 | const containerRef = useRef<HTMLDivElement>(null); |
200 | 216 | const isMobile = useMediaQuery("(max-width:600px)"); |
201 | 217 | const initialized = useRef(false); |
| 218 | + const { preferences } = useUserPreferences(); |
| 219 | + |
| 220 | + // Update container position when menu position changes |
| 221 | + useEffect(() => { |
| 222 | + if (preferences?.menuPosition) { |
| 223 | + updateGlobalContainerPosition(preferences.menuPosition); |
| 224 | + } |
| 225 | + }, [preferences?.menuPosition]); |
202 | 226 |
|
203 | 227 | // Initialize URLs on mount |
204 | 228 | useEffect(() => { |
|
0 commit comments