From 6657eb7e25d99ff8d41ffd24abd3e7635ba0580b Mon Sep 17 00:00:00 2001 From: Richard Ward Date: Tue, 30 Dec 2025 17:52:52 +0000 Subject: [PATCH] code: tsx,nextjs,frontends (7 files) --- .../ui/organisms/navigation/Navigation.tsx | 39 ++++++--- .../navigation/NavigationMenuItems.tsx | 83 +++++-------------- .../navigation/NavigationResponsive.tsx | 10 +-- .../navigation/NavigationStyling.tsx | 14 ++-- .../ui/organisms/navigation/Sidebar.tsx | 41 ++++----- .../organisms/navigation/Sidebar/Header.tsx | 13 +-- .../navigation/Sidebar/NavSections.tsx | 17 ++-- 7 files changed, 82 insertions(+), 135 deletions(-) diff --git a/frontends/nextjs/src/components/ui/organisms/navigation/Navigation.tsx b/frontends/nextjs/src/components/ui/organisms/navigation/Navigation.tsx index 4b1de71a5..e24105bc5 100644 --- a/frontends/nextjs/src/components/ui/organisms/navigation/Navigation.tsx +++ b/frontends/nextjs/src/components/ui/organisms/navigation/Navigation.tsx @@ -1,7 +1,7 @@ 'use client' -import { AppBar, Slide, Toolbar, useScrollTrigger } from '@mui/material' -import { forwardRef, ReactNode } from 'react' +import { AppBar, Toolbar, Slide } from '@/fakemui' +import { forwardRef, ReactNode, useEffect, useState } from 'react' import { NavigationContent, @@ -13,6 +13,7 @@ import { } from './NavigationMenuItems' import { NavigationMobileToggle } from './NavigationResponsive' import { NavigationBrand, NavigationSeparator, NavigationSpacer } from './NavigationStyling' +import styles from './Navigation.module.scss' interface NavigationProps { children: ReactNode @@ -22,6 +23,29 @@ interface NavigationProps { hideOnScroll?: boolean } +/** + * Custom hook to detect scroll direction for hide-on-scroll behavior + */ +const useScrollTrigger = (): boolean => { + const [trigger, setTrigger] = useState(false) + + useEffect(() => { + let lastScrollY = window.scrollY + const threshold = 100 + + const handleScroll = () => { + const currentScrollY = window.scrollY + setTrigger(currentScrollY > threshold && currentScrollY > lastScrollY) + lastScrollY = currentScrollY + } + + window.addEventListener('scroll', handleScroll, { passive: true }) + return () => window.removeEventListener('scroll', handleScroll) + }, []) + + return trigger +} + const Navigation = forwardRef( ( { @@ -41,21 +65,16 @@ const Navigation = forwardRef( ref={ref} position={position} color={color} - elevation={elevation} - sx={{ - bgcolor: 'background.paper', - borderBottom: 1, - borderColor: 'divider', - }} + className={styles.appBar} {...props} > - {children} + {children} ) if (hideOnScroll) { return ( - + {appBar} ) diff --git a/frontends/nextjs/src/components/ui/organisms/navigation/NavigationMenuItems.tsx b/frontends/nextjs/src/components/ui/organisms/navigation/NavigationMenuItems.tsx index 74c280081..cbb93645e 100644 --- a/frontends/nextjs/src/components/ui/organisms/navigation/NavigationMenuItems.tsx +++ b/frontends/nextjs/src/components/ui/organisms/navigation/NavigationMenuItems.tsx @@ -1,6 +1,7 @@ import { ExpandMore as ExpandMoreIcon } from '@/fakemui/icons' -import { Box, Button, ListItemIcon, ListItemText, Menu, MenuItem } from '@mui/material' +import { Box, Button, Menu, MenuItem, ListItemIcon, ListItemText } from '@/fakemui' import { ElementType, forwardRef, type MouseEvent, ReactNode } from 'react' +import styles from './Navigation.module.scss' interface NavigationMenuProps { children: ReactNode @@ -12,11 +13,7 @@ const NavigationMenu = forwardRef( {children} @@ -36,14 +33,7 @@ const NavigationList = forwardRef( {children} @@ -60,7 +50,7 @@ interface NavigationItemProps { const NavigationItem = forwardRef( ({ children, ...props }, ref) => { return ( - + {children} ) @@ -80,16 +70,9 @@ const NavigationTrigger = forwardRef(