From e8bb0e59a67e28fca16985e532b3e29412e56b45 Mon Sep 17 00:00:00 2001 From: Luis Herasme Date: Mon, 12 Aug 2024 16:54:01 -0400 Subject: [PATCH] Mobile menu (#469) * feat: add mobile menu * fix: add missing key prop to MobileMenuItem in MobileMenu component * fix: update menu data to handle empty NEXT_PUBLIC_SUPPORTED_NETWORKS * refactor: Moves transform to className * refactor: Update Rotable component to make onClick prop optional * feat: Update mobile menu component with the requested features * fix: Add z-index to MobileMenuBackground component * feat: Improve mobile menu ThemeModeButton * chore: MobileMenuBackground renames close -> onClose * chore: MobileMenuBackground renames open -> show * chore: rename MobileMenu -> SidebarMenu * chore: rename NavItem.tsx -> Menu.tsx * refactor: Abstract out the side panel logic * chore: use onClose instead of setOpen(false) * chore: rename MobileMenuBackground -> Overlay * chore: rename NavMenusSection to NavMenus and rename data.tsx to content.tsx * chore: rename MENU_DATA -> MENU_ITEMS * chore: renames MenuItem -> NavItem and ExpandibleMenuItem -> ExpandibleNavItem * chore: Renames MenuItem -> SubItem and removes MenuItemProps * refactor: reuse NavItem and ExpandibleNavItem types inside Menu.tsx * chore: remove NavItem.type * refactor: delegate the responsibility of hiding or displaying the SideMenu to the consumer * chore: display the mobile menu on the right side of the screen in the homepage * chore: update sidebar menu to hide only on extra-large (xl) screens * refactor(web): refactor navigation components: - Improve components names - Separate `SidebarNavigationMenu` from `NavigationMenus` - Re-add `Menu` component to `NavigationMenus` to keep consistency with `SidebarNavigationMenu to keep consistency with `SidebarNavigationMenu`` * feat(web): create side panel context * fix(web): collapse opened tabs automatically when closing sidebar navigation menu * fix(web): smooth overlay display * fix(web): highlight individual navigation items in the sidebar menu when the user is on the corresponding URL route * chore: add changeset * style(web): rename animated side panel props * refactor(web): replace conventional links with nextjs `Link` components in `SidebarNavigationMenu` --------- Co-authored-by: PJColombo --- .changeset/silver-dolphins-clean.md | 5 + .../AppLayout/TopBarLayout/CompactTopBar.tsx | 6 +- .../AppLayout/TopBarLayout/TopBar.tsx | 14 +- .../AppLayout/TopBarLayout/index.tsx | 17 +- apps/web/src/components/Button.tsx | 2 +- .../components/NavMenusSection/NavItem.tsx | 159 ------------------ .../src/components/NavMenusSection/index.tsx | 101 ----------- apps/web/src/components/NavigationMenus.tsx | 152 +++++++++++++++++ apps/web/src/components/Rotable.tsx | 2 +- apps/web/src/components/SidePanel.tsx | 98 +++++++++++ .../src/components/SidebarNavigationMenu.tsx | 148 ++++++++++++++++ apps/web/src/components/content.tsx | 105 ++++++++++++ 12 files changed, 533 insertions(+), 276 deletions(-) create mode 100644 .changeset/silver-dolphins-clean.md delete mode 100644 apps/web/src/components/NavMenusSection/NavItem.tsx delete mode 100644 apps/web/src/components/NavMenusSection/index.tsx create mode 100644 apps/web/src/components/NavigationMenus.tsx create mode 100644 apps/web/src/components/SidePanel.tsx create mode 100644 apps/web/src/components/SidebarNavigationMenu.tsx create mode 100644 apps/web/src/components/content.tsx diff --git a/.changeset/silver-dolphins-clean.md b/.changeset/silver-dolphins-clean.md new file mode 100644 index 000000000..42c86504a --- /dev/null +++ b/.changeset/silver-dolphins-clean.md @@ -0,0 +1,5 @@ +--- +"@blobscan/web": minor +--- + +Added a sidebar navigation menu for smaller screens diff --git a/apps/web/src/components/AppLayout/TopBarLayout/CompactTopBar.tsx b/apps/web/src/components/AppLayout/TopBarLayout/CompactTopBar.tsx index dcbe32cb2..2ecf5acea 100644 --- a/apps/web/src/components/AppLayout/TopBarLayout/CompactTopBar.tsx +++ b/apps/web/src/components/AppLayout/TopBarLayout/CompactTopBar.tsx @@ -1,16 +1,16 @@ +import { SidebarNavigationMenu } from "~/components/SidebarNavigationMenu"; import { BlobscanLogo } from "../../BlobscanLogo"; import { SearchInput } from "../../SearchInput"; -import { ThemeModeButton } from "../../ThemeModeButton"; import { TopBarSurface } from "./TopBarSurface"; export const CompactTopBar = function () { return ( <> -
+
- +
diff --git a/apps/web/src/components/AppLayout/TopBarLayout/TopBar.tsx b/apps/web/src/components/AppLayout/TopBarLayout/TopBar.tsx index 28bb85c98..d51e29051 100644 --- a/apps/web/src/components/AppLayout/TopBarLayout/TopBar.tsx +++ b/apps/web/src/components/AppLayout/TopBarLayout/TopBar.tsx @@ -1,6 +1,7 @@ +import { SidebarNavigationMenu } from "~/components/SidebarNavigationMenu"; import { BlobscanLogo } from "../../BlobscanLogo"; import { ExplorerDetails } from "../../ExplorerDetails"; -import { NavMenusSection } from "../../NavMenusSection"; +import { NavigationMenus } from "../../NavigationMenus"; import { SearchInput } from "../../SearchInput"; import { ThemeModeButton } from "../../ThemeModeButton"; import { TopBarSurface } from "./TopBarSurface"; @@ -14,13 +15,18 @@ export const TopBar: React.FC = () => {
-
- +
+
- +
+ +
+
+ +
diff --git a/apps/web/src/components/AppLayout/TopBarLayout/index.tsx b/apps/web/src/components/AppLayout/TopBarLayout/index.tsx index 0de5d748a..2c7e79fa9 100644 --- a/apps/web/src/components/AppLayout/TopBarLayout/index.tsx +++ b/apps/web/src/components/AppLayout/TopBarLayout/index.tsx @@ -1,9 +1,10 @@ import React from "react"; +import { SidebarNavigationMenu } from "~/components/SidebarNavigationMenu"; import { ThemeModeButton } from "~/components/ThemeModeButton"; import { useIsHomepage } from "~/hooks/useIsHomePage"; import { ExplorerDetails } from "../../ExplorerDetails"; -import { NavMenusSection } from "../../NavMenusSection"; +import { NavigationMenus } from "../../NavigationMenus"; import { CompactTopBar } from "./CompactTopBar"; import { TopBar } from "./TopBar"; @@ -12,19 +13,21 @@ export const TopBarLayout: React.FC = () => { if (isHomepage) { return ( -