From 8d625156df084209194bde25e604a389635ef5e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nicole=20miko=C5=82ajczyk?= Date: Mon, 2 Mar 2026 20:54:43 +0100 Subject: [PATCH] nicolium: revert change that didn't really have impact on performance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nicole mikołajczyk --- .../nicolium/src/components/ui/layout.tsx | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/packages/nicolium/src/components/ui/layout.tsx b/packages/nicolium/src/components/ui/layout.tsx index 3eb99fa96..0f8c6964d 100644 --- a/packages/nicolium/src/components/ui/layout.tsx +++ b/packages/nicolium/src/components/ui/layout.tsx @@ -65,6 +65,26 @@ declare global { } } +const useWindowControlsOverlay = () => { + const getRect = (): DOMRect | null => { + const overlay = navigator.windowControlsOverlay; + return overlay?.visible ? overlay.getTitlebarAreaRect() : null; + }; + + const [rect, setRect] = useState(getRect); + + useEffect(() => { + const overlay = navigator.windowControlsOverlay; + if (!overlay) return; + + const update = () => setRect(overlay.visible ? overlay.getTitlebarAreaRect() : null); + overlay.addEventListener('geometrychange', update); + return () => overlay.removeEventListener('geometrychange', update); + }, []); + + return rect; +}; + /** Layout container, to hold Sidebar, Main, and Aside. */ const Layout: LayoutComponent = ({ children, fullWidth }) => (
@@ -81,6 +101,8 @@ const Layout: LayoutComponent = ({ children, fullWidth }) => ( /** Left sidebar container in the UI. */ const Sidebar: React.FC = ({ children, shrink }) => { const isVisible = useMinWidth(`(min-width: ${breakpoints.lg})`); + const wcoRect = useWindowControlsOverlay(); + const offsetTop = wcoRect && wcoRect.x > 0 ? 16 + wcoRect.y : 16; if (!isVisible) { return null; @@ -88,7 +110,7 @@ const Sidebar: React.FC = ({ children, shrink }) => { return (
- + {children}
@@ -117,13 +139,17 @@ const Main: React.FC> = ({ children, classN /** Right sidebar container in the UI. */ const Aside: React.FC = ({ children }) => { const isVisible = useMinWidth(`(min-width: ${breakpoints.xl})`); + const wcoRect = useWindowControlsOverlay(); + const offsetTop = + wcoRect && wcoRect.x + wcoRect.width < window.innerWidth ? 16 + wcoRect.height : 16; + if (!isVisible) { return null; } return (