重构主导航栏父子菜单选中态与树形分支样式
This commit is contained in:
@@ -258,10 +258,12 @@ export default function MainLayout() {
|
||||
const isOpen = openKeys.includes(section.key)
|
||||
const isSelected = selectedKey === section.key
|
||||
const hasSelectedChild = section.children?.some((child) => child.key === selectedKey)
|
||||
const isParentActive = hasSelectedChild
|
||||
const isSingleActive = isSelected && !section.children?.length
|
||||
return (
|
||||
<div className="app-sidebar__group" key={section.key}>
|
||||
<button
|
||||
className={`app-sidebar__item${isSelected || hasSelectedChild ? ' app-sidebar__item--active' : ''}${section.disabled ? ' app-sidebar__item--disabled' : ''}`}
|
||||
className={`app-sidebar__item${isSingleActive ? ' app-sidebar__item--active' : ''}${isParentActive ? ' app-sidebar__item--parent-active' : ''}${section.disabled ? ' app-sidebar__item--disabled' : ''}`}
|
||||
type="button"
|
||||
onClick={() => toggleSection(section)}
|
||||
title={collapsed ? section.label : undefined}
|
||||
|
||||
Reference in New Issue
Block a user