MCPcopy
hub / github.com/usememos/memos / Navigation

Function Navigation

web/src/components/Navigation.tsx:25–132  ·  view source on GitHub ↗
(props: Props)

Source from the content-addressed store, hash-verified

23}
24
25const Navigation = (props: Props) => {
26 const { collapsed, className } = props;
27 const t = useTranslate();
28 const currentUser = useCurrentUser();
29 const { data: notifications = [] } = useNotifications();
30
31 const homeNavLink: NavLinkItem = {
32 id: "header-memos",
33 path: Routes.HOME,
34 title: t("common.memos"),
35 icon: <LibraryIcon className="w-6 h-auto shrink-0" />,
36 };
37 const exploreNavLink: NavLinkItem = {
38 id: "header-explore",
39 path: Routes.EXPLORE,
40 title: t("common.explore"),
41 icon: <EarthIcon className="w-6 h-auto shrink-0" />,
42 };
43 const aboutNavLink: NavLinkItem = {
44 id: "header-about",
45 path: Routes.ABOUT,
46 title: t("common.about"),
47 icon: <InfoIcon className="w-6 h-auto shrink-0" />,
48 };
49 const attachmentsNavLink: NavLinkItem = {
50 id: "header-attachments",
51 path: Routes.ATTACHMENTS,
52 title: t("common.attachments"),
53 icon: <PaperclipIcon className="w-6 h-auto shrink-0" />,
54 };
55 const unreadCount = notifications.filter((n) => n.status === UserNotification_Status.UNREAD).length;
56 const inboxNavLink: NavLinkItem = {
57 id: "header-inbox",
58 path: Routes.INBOX,
59 title: t("common.inbox"),
60 icon: (
61 <div className="relative">
62 <BellIcon className="w-6 h-auto shrink-0" />
63 {unreadCount > 0 && (
64 <span className="absolute -top-1 -right-1 min-w-[18px] h-[18px] px-1 flex items-center justify-center bg-primary text-primary-foreground text-[10px] font-semibold rounded-full border-2 border-background">
65 {unreadCount > 99 ? "99+" : unreadCount}
66 </span>
67 )}
68 </div>
69 ),
70 };
71 const signInNavLink: NavLinkItem = {
72 id: "header-auth",
73 path: Routes.AUTH,
74 title: t("common.sign-in"),
75 icon: <UserCircleIcon className="w-6 h-auto shrink-0" />,
76 };
77
78 const primaryNavLinks: NavLinkItem[] = currentUser
79 ? [homeNavLink, exploreNavLink, attachmentsNavLink, inboxNavLink]
80 : [exploreNavLink, aboutNavLink, signInNavLink];
81 const inboxAriaLabel = unreadCount > 0 ? `${t("common.inbox")}, ${unreadCount} unread` : t("common.inbox");
82

Callers

nothing calls this directly

Calls 4

useTranslateFunction · 0.90
useNotificationsFunction · 0.90
cnFunction · 0.90
useCurrentUserFunction · 0.85

Tested by

no test coverage detected