From 8ab2e225ed8ffb3779aed56da97bbae70e3050ee Mon Sep 17 00:00:00 2001 From: Richard Ward Date: Tue, 30 Dec 2025 18:05:59 +0000 Subject: [PATCH] code: tsx,nextjs,frontends (4 files) --- .../ui/molecules/navigation/Breadcrumb.tsx | 62 ++++----- .../ui/molecules/navigation/NavGroup.tsx | 84 +++++------- .../ui/molecules/navigation/NavItem.tsx | 126 +++++++----------- .../ui/molecules/navigation/NavLink.tsx | 61 +++------ 4 files changed, 136 insertions(+), 197 deletions(-) diff --git a/frontends/nextjs/src/components/ui/molecules/navigation/Breadcrumb.tsx b/frontends/nextjs/src/components/ui/molecules/navigation/Breadcrumb.tsx index 98f6680b3..87e16b86c 100644 --- a/frontends/nextjs/src/components/ui/molecules/navigation/Breadcrumb.tsx +++ b/frontends/nextjs/src/components/ui/molecules/navigation/Breadcrumb.tsx @@ -1,27 +1,32 @@ 'use client' -import { Box, Breadcrumbs as MuiBreadcrumbs, Link, Typography } from '@mui/material' +import { Box, Breadcrumbs, Link, Typography } from '@/fakemui' import { forwardRef, ReactNode } from 'react' import { MoreHoriz, NavigateNext } from '@/fakemui/icons' +import styles from './Breadcrumb.module.scss' + interface BreadcrumbProps { children: ReactNode className?: string } -const Breadcrumb = forwardRef(({ children, ...props }, ref) => { - return ( - } - aria-label="breadcrumb" - {...props} - > - {children} - - ) -}) +const Breadcrumb = forwardRef( + ({ children, className = '', ...props }, ref) => { + return ( + } + className={`${styles.breadcrumbs} ${className}`} + aria-label="breadcrumb" + {...props} + > + {children} + + ) + } +) Breadcrumb.displayName = 'Breadcrumb' interface BreadcrumbListProps { @@ -30,7 +35,7 @@ interface BreadcrumbListProps { } const BreadcrumbList = forwardRef( - ({ children, ...props }, ref) => { + ({ children, className = '', ...props }, ref) => { return <>{children} } ) @@ -42,9 +47,9 @@ interface BreadcrumbItemProps { } const BreadcrumbItem = forwardRef( - ({ children, ...props }, ref) => { + ({ children, className = '', ...props }, ref) => { return ( - + {children} ) @@ -60,14 +65,14 @@ interface BreadcrumbLinkProps { } const BreadcrumbLink = forwardRef( - ({ children, href, ...props }, ref) => { + ({ children, href, className = '', ...props }, ref) => { return ( {children} @@ -83,12 +88,11 @@ interface BreadcrumbPageProps { } const BreadcrumbPage = forwardRef( - ({ children, ...props }, ref) => { + ({ children, className = '', ...props }, ref) => { return ( {children} @@ -103,10 +107,10 @@ interface BreadcrumbSeparatorProps { className?: string } -const BreadcrumbSeparator = ({ children, ...props }: BreadcrumbSeparatorProps) => { +const BreadcrumbSeparator = ({ children, className = '', ...props }: BreadcrumbSeparatorProps) => { return ( - - {children || } + + {children || } ) } @@ -116,13 +120,11 @@ interface BreadcrumbEllipsisProps { className?: string } -const BreadcrumbEllipsis = ({ ...props }: BreadcrumbEllipsisProps) => { +const BreadcrumbEllipsis = ({ className = '', ...props }: BreadcrumbEllipsisProps) => { return ( - - - - More - + + + More ) } diff --git a/frontends/nextjs/src/components/ui/molecules/navigation/NavGroup.tsx b/frontends/nextjs/src/components/ui/molecules/navigation/NavGroup.tsx index 5f313ccdb..1b616cbde 100644 --- a/frontends/nextjs/src/components/ui/molecules/navigation/NavGroup.tsx +++ b/frontends/nextjs/src/components/ui/molecules/navigation/NavGroup.tsx @@ -1,19 +1,12 @@ 'use client' -import { - Box, - Collapse, - Divider, - List, - ListItem, - ListItemButton, - ListItemIcon, - ListItemText, -} from '@mui/material' +import { Box, Collapse, Divider, List, ListItem, ListItemIcon, ListItemText } from '@/fakemui' import { forwardRef, ReactNode, useState } from 'react' import { ExpandLess, ExpandMore } from '@/fakemui/icons' +import styles from './NavGroup.module.scss' + export interface NavGroupProps { label: string icon?: ReactNode @@ -26,7 +19,7 @@ export interface NavGroupProps { const NavGroup = forwardRef( ( - { label, icon, children, defaultOpen = false, disabled = false, divider = false, ...props }, + { label, icon, children, defaultOpen = false, disabled = false, divider = false, className = '', ...props }, ref ) => { const [open, setOpen] = useState(defaultOpen) @@ -37,51 +30,44 @@ const NavGroup = forwardRef( } } + const buttonClasses = [styles.groupButton, disabled && styles.groupButtonDisabled] + .filter(Boolean) + .join(' ') + + const collapseClasses = [styles.collapse, open && styles.collapseOpen].filter(Boolean).join(' ') + + const childListClasses = [ + styles.childList, + icon ? styles.childListWithIcon : styles.childListNoIcon, + ] + .filter(Boolean) + .join(' ') + return ( - - {divider && } - - + {divider && } + + - - - {children} - + + {children} ) diff --git a/frontends/nextjs/src/components/ui/molecules/navigation/NavItem.tsx b/frontends/nextjs/src/components/ui/molecules/navigation/NavItem.tsx index a7218e012..7c322d9be 100644 --- a/frontends/nextjs/src/components/ui/molecules/navigation/NavItem.tsx +++ b/frontends/nextjs/src/components/ui/molecules/navigation/NavItem.tsx @@ -1,17 +1,11 @@ 'use client' -import { - Badge, - Box, - ListItem, - ListItemButton, - ListItemIcon, - ListItemText, - type ListItemProps, -} from '@mui/material' +import { ListItem, ListItemIcon, ListItemText } from '@/fakemui' import { forwardRef, ReactNode } from 'react' -export interface NavItemProps extends Omit { +import styles from './NavItem.module.scss' + +export interface NavItemProps extends React.LiHTMLAttributes { icon?: ReactNode label: string onClick?: () => void @@ -25,6 +19,16 @@ export interface NavItemProps extends Omit { className?: string } +const badgeColorMap: Record = { + default: styles.badgeDefault, + primary: styles.badgePrimary, + secondary: styles.badgeSecondary, + error: styles.badgeError, + warning: styles.badgeWarning, + info: styles.badgeInfo, + success: styles.badgeSuccess, +} + const NavItem = forwardRef( ( { @@ -38,93 +42,61 @@ const NavItem = forwardRef( href, secondaryLabel, dense = false, - sx, + className = '', ...props }, ref ) => { + const buttonClasses = [ + styles.navItemButton, + active && styles.navItemButtonSelected, + disabled && styles.navItemButtonDisabled, + dense && styles.navItemButtonDense, + ] + .filter(Boolean) + .join(' ') + + const iconClasses = [styles.icon, active && styles.iconActive].filter(Boolean).join(' ') + + const primaryTextClasses = [styles.textPrimary, active && styles.textPrimaryActive] + .filter(Boolean) + .join(' ') + + const badgeClasses = [styles.badge, badgeColorMap[badgeColor]].filter(Boolean).join(' ') + + const ButtonComponent = href ? 'a' : 'button' + return ( - - + {icon && ( - + {badge !== undefined ? ( - + {icon} - + {badge} + ) : ( icon )} )} {label}} + secondary={secondaryLabel && {secondaryLabel}} /> {badge !== undefined && !icon && ( - - - + + {badge} + )} - + ) } diff --git a/frontends/nextjs/src/components/ui/molecules/navigation/NavLink.tsx b/frontends/nextjs/src/components/ui/molecules/navigation/NavLink.tsx index 49176b46b..1a940c15b 100644 --- a/frontends/nextjs/src/components/ui/molecules/navigation/NavLink.tsx +++ b/frontends/nextjs/src/components/ui/molecules/navigation/NavLink.tsx @@ -1,9 +1,11 @@ 'use client' -import { Box, Link as MuiLink, LinkProps as MuiLinkProps } from '@mui/material' +import { Box, Link } from '@/fakemui' import { forwardRef, ReactNode } from 'react' -export interface NavLinkProps extends Omit { +import styles from './NavLink.module.scss' + +export interface NavLinkProps extends React.AnchorHTMLAttributes { href: string active?: boolean disabled?: boolean @@ -13,56 +15,33 @@ export interface NavLinkProps extends Omit { } const NavLink = forwardRef( - ({ href, active = false, disabled = false, children, icon, sx, ...props }, ref) => { + ({ href, active = false, disabled = false, children, icon, className = '', ...props }, ref) => { + const linkClasses = [ + styles.navLink, + active && styles.navLinkActive, + disabled && styles.navLinkDisabled, + className, + ] + .filter(Boolean) + .join(' ') + + const iconClasses = [styles.icon, active && styles.iconActive].filter(Boolean).join(' ') + return ( - {icon && ( - + {icon} )} {children} - + ) } )