Skip to content

Commit

Permalink
Merge pull request #26 from astriaorg/feature/mobile-nav
Browse files Browse the repository at this point in the history
Adds MobileNav Refactors NetworkSelector
  • Loading branch information
matthew-garrett authored Jan 22, 2025
2 parents 8e1b7a8 + a034767 commit e8e47e6
Show file tree
Hide file tree
Showing 26 changed files with 841 additions and 106 deletions.
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
import React, { useMemo } from "react";
import { ConnectCosmosWalletButton } from "features/CosmosWallet";
import { ConnectEvmWalletButton, SingleWalletButton } from "features/EvmWallet";
import { ConnectCosmosWalletButton, useCosmosWallet } from "features/CosmosWallet";
import {
ConnectEvmWalletButton,
SingleWalletConnect,
} from "features/EvmWallet";
import {
Button,
Popover,
PopoverContent,
PopoverTrigger,
} from "@repo/ui/shadcn-primitives";
import { usePathname } from "next/navigation";

interface ConnectWalletsButtonProps {
// Label to show before the user is connected to any wallets.
labelBeforeConnected?: string;
}
import { useAccount } from "wagmi";

/**
* Button with dropdown to connect to multiple wallets.
*/
export default function ConnectWalletsButton({
labelBeforeConnected,
}: ConnectWalletsButtonProps) {
export default function ConnectWalletsButton() {
const pathname = usePathname();
const { cosmosAccountAddress } = useCosmosWallet();
const userAccount = useAccount();

const label = useMemo(() => {
return labelBeforeConnected ?? "Connect";
}, [labelBeforeConnected]);
const isConnected = userAccount.address || cosmosAccountAddress;

return (
<div>
Expand All @@ -35,7 +31,7 @@ export default function ConnectWalletsButton({
variant="default"
className="rounded-md bg-button-gradient text-white transition border border-button-gradient hover:border-white w-[156px] text-base"
>
<span>{label}</span>
<span>{isConnected ? "Connected" : "Connect"}</span>
</Button>
</PopoverTrigger>
<PopoverContent
Expand All @@ -52,7 +48,7 @@ export default function ConnectWalletsButton({
</PopoverContent>
</Popover>
) : (
<SingleWalletButton />
<SingleWalletConnect />
)}
</div>
);
Expand Down
9 changes: 6 additions & 3 deletions apps/flame-defi/app/components/DepositCard/DepositCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
PlusIcon,
WalletIcon,
} from "@repo/ui/icons";
import { shortenAddress } from "utils/utils";

export default function DepositCard(): React.ReactElement {
const { addNotification } = useNotifications();
Expand Down Expand Up @@ -332,10 +333,10 @@ export default function DepositCard(): React.ReactElement {
</div>
</div>
{fromAddress && (
<div className="bg-grey-dark rounded-xl py-2 px-3">
<div className="mt-3 bg-grey-dark rounded-xl py-2 px-3">
{fromAddress && (
<p className="text-grey-light font-semibold">
Address: {fromAddress}
Address: {shortenAddress(fromAddress)}
</p>
)}
{fromAddress &&
Expand Down Expand Up @@ -406,7 +407,9 @@ export default function DepositCard(): React.ReactElement {
onKeyDown={handleEditRecipientClick}
onClick={handleEditRecipientClick}
>
<span className="mr-2">Address: {evmAccountAddress}</span>
<span className="mr-2">
Address: {shortenAddress(evmAccountAddress)}
</span>
<i className="fas fa-pen-to-square" />
</p>
)}
Expand Down
162 changes: 162 additions & 0 deletions apps/flame-defi/app/components/MobileNav/MobileNav.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
Button,
Drawer,
DrawerContent,
DrawerTrigger,
} from "@repo/ui/shadcn-primitives";
import MobileWalletConnect from "components/MobileWalletConnect/MobileWalletConnect";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { useCallback, useEffect, useState } from "react";

function MobileNav() {
const [isOpen, setIsOpen] = useState(false);
const pathname = usePathname();

const handleClose = useCallback(() => {
setIsOpen(false);
}, []);

useEffect(() => {
setIsOpen(false);
}, [pathname]);

return (
<div className="flex items-center gap-4 md:hidden">
<MobileWalletConnect handleClose={handleClose} />
<Drawer open={isOpen} onOpenChange={setIsOpen} direction="bottom">
<DrawerTrigger asChild>
<Button
variant="ghost"
className="p-2 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent"
>
<div className="flex flex-col gap-1.5 w-6">
<div
className={`h-0.5 bg-current transition-all ${
isOpen ? "rotate-45 translate-y-2" : ""
}`}
/>
<div
className={`h-0.5 bg-current transition-all ${
isOpen ? "opacity-0" : ""
}`}
/>
<div
className={`h-0.5 bg-current transition-all ${
isOpen ? "-rotate-45 -translate-y-2" : ""
}`}
/>
</div>
</Button>
</DrawerTrigger>
<DrawerContent className="bg-radial-dark pb-12">
<div className="p-8 pt-4 pb-0 flex flex-col items-start">
<div className="text-center text-white text-base font-semibold">
Flame Apps
</div>
<div className="flex flex-col items-baseline space-y-4 mt-4">
<Link
href="/"
className={`font-medium text-grey-light text-base ${pathname === "/" ? "text-orange-soft" : ""}`}
>
Bridge
</Link>
<Link
href="/swap"
className={`font-medium text-grey-light text-base ${pathname === "/swap" ? "text-orange-soft" : ""}`}
>
Swap
</Link>
<Link
href="/pool"
className={`font-medium text-grey-light text-base ${pathname === "/pool" ? "text-orange-soft" : ""}`}
>
Pool
</Link>
</div>
</div>
<div className="pt-4 pb-0 px-8 flex flex-col items-start">
<Accordion type="single" collapsible>
<AccordionItem value="docs-details" className="border-b-0 pb-4">
<AccordionTrigger className="no-underline hover:no-underline flex items-center justify-start p-0 [&>svg]:h-6 [&>svg]:w-6">
<div className="text-white text-base font-semibold mr-1 mb-1">
Docs
</div>
</AccordionTrigger>
<AccordionContent>
<div className="flex flex-col items-baseline space-y-4 mt-4">
<a
href="https://docs.astria.org/flame/flame-mainnet-alpha"
target="_blank"
rel="noreferrer"
className="font-medium text-grey-light text-base"
>
Flame
</a>
<a
href="https://docs.astria.org/overview/introduction"
target="_blank"
rel="noreferrer"
className="font-medium text-grey-light text-base"
>
Learn
</a>
<a
href="https://docs.astria.org/developer/astria-go/astria-go-installation"
target="_blank"
rel="noreferrer"
className="font-medium text-grey-light text-base"
>
Developers
</a>
</div>
</AccordionContent>
</AccordionItem>
<AccordionItem value="company-details" className="border-b-0">
<AccordionTrigger className="no-underline hover:no-underline flex items-center justify-start p-0 [&>svg]:h-6 [&>svg]:w-6">
<div className="text-white text-base font-semibold mr-1 mb-1">
Company
</div>
</AccordionTrigger>
<AccordionContent>
<div className="flex flex-col items-baseline space-y-4 mt-4">
<a
href="https://www.astria.org/about"
target="_blank"
rel="noreferrer"
className="font-medium text-grey-light text-base"
>
About
</a>
<a
href="https://job-boards.greenhouse.io/astria"
target="_blank"
rel="noreferrer"
className="font-medium text-grey-light text-base"
>
Careers
</a>
<a
href="https://www.astria.org/blog"
target="_blank"
rel="noreferrer"
className="font-medium text-grey-light text-base"
>
Blog
</a>
</div>
</AccordionContent>
</AccordionItem>
</Accordion>
</div>
</DrawerContent>
</Drawer>
</div>
);
}

export default MobileNav;
Loading

0 comments on commit e8e47e6

Please sign in to comment.