Files
plane/web/ee/components/desktop/sidebar-toggle.tsx
Prateek Shourya c02f452ae4 [WEB-2332] dev: custom titlebar for desktop application. (#944)
* dev: custom titlebar for desktop application.

* style: update `app-container` css position.

* style: update border padding.
2024-08-28 14:20:47 +05:30

53 lines
1.6 KiB
TypeScript

"use client";
import { useMemo } from "react";
import { observer } from "mobx-react";
import { useParams, usePathname } from "next/navigation";
import { PanelLeft, PanelRight } from "lucide-react";
// ui
import { Tooltip } from "@plane/ui";
// helpers
import { cn } from "@/helpers/common.helper";
// hooks
import { useAppTheme } from "@/hooks/store";
export const SidebarToggle = observer(() => {
// router
const { workspaceSlug } = useParams();
const pathname = usePathname();
// store hooks
const { sidebarCollapsed, toggleSidebar } = useAppTheme();
// derived values
const isSidebarAccessible = !!workspaceSlug?.toString() || pathname.includes("/profile/");
const isSidebarCollapsed = useMemo(() => sidebarCollapsed, [sidebarCollapsed]);
if (!isSidebarAccessible) {
return null;
}
return (
<>
<Tooltip tooltipContent={isSidebarCollapsed ? "Expand sidebar" : "Collapse sidebar"} position="bottom">
<button
onClick={(e) => {
toggleSidebar(!isSidebarCollapsed);
e.currentTarget.blur();
}}
className={cn(
"ml-2 mr-1 size-6 flex items-center justify-center rounded cursor-pointer text-custom-text-300 hover:text-custom-text-200",
{
"text-custom-text-200": !isSidebarCollapsed,
}
)}
>
{isSidebarCollapsed ? (
<PanelRight className="size-4" strokeWidth={2.5} />
) : (
<PanelLeft className="size-4" strokeWidth={2.5} />
)}
</button>
</Tooltip>
</>
);
});