From 37df86ab976c7f8acc5c527f9a4c8ee37e71ca5d Mon Sep 17 00:00:00 2001 From: JunichiSugiura Date: Wed, 22 Jan 2025 13:54:50 +0900 Subject: [PATCH 1/2] Add bottom tabs --- .../src/components/achievements/index.tsx | 10 ++- packages/profile/src/components/activity.tsx | 5 +- .../src/components/inventory/index.tsx | 5 +- .../profile/src/components/layout/index.tsx | 61 ++++++++++++++++- .../profile/src/components/navigation.tsx | 68 ------------------- .../src/components/icons/state/clock.tsx | 2 +- 6 files changed, 71 insertions(+), 80 deletions(-) delete mode 100644 packages/profile/src/components/navigation.tsx diff --git a/packages/profile/src/components/achievements/index.tsx b/packages/profile/src/components/achievements/index.tsx index bc2b9ff6f..1535f8620 100644 --- a/packages/profile/src/components/achievements/index.tsx +++ b/packages/profile/src/components/achievements/index.tsx @@ -1,4 +1,5 @@ import { + LayoutBottomTabs, LayoutContainer, LayoutContent, LayoutHeader, @@ -8,7 +9,6 @@ import { ScrollArea, Button, ArrowIcon, Spinner } from "@cartridge/ui-next"; import { TrophiesTab, LeaderboardTab, Scoreboard } from "./tab"; import { useAccount, useUsername } from "@/hooks/account"; import { CopyAddress } from "@cartridge/ui-next"; -import { Navigation } from "../navigation"; import { useEffect, useMemo, useState } from "react"; import { useParams } from "react-router-dom"; import { Trophies } from "./trophies"; @@ -92,11 +92,7 @@ export function Achievements() { } description={} right={ - isSelf ? ( - - ) : ( - - ) + !isSelf ? : undefined } /> @@ -154,6 +150,8 @@ export function Achievements() { )} + + {isSelf && } ); } diff --git a/packages/profile/src/components/activity.tsx b/packages/profile/src/components/activity.tsx index c97eea19d..287d7d54e 100644 --- a/packages/profile/src/components/activity.tsx +++ b/packages/profile/src/components/activity.tsx @@ -10,13 +10,13 @@ import { } from "@cartridge/ui-next"; import { useInfiniteTokenTransfersQuery } from "@cartridge/utils/api/indexer"; import { + LayoutBottomTabs, LayoutContainer, LayoutContent, LayoutContentError, LayoutContentLoader, LayoutHeader, } from "@/components/layout"; -import { Navigation } from "@/components/navigation"; import { useAccount } from "@/hooks/account"; import { Link } from "react-router-dom"; import { StarkscanUrl, useIndexerAPI } from "@cartridge/utils"; @@ -45,7 +45,6 @@ export function Activity() { } - right={} /> {(() => { @@ -124,6 +123,8 @@ export function Activity() { } } })()} + + ); } diff --git a/packages/profile/src/components/inventory/index.tsx b/packages/profile/src/components/inventory/index.tsx index c241c745a..8c8e57e44 100644 --- a/packages/profile/src/components/inventory/index.tsx +++ b/packages/profile/src/components/inventory/index.tsx @@ -4,11 +4,11 @@ export { SendToken } from "./token/send/index"; import { CopyAddress, ScrollArea } from "@cartridge/ui-next"; import { + LayoutBottomTabs, LayoutContainer, LayoutContent, LayoutHeader, } from "@/components/layout"; -import { Navigation } from "../navigation"; import { Tokens } from "./token"; import { useAccount } from "@/hooks/account"; import { Outlet, useParams } from "react-router-dom"; @@ -30,7 +30,6 @@ export function Inventory() { } - right={project ? : undefined} /> @@ -41,6 +40,8 @@ export function Inventory() { + + {project && } ); } diff --git a/packages/profile/src/components/layout/index.tsx b/packages/profile/src/components/layout/index.tsx index a021aefb4..ebf4b8ba3 100644 --- a/packages/profile/src/components/layout/index.tsx +++ b/packages/profile/src/components/layout/index.tsx @@ -1,3 +1,4 @@ +import { ProfileContextTypeVariant } from "@cartridge/controller"; import { Button, cn, @@ -6,9 +7,13 @@ import { DotsIcon, Spinner, ErrorImage, + ChestIcon, + TrophyIcon, + ClockIcon, } from "@cartridge/ui-next"; -import { PropsWithChildren, useCallback } from "react"; +import { PropsWithChildren, useCallback, useMemo } from "react"; import { useConnection } from "@/hooks/context"; +import { Link, useLocation } from "react-router-dom"; import { isIframe } from "@cartridge/utils"; export function LayoutContainer({ @@ -176,3 +181,57 @@ export function LayoutFooter({ ); } + +export function LayoutBottomTabs() { + const { pathname } = useLocation(); + const active = useMemo(() => { + if (pathname.includes("inventory")) return "inventory"; + if (pathname.includes("achievements")) return "achievements"; + if (pathname.includes("activity")) return "activity"; + + return "inventory"; + }, [pathname]); + + return ( +
+ + + + + + + + + +
+ ); +} diff --git a/packages/profile/src/components/navigation.tsx b/packages/profile/src/components/navigation.tsx deleted file mode 100644 index 98cbb20e4..000000000 --- a/packages/profile/src/components/navigation.tsx +++ /dev/null @@ -1,68 +0,0 @@ -import { - ClockIcon, - cn, - CoinsIcon, - StateIconProps, - Tooltip, - TooltipContent, - TooltipProvider, - TooltipTrigger, - TrophyIcon, -} from "@cartridge/ui-next"; -import { ProfileContextTypeVariant } from "@cartridge/controller"; -import { Link, useMatch, useParams } from "react-router-dom"; -import { useAccount } from "@/hooks/account"; -import { useConnection } from "@/hooks/context"; - -export function Navigation() { - const { project } = useParams<{ project?: string }>(); - const { namespace } = useConnection(); - return ( -
- - {project && namespace && ( - - )} - {project && } -
- ); -} - -function Item({ - Icon, - variant, -}: { - Icon: React.ComponentType; - variant: ProfileContextTypeVariant; -}) { - const { project } = useParams<{ project?: string }>(); - const { username } = useAccount(); - const isPublic = useMatch(`/account/:username/${variant}`); - const isSlot = useMatch(`/account/:username/slot/:project/${variant}`); - const isActive = project ? isSlot : isPublic; - - return ( - - - - - - - - -

{variant}

-
-
-
- ); -} diff --git a/packages/ui-next/src/components/icons/state/clock.tsx b/packages/ui-next/src/components/icons/state/clock.tsx index b52ea0f19..aa0081ee7 100644 --- a/packages/ui-next/src/components/icons/state/clock.tsx +++ b/packages/ui-next/src/components/icons/state/clock.tsx @@ -6,7 +6,7 @@ export const ClockIcon = memo( forwardRef( ({ className, size, variant, ...props }, forwardedRef) => ( Date: Wed, 22 Jan 2025 13:55:03 +0900 Subject: [PATCH 2/2] Prevent content to overwrap with footer --- packages/profile/src/components/layout/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/profile/src/components/layout/index.tsx b/packages/profile/src/components/layout/index.tsx index ebf4b8ba3..381be2c06 100644 --- a/packages/profile/src/components/layout/index.tsx +++ b/packages/profile/src/components/layout/index.tsx @@ -139,6 +139,7 @@ export function LayoutContent({