2023-01-26 18:12:20 +00:00
|
|
|
import React from "react";
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
import Link from "next/link";
|
|
|
|
// icons
|
2023-02-28 11:18:02 +00:00
|
|
|
import { GridViewIcon, AssignmentClipboardIcon, TickMarkIcon, SettingIcon } from "components/icons";
|
2023-01-26 18:12:20 +00:00
|
|
|
// hooks
|
|
|
|
import useTheme from "hooks/use-theme";
|
|
|
|
|
|
|
|
const workspaceLinks = (workspaceSlug: string) => [
|
|
|
|
{
|
2023-02-28 11:18:02 +00:00
|
|
|
icon: GridViewIcon,
|
|
|
|
name: "Dashboard",
|
2023-01-26 18:12:20 +00:00
|
|
|
href: `/${workspaceSlug}`,
|
|
|
|
},
|
|
|
|
{
|
2023-02-28 11:18:02 +00:00
|
|
|
icon: AssignmentClipboardIcon,
|
2023-01-26 18:12:20 +00:00
|
|
|
name: "Projects",
|
|
|
|
href: `/${workspaceSlug}/projects`,
|
|
|
|
},
|
|
|
|
{
|
2023-02-28 11:18:02 +00:00
|
|
|
icon: TickMarkIcon,
|
2023-01-26 18:12:20 +00:00
|
|
|
name: "My Issues",
|
|
|
|
href: `/${workspaceSlug}/me/my-issues`,
|
|
|
|
},
|
|
|
|
{
|
2023-02-28 11:18:02 +00:00
|
|
|
icon: SettingIcon,
|
2023-01-26 18:12:20 +00:00
|
|
|
name: "Settings",
|
|
|
|
href: `/${workspaceSlug}/settings`,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2023-02-28 11:18:02 +00:00
|
|
|
export const WorkspaceSidebarMenu: React.FC = () => {
|
2023-01-26 18:12:20 +00:00
|
|
|
// router
|
|
|
|
const router = useRouter();
|
|
|
|
const { workspaceSlug } = router.query;
|
|
|
|
// theme context
|
|
|
|
const { collapsed: sidebarCollapse } = useTheme();
|
|
|
|
|
|
|
|
return (
|
2023-03-22 11:28:32 +00:00
|
|
|
<div className="flex w-full flex-col items-start justify-start gap-2 px-3 py-1">
|
2023-03-10 10:35:10 +00:00
|
|
|
{workspaceLinks(workspaceSlug as string).map((link, index) => (
|
|
|
|
<Link key={index} href={link.href}>
|
|
|
|
<a
|
|
|
|
className={`${
|
2023-04-25 06:40:05 +00:00
|
|
|
(
|
2023-05-10 20:45:39 +00:00
|
|
|
link.name === "Settings"
|
|
|
|
? router.asPath.includes(link.href)
|
|
|
|
: router.asPath === link.href
|
2023-04-25 06:40:05 +00:00
|
|
|
)
|
2023-05-05 10:15:53 +00:00
|
|
|
? "bg-brand-surface-2 text-brand-base"
|
|
|
|
: "text-brand-secondary hover:bg-brand-surface-2 hover:text-brand-secondary focus:bg-brand-surface-2 focus:text-brand-secondary"
|
2023-03-14 06:48:14 +00:00
|
|
|
} group flex w-full items-center gap-3 rounded-md p-2 text-sm font-medium outline-none ${
|
2023-03-10 10:35:10 +00:00
|
|
|
sidebarCollapse ? "justify-center" : ""
|
|
|
|
}`}
|
|
|
|
>
|
2023-03-22 11:28:32 +00:00
|
|
|
<span className="grid h-5 w-5 flex-shrink-0 place-items-center">
|
|
|
|
<link.icon
|
2023-04-28 15:21:47 +00:00
|
|
|
className="text-brand-secondary"
|
2023-03-22 11:28:32 +00:00
|
|
|
aria-hidden="true"
|
|
|
|
height="20"
|
|
|
|
width="20"
|
|
|
|
/>
|
|
|
|
</span>
|
2023-03-10 10:35:10 +00:00
|
|
|
{!sidebarCollapse && link.name}
|
|
|
|
</a>
|
|
|
|
</Link>
|
|
|
|
))}
|
2023-01-26 18:12:20 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|