Skip to content

Commit 6bd1e33

Browse files
authored
feat: add the transfer buttons to top navigation (#1128)
1 parent 4eae232 commit 6bd1e33

18 files changed

+221
-141
lines changed

apps/namadillo/src/App/App.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import { AppContainer } from "App/Common/AppContainer";
21
import { Toasts } from "App/Common/Toast";
3-
import { TopNavigation } from "App/Common/TopNavigation";
2+
import { AppLayout } from "App/Layout/AppLayout";
43
import { createBrowserHistory } from "history";
54
import { useExtensionEvents } from "hooks/useExtensionEvents";
65
import { useOnNamadaExtensionAttached } from "hooks/useOnNamadaExtensionAttached";
76
import { useTransactionCallback } from "hooks/useTransactionCallbacks";
87
import { useTransactionNotifications } from "hooks/useTransactionNotifications";
98
import { Outlet } from "react-router-dom";
10-
import { Navigation } from "./Common/Navigation";
119
import { ChainLoader } from "./Setup/ChainLoader";
1210

1311
export const history = createBrowserHistory({ window });
@@ -21,15 +19,11 @@ export function App(): JSX.Element {
2119
return (
2220
<>
2321
<Toasts />
24-
<AppContainer
25-
data-testid="AppContainer"
26-
navigation={<Navigation />}
27-
header={<TopNavigation />}
28-
>
22+
<AppLayout>
2923
<ChainLoader>
3024
<Outlet />
3125
</ChainLoader>
32-
</AppContainer>
26+
</AppLayout>
3327
</>
3428
);
3529
}

apps/namadillo/src/App/Common/AppContainer.tsx

Lines changed: 0 additions & 66 deletions
This file was deleted.

apps/namadillo/src/App/Common/PageWithSidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type PageWithSidebar = {
77
export const PageWithSidebar = ({ children }: PageWithSidebar): JSX.Element => {
88
return (
99
<div
10-
className={clsx("w-full min-h-full grid lg:grid-cols-[auto_240px] gap-2")}
10+
className={clsx("w-full min-h-full grid xl:grid-cols-[auto_240px] gap-2")}
1111
>
1212
{children}
1313
</div>

apps/namadillo/src/App/Common/TopNavigation.tsx

Lines changed: 0 additions & 62 deletions
This file was deleted.

apps/namadillo/src/App/Common/ActiveAccount.tsx renamed to apps/namadillo/src/App/Layout/ActiveAccount.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const ActiveAccount = (): JSX.Element => {
2323
<div>
2424
<span
2525
className={clsx(
26-
"px-4 py-2.5 flex items-center text-xs rounded-[2px]",
26+
"px-4 py-2.5 flex items-center text-xs rounded-sm",
2727
"text-white bg-black rounded-xs"
2828
)}
2929
>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { ReactNode } from "react";
2+
import { Link } from "react-router-dom";
3+
import { twMerge } from "tailwind-merge";
4+
import { Logo } from "./Logo";
5+
import { TopNavigation } from "./TopNavigation";
6+
7+
export const AppHeader = ({ burger }: { burger: ReactNode }): JSX.Element => {
8+
return (
9+
<header
10+
className={twMerge(
11+
"grid gap-2",
12+
"grid-cols-[auto_auto] lg:grid-cols-[220px_auto]",
13+
"h-[80px] items-center",
14+
"px-6 sm:px-0"
15+
)}
16+
>
17+
<div className="flex items-center gap-4">
18+
<span className="sm:px-0 lg:hidden">{burger}</span>
19+
<Link
20+
to={"/"}
21+
className={twMerge(
22+
"flex items-center gap-3",
23+
"text-yellow text-xl font-medium uppercase"
24+
)}
25+
>
26+
<span className="w-[40px]">
27+
<Logo eyeOpen={true} />
28+
</span>
29+
<span className="hidden sm:block">Namadillo</span>
30+
</Link>
31+
</div>
32+
33+
<TopNavigation />
34+
</header>
35+
);
36+
};
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { ReactNode, useState } from "react";
2+
import { twMerge } from "tailwind-merge";
3+
import { AppHeader } from "./AppHeader";
4+
import { BurgerButton } from "./BurgerButton";
5+
import { Navigation } from "./Navigation";
6+
7+
export const AppLayout = ({
8+
children,
9+
}: {
10+
children: ReactNode;
11+
}): JSX.Element => {
12+
const [displayNavigation, setDisplayNavigation] = useState(false);
13+
14+
return (
15+
<div className="custom-container pb-2">
16+
<AppHeader
17+
burger={
18+
<span className="sm:px-0 lg:hidden">
19+
<BurgerButton
20+
open={displayNavigation}
21+
onClick={() => setDisplayNavigation(!displayNavigation)}
22+
/>
23+
</span>
24+
}
25+
/>
26+
<div
27+
className={twMerge(
28+
"grid lg:grid-cols-[220px_auto] lg:gap-2 min-h-[calc(100svh-95px)]"
29+
)}
30+
>
31+
<aside
32+
onClick={(e) => e.stopPropagation()}
33+
className={twMerge(
34+
"transition-transform duration-500 ease-out-expo",
35+
"pt-10 bg-black rounded-sm fixed top-0 z-[9999] w-[240px]",
36+
"h-svh lg:h-[calc(100svh-90px)] left-0 lg:z-0 lg:transition-none",
37+
"lg:pt-0 lg:w-auto lg:relative",
38+
!displayNavigation && "-translate-x-full lg:translate-x-0"
39+
)}
40+
>
41+
<Navigation />
42+
</aside>
43+
<main className="min-h-full">{children}</main>
44+
</div>
45+
</div>
46+
);
47+
};
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import { ActionButton } from "@namada/components";
2+
import { ConnectExtensionButton } from "App/Common/ConnectExtensionButton";
3+
import SettingsRoutes from "App/Settings/routes";
4+
import MessageRoutes from "App/SignMessages/routes";
5+
import {
6+
applicationFeaturesAtom,
7+
namadaExtensionConnectedAtom,
8+
signArbitraryEnabledAtom,
9+
} from "atoms/settings";
10+
import { useAtomValue } from "jotai";
11+
import { AiOutlineMessage } from "react-icons/ai";
12+
import { IoSettingsOutline } from "react-icons/io5";
13+
import { useLocation, useNavigate } from "react-router-dom";
14+
import TransferRoutes from "../Transfer/routes";
15+
import { ActiveAccount } from "./ActiveAccount";
16+
import { SyncIndicator } from "./SyncIndicator";
17+
18+
export const TopNavigation = (): JSX.Element => {
19+
const isExtensionConnected = useAtomValue(namadaExtensionConnectedAtom);
20+
const signArbitraryEnabled = useAtomValue(signArbitraryEnabledAtom);
21+
const { maspEnabled, namTransfersEnabled } = useAtomValue(
22+
applicationFeaturesAtom
23+
);
24+
const location = useLocation();
25+
const navigate = useNavigate();
26+
27+
if (!isExtensionConnected) {
28+
return (
29+
<div className="w-fit justify-self-end">
30+
<ConnectExtensionButton />
31+
</div>
32+
);
33+
}
34+
35+
return (
36+
<div className="flex-1 flex items-center gap-4 sm:gap-6">
37+
<div className="hidden lg:flex gap-2">
38+
{maspEnabled && (
39+
<ActionButton
40+
href={TransferRoutes.shield().url}
41+
size="sm"
42+
className="w-[140px]"
43+
>
44+
Shield assets
45+
</ActionButton>
46+
)}
47+
{namTransfersEnabled && (
48+
<ActionButton
49+
href={TransferRoutes.namTransfer().url}
50+
size="sm"
51+
backgroundColor="white"
52+
className="w-[140px]"
53+
>
54+
Transfer
55+
</ActionButton>
56+
)}
57+
</div>
58+
59+
<div className="flex-1" />
60+
61+
<button
62+
className="text-2xl text-yellow hover:text-cyan"
63+
onClick={() =>
64+
navigate(SettingsRoutes.index(), {
65+
state: { backgroundLocation: location },
66+
})
67+
}
68+
>
69+
<IoSettingsOutline />
70+
</button>
71+
{signArbitraryEnabled && (
72+
<button
73+
className="text-2xl text-yellow hover:text-cyan"
74+
title="Sign Message"
75+
onClick={() =>
76+
navigate(MessageRoutes.index(), {
77+
state: { backgroundLocation: location },
78+
})
79+
}
80+
>
81+
<AiOutlineMessage />
82+
</button>
83+
)}
84+
85+
<SyncIndicator />
86+
87+
<ActiveAccount />
88+
</div>
89+
);
90+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { PageWithSidebar } from "App/Common/PageWithSidebar";
2+
3+
export const NamTransfer: React.FC = () => {
4+
return (
5+
<PageWithSidebar>
6+
<div className="flex flex-col gap-2 text-yellow">
7+
<div>Internal Transfer (WIP)</div>
8+
</div>
9+
<aside className="flex flex-col gap-2 text-yellow">
10+
<div>Sidebar (WIP)</div>
11+
</aside>
12+
</PageWithSidebar>
13+
);
14+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { PageWithSidebar } from "App/Common/PageWithSidebar";
2+
3+
export const Shield: React.FC = () => {
4+
return (
5+
<PageWithSidebar>
6+
<div className="flex flex-col gap-2 text-yellow">
7+
<div>Shield (WIP)</div>
8+
</div>
9+
<aside className="flex flex-col gap-2 text-yellow">
10+
<div>Sidebar (WIP)</div>
11+
</aside>
12+
</PageWithSidebar>
13+
);
14+
};

0 commit comments

Comments
 (0)