mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Export metrics components.
Some checks failed
Node.js CI / build (postgresql, 18.18) (push) Has been cancelled
Some checks failed
Node.js CI / build (postgresql, 18.18) (push) Has been cancelled
This commit is contained in:
parent
c4114f4349
commit
dc1736458b
16 changed files with 140 additions and 126 deletions
|
|
@ -12,8 +12,20 @@ import {
|
|||
} from '@umami/react-zen';
|
||||
import Link from 'next/link';
|
||||
|
||||
interface SideMenuData {
|
||||
id: string;
|
||||
label: string;
|
||||
icon?: any;
|
||||
path: string;
|
||||
}
|
||||
|
||||
interface SideMenuItems {
|
||||
label?: string;
|
||||
items: SideMenuData[];
|
||||
}
|
||||
|
||||
export interface SideMenuProps extends NavMenuProps {
|
||||
items: { label: string; items: { id: string; label: string; icon?: any; path: string }[] }[];
|
||||
items: SideMenuItems[];
|
||||
title?: string;
|
||||
selectedKey?: string;
|
||||
allowMinimize?: boolean;
|
||||
|
|
@ -28,6 +40,23 @@ export function SideMenu({
|
|||
children,
|
||||
...props
|
||||
}: SideMenuProps) {
|
||||
const renderItems = (items: SideMenuData[]) => {
|
||||
return items?.map(({ id, label, icon, path }) => {
|
||||
const isSelected = selectedKey === id;
|
||||
|
||||
return (
|
||||
<Link key={id} href={path}>
|
||||
<NavMenuItem isSelected={isSelected}>
|
||||
<Row alignItems="center" gap>
|
||||
<Icon>{icon}</Icon>
|
||||
<Text>{label}</Text>
|
||||
</Row>
|
||||
</NavMenuItem>
|
||||
</Link>
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Column
|
||||
gap
|
||||
|
|
@ -47,30 +76,19 @@ export function SideMenu({
|
|||
)}
|
||||
<NavMenu gap="6" {...props}>
|
||||
{items?.map(({ label, items }, index) => {
|
||||
return (
|
||||
<NavMenuGroup
|
||||
title={label}
|
||||
key={`${label}${index}`}
|
||||
gap="1"
|
||||
allowMinimize={allowMinimize}
|
||||
marginBottom="3"
|
||||
>
|
||||
{items?.map(({ id, label, icon, path }) => {
|
||||
const isSelected = selectedKey === id;
|
||||
|
||||
return (
|
||||
<Link key={id} href={path}>
|
||||
<NavMenuItem isSelected={isSelected}>
|
||||
<Row alignItems="center" gap>
|
||||
<Icon>{icon}</Icon>
|
||||
<Text>{label}</Text>
|
||||
</Row>
|
||||
</NavMenuItem>
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</NavMenuGroup>
|
||||
);
|
||||
if (label) {
|
||||
return (
|
||||
<NavMenuGroup
|
||||
title={label}
|
||||
key={`${label}${index}`}
|
||||
gap="1"
|
||||
allowMinimize={allowMinimize}
|
||||
marginBottom="3"
|
||||
>
|
||||
{renderItems(items)}
|
||||
</NavMenuGroup>
|
||||
);
|
||||
}
|
||||
})}
|
||||
</NavMenu>
|
||||
</Column>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue