From 56046f56956cd4ef150ba8f6e92feefd2d7b3540 Mon Sep 17 00:00:00 2001 From: 01zulfi <85733202+01zulfi@users.noreply.github.com> Date: Tue, 7 Jan 2025 11:26:16 +0500 Subject: [PATCH] web: separate component for tab items in sidebar Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com> --- .../src/components/navigation-menu/index.tsx | 5 +- .../navigation-menu/navigation-item.tsx | 36 ++++---- .../components/navigation-menu/tab-item.tsx | 92 +++++++++++++++++++ 3 files changed, 110 insertions(+), 23 deletions(-) create mode 100644 apps/web/src/components/navigation-menu/tab-item.tsx diff --git a/apps/web/src/components/navigation-menu/index.tsx b/apps/web/src/components/navigation-menu/index.tsx index ce7a41827..09f441513 100644 --- a/apps/web/src/components/navigation-menu/index.tsx +++ b/apps/web/src/components/navigation-menu/index.tsx @@ -85,6 +85,7 @@ import { CREATE_BUTTON_MAP, createBackup } from "../../common"; import { TaskManager } from "../../common/task-manager"; import { showToast } from "../../utils/toast"; import { useStore } from "../../stores/note-store"; +import { TabItem } from "./tab-item"; type Route = { id: string; @@ -310,15 +311,13 @@ function NavigationMenu(props: NavigationMenuProps) { }} > {tabs.map((tab) => ( - setCurrentTab(tab.id)} - showTitle={false} /> ))} diff --git a/apps/web/src/components/navigation-menu/navigation-item.tsx b/apps/web/src/components/navigation-menu/navigation-item.tsx index b9cd53b23..ce9ac41fb 100644 --- a/apps/web/src/components/navigation-menu/navigation-item.tsx +++ b/apps/web/src/components/navigation-menu/navigation-item.tsx @@ -41,7 +41,6 @@ type NavigationItemProps = { onClick?: () => void; count?: number; menuItems?: MenuItem[]; - showTitle?: boolean; }; function NavigationItem( @@ -65,7 +64,6 @@ function NavigationItem( count, sx, containerRef, - showTitle = true, ...restProps } = props; const isMobile = useMobile(); @@ -146,22 +144,21 @@ function NavigationItem( /> )} - {showTitle && ( - - {title} - {/* {tag && ( + + {title} + {/* {tag && ( )} */} - - )} + {children ? ( children diff --git a/apps/web/src/components/navigation-menu/tab-item.tsx b/apps/web/src/components/navigation-menu/tab-item.tsx new file mode 100644 index 000000000..32d88b17e --- /dev/null +++ b/apps/web/src/components/navigation-menu/tab-item.tsx @@ -0,0 +1,92 @@ +/* +This file is part of the Notesnook project (https://notesnook.com/) + +Copyright (C) 2023 Streetwriters (Private) Limited + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +import { createButtonVariant } from "@notesnook/theme"; +import { Button, Flex, FlexProps } from "@theme-ui/components"; +import { PropsWithChildren } from "react"; +import { Icon } from "../icons"; + +type TabItemProps = { + icon?: Icon; + title?: string; + selected?: boolean; + onClick?: () => void; +}; + +export function TabItem(props: PropsWithChildren) { + const { + icon: Icon, + color, + title, + children, + selected, + onClick, + sx, + ...restProps + } = props; + + return ( + + + + ); +}