mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-20 15:57:06 +08:00
45 lines
1.0 KiB
TypeScript
45 lines
1.0 KiB
TypeScript
import { useCallback } from 'react';
|
|
import { NavLink } from 'react-router-dom';
|
|
|
|
import { buttonVariants } from '../../components/ui/button';
|
|
import { cn } from '../../utils';
|
|
|
|
export const NormalSubItem = ({
|
|
module,
|
|
title,
|
|
changeModule,
|
|
indent = 'normal',
|
|
}: {
|
|
module: string;
|
|
title: string;
|
|
changeModule?: (module: string) => void;
|
|
indent?: 'normal' | 'nested';
|
|
}) => {
|
|
const handleClick = useCallback(() => {
|
|
changeModule?.(module);
|
|
}, [changeModule, module]);
|
|
const indentClassName = indent === 'nested' ? 'ml-12' : 'ml-8';
|
|
return (
|
|
<div className="w-full flex">
|
|
<NavLink
|
|
to={`/admin/settings/${module}`}
|
|
onClick={handleClick}
|
|
className={({ isActive }) => {
|
|
return cn(
|
|
buttonVariants({
|
|
variant: 'ghost',
|
|
className: cn(
|
|
indentClassName,
|
|
'px-2 w-full justify-start',
|
|
isActive && 'bg-zinc-100'
|
|
),
|
|
})
|
|
);
|
|
}}
|
|
>
|
|
{title}
|
|
</NavLink>
|
|
</div>
|
|
);
|
|
};
|