Skip to content

Commit 123f59e

Browse files
[WEB-5525] improvement: update WorkspaceMenuRoot to use variant prop for layout adjustments (#8196)
1 parent c7bf912 commit 123f59e

File tree

8 files changed

+36
-25
lines changed

8 files changed

+36
-25
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const isSidebarToggleVisible = () => true;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from "./helper";
2+
export * from "./sidebar-workspace-menu";
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function DesktopSidebarWorkspaceMenu() {
2+
return null;
3+
}

apps/web/ce/components/navigations/top-navigation-root.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const TopNavigationRoot = observer(() => {
2020
>
2121
{/* Workspace Menu */}
2222
<div className="shrink-0 flex-1">
23-
<WorkspaceMenuRoot />
23+
<WorkspaceMenuRoot variant="top-navigation" />
2424
</div>
2525
{/* Power K Search */}
2626
<div className="shrink-0">

apps/web/core/components/navigation/app-rail-root.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { cn } from "@plane/utils";
88
import { AppSidebarItem } from "@/components/sidebar/sidebar-item";
99
// hooks
1010
import { useAppRailPreferences } from "@/hooks/use-navigation-preferences";
11+
// plane web imports
12+
import { DesktopSidebarWorkspaceMenu } from "@/plane-web/components/desktop";
1113
// local imports
1214
import { AppSidebarItemsRoot } from "./items-root";
1315

@@ -39,6 +41,7 @@ export const AppRailRoot = observer(() => {
3941
"gap-3": !showLabel,
4042
})}
4143
>
44+
<DesktopSidebarWorkspaceMenu />
4245
<AppSidebarItemsRoot showLabel={showLabel} />
4346
<div className="border-t border-custom-sidebar-border-300 mx-2" />
4447
<AppSidebarItem

apps/web/core/components/sidebar/sidebar-toggle-button.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import { observer } from "mobx-react";
22
import { PanelLeft } from "lucide-react";
33
// hooks
44
import { useAppTheme } from "@/hooks/store/use-app-theme";
5+
import { isSidebarToggleVisible } from "@/plane-web/components/desktop";
56

67
export const AppSidebarToggleButton = observer(function AppSidebarToggleButton() {
78
// store hooks
89
const { toggleSidebar, sidebarPeek, toggleSidebarPeek } = useAppTheme();
910

11+
if (!isSidebarToggleVisible()) return null;
1012
return (
1113
<button
1214
className="flex items-center justify-center size-6 rounded-md text-custom-text-400 hover:text-custom-primary-100 hover:bg-custom-background-90"

apps/web/core/components/workspace/sidebar/dropdown.tsx

Lines changed: 0 additions & 10 deletions
This file was deleted.

apps/web/core/components/workspace/sidebar/workspace-menu-root.tsx

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ import { WorkspaceLogo } from "../logo";
2525
import SidebarDropdownItem from "./dropdown-item";
2626

2727
type WorkspaceMenuRootProps = {
28-
renderLogoOnly?: boolean;
28+
variant: "sidebar" | "top-navigation";
2929
};
3030

3131
export const WorkspaceMenuRoot = observer(function WorkspaceMenuRoot(props: WorkspaceMenuRootProps) {
32-
const { renderLogoOnly } = props;
32+
const { variant } = props;
3333
// store hooks
3434
const { toggleSidebar, toggleAnySidebarDropdown } = useAppTheme();
3535
const { data: currentUser } = useUser();
@@ -72,8 +72,8 @@ export const WorkspaceMenuRoot = observer(function WorkspaceMenuRoot(props: Work
7272
<Menu
7373
as="div"
7474
className={cn("relative h-full flex max-w-48 w-fit whitespace-nowrap truncate", {
75-
"justify-center text-center": renderLogoOnly,
76-
"flex-grow justify-stretch text-left truncate": !renderLogoOnly,
75+
"w-full justify-center text-center": variant === "sidebar",
76+
"flex-grow justify-stretch text-left truncate": variant === "top-navigation",
7777
})}
7878
>
7979
{({ open, close }: { open: boolean; close: () => void }) => {
@@ -84,9 +84,9 @@ export const WorkspaceMenuRoot = observer(function WorkspaceMenuRoot(props: Work
8484

8585
return (
8686
<>
87-
{renderLogoOnly ? (
87+
{variant === "sidebar" && (
8888
<Menu.Button
89-
className={cn("flex items-center justify-center size-8 rounded", {
89+
className={cn("flex w-full items-center justify-center size-8 rounded-md", {
9090
"bg-custom-sidebar-background-80": open,
9191
})}
9292
>
@@ -97,26 +97,29 @@ export const WorkspaceMenuRoot = observer(function WorkspaceMenuRoot(props: Work
9797
<WorkspaceLogo
9898
logo={activeWorkspace?.logo_url}
9999
name={activeWorkspace?.name}
100-
classNames="size-8 rounded-md"
100+
classNames="size-8 rounded-md border border-custom-border-200"
101101
/>
102102
),
103103
}}
104104
/>
105105
</Menu.Button>
106-
) : (
106+
)}
107+
{variant === "top-navigation" && (
107108
<Menu.Button
108109
className={cn(
109-
"group/menu-button flex items-center gap-1 p-1 truncate rounded text-sm font-medium text-custom-sidebar-text-200 hover:bg-custom-sidebar-background-80 focus:outline-none ",
110+
"group/menu-button flex items-center gap-1 p-1 truncate rounded text-sm font-medium text-custom-sidebar-text-200 hover:bg-custom-sidebar-background-80 focus:outline-none justify-between flex-grow",
110111
{
111-
"justify-center text-center": renderLogoOnly,
112-
"justify-between flex-grow": !renderLogoOnly,
113112
"bg-custom-sidebar-background-80": open,
114113
}
115114
)}
116115
aria-label={t("aria_labels.projects_sidebar.open_workspace_switcher")}
117116
>
118117
<div className="flex-grow flex items-center gap-2 truncate">
119-
<WorkspaceLogo logo={activeWorkspace?.logo_url} name={activeWorkspace?.name} />
118+
<WorkspaceLogo
119+
logo={activeWorkspace?.logo_url}
120+
name={activeWorkspace?.name}
121+
classNames="border border-custom-border-200 size-7"
122+
/>
120123
<h4 className="truncate text-base font-medium text-custom-text-100">
121124
{activeWorkspace?.name ?? t("loading")}
122125
</h4>
@@ -128,7 +131,6 @@ export const WorkspaceMenuRoot = observer(function WorkspaceMenuRoot(props: Work
128131
/>
129132
</Menu.Button>
130133
)}
131-
132134
<Transition
133135
as={Fragment}
134136
enter="transition ease-out duration-100"
@@ -139,7 +141,15 @@ export const WorkspaceMenuRoot = observer(function WorkspaceMenuRoot(props: Work
139141
leaveTo="transform opacity-0 scale-95"
140142
>
141143
<Menu.Items as={Fragment}>
142-
<div className="fixed top-10 left-4 z-[21] mt-1 flex w-[19rem] origin-top-left flex-col divide-y divide-custom-border-100 rounded-md border-[0.5px] border-custom-sidebar-border-300 bg-custom-sidebar-background-100 shadow-custom-shadow-rg outline-none">
144+
<div
145+
className={cn(
146+
"fixed z-[21] mt-1 flex w-[19rem] origin-top-left flex-col divide-y divide-custom-border-100 rounded-md border-[0.5px] border-custom-sidebar-border-300 bg-custom-sidebar-background-100 shadow-custom-shadow-rg outline-none",
147+
{
148+
"top-11 left-14": variant === "sidebar",
149+
"top-10 left-4": variant === "top-navigation",
150+
}
151+
)}
152+
>
143153
<div className="overflow-x-hidden vertical-scrollbar scrollbar-sm flex max-h-96 flex-col items-start justify-start overflow-y-scroll">
144154
<span className="rounded-md text-left px-4 sticky top-0 z-[21] h-full w-full bg-custom-sidebar-background-100 pb-1 pt-3 text-sm font-medium text-custom-text-400 truncate flex-shrink-0">
145155
{currentUser?.email}

0 commit comments

Comments
 (0)