From f73d066bab02b098588a6f013b197b48b3fed95d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nicole=20miko=C5=82ajczyk?= Date: Sat, 21 Feb 2026 23:38:02 +0100 Subject: [PATCH] nicolium: do not render parts of ui hidden behind breakpoints (fixes announcements display) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nicole mikołajczyk --- packages/pl-fe/src/components/ui/layout.tsx | 77 +++++++++++++++++---- 1 file changed, 62 insertions(+), 15 deletions(-) diff --git a/packages/pl-fe/src/components/ui/layout.tsx b/packages/pl-fe/src/components/ui/layout.tsx index 9067af77f..c1c4b22a3 100644 --- a/packages/pl-fe/src/components/ui/layout.tsx +++ b/packages/pl-fe/src/components/ui/layout.tsx @@ -1,9 +1,16 @@ import clsx from 'clsx'; -import React, { Suspense } from 'react'; +import React, { Suspense, useEffect, useState } from 'react'; import StickyBox from 'react-sticky-box'; import { useFeatures } from '@/hooks/use-features'; +import tailwindConfig from '../../../tailwind.config'; + +const breakpoints = (tailwindConfig.theme?.screens as Record) ?? { + lg: '976px', + xl: '1280px', +}; + interface ISidebar { children: React.ReactNode; shrink?: boolean; @@ -23,6 +30,30 @@ interface LayoutComponent extends React.FC { Aside: React.FC; } +const useMinWidth = (query: string) => { + const getMatch = () => (typeof window !== 'undefined' ? window.matchMedia(query).matches : false); + + const [matches, setMatches] = useState(getMatch); + + useEffect(() => { + const mediaQuery = window.matchMedia(query); + + setMatches(mediaQuery.matches); + + const onChange = (event: MediaQueryListEvent) => { + setMatches(event.matches); + }; + + mediaQuery.addEventListener('change', onChange); + + return () => { + mediaQuery.removeEventListener('change', onChange); + }; + }, [query]); + + return matches; +}; + /** Layout container, to hold Sidebar, Main, and Aside. */ const Layout: LayoutComponent = ({ children, fullWidth }) => (
@@ -37,13 +68,21 @@ const Layout: LayoutComponent = ({ children, fullWidth }) => ( ); /** Left sidebar container in the UI. */ -const Sidebar: React.FC = ({ children, shrink }) => ( -
- - {children} - -
-); +const Sidebar: React.FC = ({ children, shrink }) => { + const isVisible = useMinWidth(`(min-width: ${breakpoints.lg})`); + + if (!isVisible) { + return null; + } + + return ( +
+ + {children} + +
+ ); +}; /** Center column container in the UI. */ const Main: React.FC> = ({ children, className }) => { @@ -65,13 +104,21 @@ const Main: React.FC> = ({ children, classN }; /** Right sidebar container in the UI. */ -const Aside: React.FC = ({ children }) => ( - -); +const Aside: React.FC = ({ children }) => { + const isVisible = useMinWidth(`(min-width: ${breakpoints.xl})`); + + if (!isVisible) { + return null; + } + + return ( + + ); +}; Layout.Sidebar = Sidebar; Layout.Main = Main;