mirror of
https://github.com/makeplane/plane.git
synced 2026-07-12 21:40:18 +02:00
* dev: custom titlebar for desktop application. * style: update `app-container` css position. * style: update border padding.
53 lines
1.6 KiB
TypeScript
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>
|
|
</>
|
|
);
|
|
});
|