forked from github/plane
style: workspace dropdown (#416)
* style: workspace dropdown * style: workspace dropdown hover fix
This commit is contained in:
parent
704b7d02ef
commit
4fad685ec8
@ -3,7 +3,7 @@ import { Menu, Transition } from "@headlessui/react";
|
|||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { ChevronDownIcon, PlusIcon } from "@heroicons/react/24/outline";
|
import { CheckIcon, ChevronDownIcon, PlusIcon } from "@heroicons/react/24/outline";
|
||||||
// hooks
|
// hooks
|
||||||
import useUser from "hooks/use-user";
|
import useUser from "hooks/use-user";
|
||||||
import useTheme from "hooks/use-theme";
|
import useTheme from "hooks/use-theme";
|
||||||
@ -20,13 +20,17 @@ import { IWorkspace } from "types";
|
|||||||
// Static Data
|
// Static Data
|
||||||
const userLinks = (workspaceSlug: string) => [
|
const userLinks = (workspaceSlug: string) => [
|
||||||
{
|
{
|
||||||
name: "My Profile",
|
name: "Workspace Settings",
|
||||||
href: `/${workspaceSlug}/me/profile`,
|
href: `/${workspaceSlug}/settings`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Workspace Invites",
|
name: "Workspace Invites",
|
||||||
href: "/invitations",
|
href: "/invitations",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "My Profile",
|
||||||
|
href: `/${workspaceSlug}/me/profile`,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export const WorkspaceSidebarDropdown = () => {
|
export const WorkspaceSidebarDropdown = () => {
|
||||||
@ -116,16 +120,18 @@ export const WorkspaceSidebarDropdown = () => {
|
|||||||
leaveFrom="transform opacity-100 scale-100"
|
leaveFrom="transform opacity-100 scale-100"
|
||||||
leaveTo="transform opacity-0 scale-95"
|
leaveTo="transform opacity-0 scale-95"
|
||||||
>
|
>
|
||||||
<Menu.Items className="fixed left-2 z-20 mt-1 w-full max-w-[17rem] origin-top-left rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none">
|
<Menu.Items
|
||||||
<div className="divide-y px-1 py-2">
|
className="fixed left-2 z-20 mt-1 flex w-full max-w-[17rem] origin-top-left flex-col rounded-md
|
||||||
<div>
|
bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none"
|
||||||
<Menu.Item as="div" className="px-2 pb-2 text-xs">
|
>
|
||||||
|
<div className="flex flex-col items-start justify-start gap-3 px-5 py-3">
|
||||||
|
<Menu.Item as="div" className="text-sm text-gray-500">
|
||||||
{user?.email}
|
{user?.email}
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
</div>
|
<span className="text-sm font-semibold text-gray-500">Workspace</span>
|
||||||
<div className="py-2">
|
|
||||||
{workspaces ? (
|
{workspaces ? (
|
||||||
<>
|
<div className="flex h-full w-full flex-col items-start justify-start gap-3.5">
|
||||||
{workspaces.length > 0 ? (
|
{workspaces.length > 0 ? (
|
||||||
workspaces.map((workspace) => (
|
workspaces.map((workspace) => (
|
||||||
<Menu.Item key={workspace.id}>
|
<Menu.Item key={workspace.id}>
|
||||||
@ -133,11 +139,10 @@ export const WorkspaceSidebarDropdown = () => {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => handleWorkspaceNavigation(workspace)}
|
onClick={() => handleWorkspaceNavigation(workspace)}
|
||||||
className={`${
|
className="flex w-full items-center justify-between gap-1 rounded-md text-sm text-gray-900"
|
||||||
active ? "bg-gray-100" : ""
|
|
||||||
} flex w-full items-center gap-2 rounded-md p-2 text-sm text-gray-900`}
|
|
||||||
>
|
>
|
||||||
<div className="relative flex h-5 w-5 items-center justify-center rounded bg-gray-700 p-4 uppercase text-white">
|
<div className="flex items-center justify-start gap-2.5">
|
||||||
|
<span className="relative flex h-6 w-6 items-center justify-center rounded bg-gray-700 p-2 text-xs uppercase text-white">
|
||||||
{workspace?.logo && workspace.logo !== "" ? (
|
{workspace?.logo && workspace.logo !== "" ? (
|
||||||
<Image
|
<Image
|
||||||
src={workspace.logo}
|
src={workspace.logo}
|
||||||
@ -149,14 +154,18 @@ export const WorkspaceSidebarDropdown = () => {
|
|||||||
) : (
|
) : (
|
||||||
activeWorkspace?.name?.charAt(0) ?? "N"
|
activeWorkspace?.name?.charAt(0) ?? "N"
|
||||||
)}
|
)}
|
||||||
</div>
|
</span>
|
||||||
<div className="text-left">
|
|
||||||
<h5 className="text-sm">{workspace.name}</h5>
|
<h5 className="text-sm">{workspace.name}</h5>
|
||||||
<div className="text-xs text-gray-500">
|
|
||||||
{workspace.total_members}{" "}
|
|
||||||
{workspace.total_members > 1 ? "members" : "member"}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<span className="p-1">
|
||||||
|
<CheckIcon
|
||||||
|
className={`h-3 w-3.5 text-gray-600 ${
|
||||||
|
active || workspace.id === activeWorkspace?.id
|
||||||
|
? "opacity-100"
|
||||||
|
: "opacity-0"
|
||||||
|
}`}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
@ -170,12 +179,12 @@ export const WorkspaceSidebarDropdown = () => {
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
router.push("/create-workspace");
|
router.push("/create-workspace");
|
||||||
}}
|
}}
|
||||||
className="flex w-full items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-gray-100"
|
className="flex w-full items-center gap-1 text-sm text-gray-600"
|
||||||
>
|
>
|
||||||
<PlusIcon className="h-3 w-3" />
|
<PlusIcon className="h-3 w-3 text-gray-600" />
|
||||||
Create Workspace
|
Create Workspace
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
</>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<Loader className="space-y-2">
|
<Loader className="space-y-2">
|
||||||
@ -185,26 +194,29 @@ export const WorkspaceSidebarDropdown = () => {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-1 pt-2 text-xs">
|
<div className="flex w-full flex-col items-start justify-start gap-2 border-t border-t-gray-200 px-3 py-2 text-sm">
|
||||||
{userLinks(workspaceSlug as string).map((link, index) => (
|
{userLinks(workspaceSlug as string).map((link, index) => (
|
||||||
<Menu.Item key={index} as="div">
|
<Menu.Item
|
||||||
|
key={index}
|
||||||
|
as="div"
|
||||||
|
className="flex w-full items-center justify-start rounded px-2 py-1 text-sm text-gray-600 hover:bg-gray-100"
|
||||||
|
>
|
||||||
<Link href={link.href}>
|
<Link href={link.href}>
|
||||||
<a className="block rounded px-2 py-1 text-left hover:bg-gray-100">
|
<a>{link.name}</a>
|
||||||
{link.name}
|
|
||||||
</a>
|
|
||||||
</Link>
|
</Link>
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
))}
|
))}
|
||||||
|
</div>
|
||||||
|
<div className="w-full border-t border-t-gray-200 px-3 py-2">
|
||||||
<Menu.Item
|
<Menu.Item
|
||||||
as="button"
|
as="button"
|
||||||
type="button"
|
type="button"
|
||||||
className="w-full rounded px-2 py-1 text-left hover:bg-gray-100"
|
className="flex w-full items-center justify-start rounded px-2 py-1 text-sm text-red-600 hover:bg-gray-100"
|
||||||
onClick={handleSignOut}
|
onClick={handleSignOut}
|
||||||
>
|
>
|
||||||
Sign out
|
Sign out
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</Menu.Items>
|
</Menu.Items>
|
||||||
</Transition>
|
</Transition>
|
||||||
</Menu>
|
</Menu>
|
||||||
|
Loading…
Reference in New Issue
Block a user