2023-01-26 18:12:20 +00:00
|
|
|
import { useState, useRef, FC } from "react";
|
|
|
|
import { Transition } from "@headlessui/react";
|
|
|
|
import Link from "next/link";
|
|
|
|
// icons
|
2023-02-15 06:58:22 +00:00
|
|
|
import { ArrowLongLeftIcon, InboxIcon } from "@heroicons/react/24/outline";
|
2023-01-26 18:12:20 +00:00
|
|
|
import {
|
|
|
|
QuestionMarkCircleIcon,
|
|
|
|
BoltIcon,
|
|
|
|
DocumentIcon,
|
|
|
|
DiscordIcon,
|
|
|
|
GithubIcon,
|
|
|
|
} from "components/icons";
|
|
|
|
// hooks
|
|
|
|
import useTheme from "hooks/use-theme";
|
|
|
|
import useOutsideClickDetector from "hooks/use-outside-click-detector";
|
|
|
|
|
|
|
|
const helpOptions = [
|
|
|
|
{
|
|
|
|
name: "Documentation",
|
|
|
|
href: "https://docs.plane.so/",
|
|
|
|
Icon: DocumentIcon,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Join our Discord",
|
|
|
|
href: "https://discord.com/invite/A92xrEGCge",
|
|
|
|
Icon: DiscordIcon,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Report a bug",
|
|
|
|
href: "https://github.com/makeplane/plane/issues/new/choose",
|
|
|
|
Icon: GithubIcon,
|
|
|
|
},
|
|
|
|
{
|
2023-02-13 14:49:46 +00:00
|
|
|
name: "Email us",
|
2023-01-26 18:12:20 +00:00
|
|
|
href: "mailto:hello@plane.so",
|
2023-02-15 06:58:22 +00:00
|
|
|
Icon: InboxIcon,
|
2023-01-26 18:12:20 +00:00
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
export interface WorkspaceHelpSectionProps {
|
|
|
|
setSidebarActive: React.Dispatch<React.SetStateAction<boolean>>;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const WorkspaceHelpSection: FC<WorkspaceHelpSectionProps> = (props) => {
|
|
|
|
const { setSidebarActive } = props;
|
|
|
|
// theme
|
|
|
|
const { collapsed: sidebarCollapse, toggleCollapsed } = useTheme();
|
|
|
|
// states
|
|
|
|
const [isNeedHelpOpen, setIsNeedHelpOpen] = useState(false);
|
|
|
|
// refs
|
|
|
|
const helpOptionsRef = useRef<HTMLDivElement | null>(null);
|
|
|
|
// hooks
|
|
|
|
useOutsideClickDetector(helpOptionsRef, () => setIsNeedHelpOpen(false));
|
|
|
|
|
2023-01-31 12:39:11 +00:00
|
|
|
const helpOptionMode = sidebarCollapse ? "left-full" : "left-[-75px]";
|
|
|
|
|
2023-01-26 18:12:20 +00:00
|
|
|
return (
|
|
|
|
<div
|
2023-03-04 12:17:03 +00:00
|
|
|
className={`flex w-full items-center justify-between self-baseline border-t bg-white px-6 py-2 ${
|
2023-03-23 17:55:30 +00:00
|
|
|
sidebarCollapse ? "flex-col" : ""
|
2023-01-26 18:12:20 +00:00
|
|
|
}`}
|
|
|
|
>
|
|
|
|
<button
|
|
|
|
type="button"
|
2023-02-28 11:18:02 +00:00
|
|
|
className={`flex items-center gap-x-1 rounded-md px-2 py-2 text-xs font-medium text-gray-500 outline-none hover:bg-gray-100 hover:text-gray-900 ${
|
2023-01-26 18:12:20 +00:00
|
|
|
sidebarCollapse ? "w-full justify-center" : ""
|
|
|
|
}`}
|
2023-02-28 11:18:02 +00:00
|
|
|
onClick={() => {
|
|
|
|
const e = new KeyboardEvent("keydown", {
|
|
|
|
key: "h",
|
|
|
|
});
|
|
|
|
document.dispatchEvent(e);
|
|
|
|
}}
|
|
|
|
title="Shortcuts"
|
2023-01-26 18:12:20 +00:00
|
|
|
>
|
2023-03-23 17:55:30 +00:00
|
|
|
<BoltIcon className="h-4 w-4 text-gray-500" />
|
2023-02-28 11:18:02 +00:00
|
|
|
{!sidebarCollapse && <span>Shortcuts</span>}
|
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className={`flex items-center gap-x-1 rounded-md px-2 py-2 text-xs font-medium text-gray-500 outline-none hover:bg-gray-100 hover:text-gray-900 ${
|
|
|
|
sidebarCollapse ? "w-full justify-center" : ""
|
|
|
|
}`}
|
|
|
|
onClick={() => setIsNeedHelpOpen((prev) => !prev)}
|
|
|
|
title="Help"
|
|
|
|
>
|
2023-03-23 17:55:30 +00:00
|
|
|
<QuestionMarkCircleIcon className="h-4 w-4 text-gray-500" />
|
2023-02-28 11:18:02 +00:00
|
|
|
{!sidebarCollapse && <span>Help</span>}
|
2023-01-26 18:12:20 +00:00
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className="flex items-center gap-3 rounded-md px-2 py-2 text-xs font-medium text-gray-500 outline-none hover:bg-gray-100 hover:text-gray-900 md:hidden"
|
|
|
|
onClick={() => setSidebarActive(false)}
|
|
|
|
>
|
2023-03-23 17:55:30 +00:00
|
|
|
<ArrowLongLeftIcon className="h-4 w-4 flex-shrink-0 text-gray-500 group-hover:text-gray-900" />
|
2023-01-26 18:12:20 +00:00
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
type="button"
|
2023-02-28 11:18:02 +00:00
|
|
|
className={`hidden items-center gap-3 rounded-md px-2 py-2 text-xs font-medium text-gray-500 outline-none hover:bg-gray-100 hover:text-gray-900 md:flex ${
|
2023-01-26 18:12:20 +00:00
|
|
|
sidebarCollapse ? "w-full justify-center" : ""
|
|
|
|
}`}
|
2023-02-28 11:18:02 +00:00
|
|
|
onClick={() => toggleCollapsed()}
|
2023-01-26 18:12:20 +00:00
|
|
|
>
|
2023-02-28 11:18:02 +00:00
|
|
|
<ArrowLongLeftIcon
|
2023-03-23 17:55:30 +00:00
|
|
|
className={`h-4 w-4 flex-shrink-0 text-gray-500 duration-300 group-hover:text-gray-900 ${
|
|
|
|
sidebarCollapse ? "rotate-180" : ""
|
2023-02-28 11:18:02 +00:00
|
|
|
}`}
|
|
|
|
/>
|
2023-01-26 18:12:20 +00:00
|
|
|
</button>
|
2023-02-28 11:18:02 +00:00
|
|
|
|
2023-01-26 18:12:20 +00:00
|
|
|
<div className="relative">
|
|
|
|
<Transition
|
|
|
|
show={isNeedHelpOpen}
|
|
|
|
enter="transition ease-out duration-100"
|
|
|
|
enterFrom="transform opacity-0 scale-95"
|
|
|
|
enterTo="transform opacity-100 scale-100"
|
|
|
|
leave="transition ease-in duration-75"
|
|
|
|
leaveFrom="transform opacity-100 scale-100"
|
|
|
|
leaveTo="transform opacity-0 scale-95"
|
|
|
|
>
|
|
|
|
<div
|
2023-01-31 12:39:11 +00:00
|
|
|
className={`absolute bottom-2 ${helpOptionMode} space-y-2 rounded-sm bg-white py-3 shadow-md`}
|
2023-01-26 18:12:20 +00:00
|
|
|
ref={helpOptionsRef}
|
|
|
|
>
|
|
|
|
{helpOptions.map(({ name, Icon, href }) => (
|
|
|
|
<Link href={href} key={name}>
|
|
|
|
<a
|
|
|
|
target="_blank"
|
2023-03-04 12:17:03 +00:00
|
|
|
className="mx-3 flex items-center gap-x-2 whitespace-nowrap rounded-md px-2 py-2 text-xs hover:bg-gray-100"
|
2023-01-26 18:12:20 +00:00
|
|
|
>
|
|
|
|
<Icon className="h-5 w-5 text-gray-500" />
|
|
|
|
<span className="text-sm">{name}</span>
|
|
|
|
</a>
|
|
|
|
</Link>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</Transition>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|