Skip to content

Commit c4f094d

Browse files
fix: BrandBanner to use NavLink (#4536)
* Fix BrandBanner to use NavLink * Apply suggestions from code review --------- Co-authored-by: Johnny <[email protected]>
1 parent 3d0f728 commit c4f094d

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

web/src/components/BrandBanner.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import useCurrentUser from "@/hooks/useCurrentUser";
2-
import useNavigateTo from "@/hooks/useNavigateTo";
3-
import { Routes } from "@/router";
41
import { workspaceStore } from "@/store/v2";
52
import { cn } from "@/utils";
63
import UserAvatar from "./UserAvatar";
@@ -12,18 +9,13 @@ interface Props {
129

1310
const BrandBanner = (props: Props) => {
1411
const { collapsed } = props;
15-
const navigateTo = useNavigateTo();
16-
const currentUser = useCurrentUser();
1712
const workspaceGeneralSetting = workspaceStore.state.generalSetting;
1813
const title = workspaceGeneralSetting.customProfile?.title || "Memos";
1914
const avatarUrl = workspaceGeneralSetting.customProfile?.logoUrl || "/full-logo.webp";
2015

2116
return (
2217
<div className={cn("relative w-full h-auto shrink-0", props.className)}>
23-
<div
24-
className={cn("w-auto flex flex-row justify-start items-center text-gray-800 dark:text-gray-400", collapsed ? "px-1" : "px-3")}
25-
onClick={() => navigateTo(currentUser ? Routes.ROOT : Routes.EXPLORE)}
26-
>
18+
<div className={cn("w-auto flex flex-row justify-start items-center text-gray-800 dark:text-gray-400", collapsed ? "px-1" : "px-3")}>
2719
<UserAvatar className="shrink-0" avatarUrl={avatarUrl} />
2820
{!collapsed && <span className="ml-2 text-lg font-medium text-slate-800 dark:text-gray-300 shrink truncate">{title}</span>}
2921
</div>

web/src/components/Navigation.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ const Navigation = observer((props: Props) => {
8080
)}
8181
>
8282
<div className="w-full px-1 py-1 flex flex-col justify-start items-start space-y-2 overflow-auto hide-scrollbar shrink">
83-
<BrandBanner className="mb-2" collapsed={collapsed} />
83+
<NavLink className="mb-2" to={currentUser ? Routes.ROOT : Routes.EXPLORE}>
84+
<BrandBanner collapsed={collapsed} />
85+
</NavLink>
8486
{navLinks.map((navLink) => (
8587
<NavLink
8688
className={({ isActive }) =>

0 commit comments

Comments
 (0)