admin管理员组文章数量:1123509
Hi I am following the component of double sidebar by mantine but struggle to change the submenu based on the selection.
import { useState } from 'react';
import {
IconCalendarStats,
IconDeviceDesktopAnalytics,
IconFingerprint,
IconGauge,
IconHome2,
IconSettings,
IconUser,
} from '@tabler/icons-react';
import { Title, Tooltip, UnstyledButton } from '@mantine/core';
import { MantineLogo } from '@mantinex/mantine-logo';
import classes from './DoubleNavbar.module.css';
const mainLinksMockdata = [
{ icon: IconHome2, label: 'Home' },
{ icon: IconGauge, label: 'Dashboard' },
{ icon: IconDeviceDesktopAnalytics, label: 'Analytics' },
{ icon: IconCalendarStats, label: 'Releases' },
{ icon: IconUser, label: 'Account' },
{ icon: IconFingerprint, label: 'Security' },
{ icon: IconSettings, label: 'Settings' },
];
const linksMockdata = [
'Security',
'Settings',
'Dashboard',
'Releases',
'Account',
'Orders',
'Clients',
'Databases',
'Pull Requests',
'Open Issues',
'Wiki pages',
];
export function DoubleNavbar() {
const [active, setActive] = useState('Releases');
const [activeLink, setActiveLink] = useState('Settings');
const mainLinks = mainLinksMockdata.map((link) => (
<Tooltip
label={link.label}
position="right"
withArrow
transitionProps={{ duration: 0 }}
key={link.label}
>
<UnstyledButton
onClick={() => setActive(link.label)}
className={classes.mainLink}
data-active={link.label === active || undefined}
>
<link.icon size={22} stroke={1.5} />
</UnstyledButton>
</Tooltip>
));
const links = linksMockdata.map((link) => (
<a
className={classes.link}
data-active={activeLink === link || undefined}
href="#"
onClick={(event) => {
event.preventDefault();
setActiveLink(link);
}}
key={link}
>
{link}
</a>
));
return (
<nav className={classes.navbar}>
<div className={classes.wrapper}>
<div className={classes.aside}>
<div className={classes.logo}>
<MantineLogo type="mark" size={30} />
</div>
{mainLinks}
</div>
<div className={classes.main}>
<Title order={4} className={classes.title}>
{active}
</Title>
{links}
</div>
</div>
</nav>
);
}
本文标签: nextjshow to change submenu on sidebar of mantine double sidebarStack Overflow
版权声明:本文标题:next.js - how to change submenu on sidebar of mantine double sidebar - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736572202a1944786.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论