From 481402e09fe760634b826b09e302e2e1bfec88b1 Mon Sep 17 00:00:00 2001 From: shu Date: Mon, 7 Sep 2026 15:48:36 +0800 Subject: feat: initialize React Spectrum template with layouts and showcases --- src/components/collapsed-navigation.tsx | 54 +++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/components/collapsed-navigation.tsx (limited to 'src/components/collapsed-navigation.tsx') diff --git a/src/components/collapsed-navigation.tsx b/src/components/collapsed-navigation.tsx new file mode 100644 index 0000000..1748317 --- /dev/null +++ b/src/components/collapsed-navigation.tsx @@ -0,0 +1,54 @@ +import { NavLink } from 'react-router' +import { ActionButton } from '@react-spectrum/s2/ActionButton' +import { Menu, MenuItem, MenuTrigger, SubmenuTrigger, Text } from '@react-spectrum/s2/Menu' +import { Tooltip, TooltipTrigger } from '@react-spectrum/s2/Tooltip' +import { menuItems, type NavigationItem } from '../route-config' +import iconStyles from './menu-icon.module.css' +import styles from './layout-basic.module.css' + +function containsPage(item: NavigationItem, pageId?: string): boolean { + return item.id === pageId || !!item.children?.some((child) => containsPage(child, pageId)) +} + +function renderMenuItem(item: NavigationItem) { + const Icon = item.Icon + const content = <>{Icon && }{item.title} + + return item.children ? ( + + {content} + {item.children.map(renderMenuItem)} + + ) : ( + {content} + ) +} + +function CollapsedNavigation({ activePageId }: { activePageId?: string }) { + return ( +
+ {menuItems.map((item) => { + const Icon = item.Icon + const icon = Icon ? : item.title.slice(0, 1) + + return item.children ? ( +
+ + + {icon} + {item.title} + + {item.children.map(renderMenuItem)} + +
+ ) : ( + + {icon} + + ) + })} +
+ ) +} + +export default CollapsedNavigation -- cgit v1.2.3