Skip to content

Commit

Permalink
Tong/355 wallet connect component (#473)
Browse files Browse the repository at this point in the history
* feat: connect button refinement

---------

Co-authored-by: jeremy-babylonchain <[email protected]>
  • Loading branch information
supertong and jeremy-babylonlabs authored Dec 23, 2024
1 parent d764a48 commit 3299275
Show file tree
Hide file tree
Showing 11 changed files with 513 additions and 901 deletions.
762 changes: 159 additions & 603 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions public/lock.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/app/assets/bitcoin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/app/assets/cancel-circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
156 changes: 0 additions & 156 deletions src/app/components/Connect/ConnectSmall.tsx

This file was deleted.

108 changes: 0 additions & 108 deletions src/app/components/Connect/ConnectedSmall.tsx

This file was deleted.

12 changes: 8 additions & 4 deletions src/app/components/Hash/Hash.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Text } from "@babylonlabs-io/bbn-core-ui";
import { useEffect, useState } from "react";
import { FiCopy } from "react-icons/fi";
import { IoIosCheckmarkCircle } from "react-icons/io";
Expand All @@ -11,6 +12,7 @@ interface HashProps {
address?: boolean;
small?: boolean;
fullWidth?: boolean;
symbols?: number;
}

export const Hash: React.FC<HashProps> = ({
Expand All @@ -19,6 +21,7 @@ export const Hash: React.FC<HashProps> = ({
address,
small,
fullWidth,
symbols = 8,
}) => {
const [_value, copy] = useCopyToClipboard();
const [copiedText, setCopiedText] = useState("");
Expand All @@ -42,11 +45,12 @@ export const Hash: React.FC<HashProps> = ({
} hover:opacity-100 pointer-events-auto`}
onClick={handleCopy}
>
<p
<Text
variant="body2"
style={{
minWidth: small ? "3.5rem" : "5.5rem",
}}
className={`${fullWidth ? "w-full" : ""}`}
className={`${fullWidth ? "w-full" : ""} text-primary-main`}
>
{copiedText || (
<>
Expand All @@ -56,10 +60,10 @@ export const Hash: React.FC<HashProps> = ({
<span className="font-mono">x</span>
</>
)}
<span>{trim(value)}</span>
<span>{trim(value, symbols)}</span>
</>
)}
</p>
</Text>
{copiedText ? (
<IoIosCheckmarkCircle className="ml-1" />
) : (
Expand Down
34 changes: 4 additions & 30 deletions src/app/components/Header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import { useWalletConnect } from "@babylonlabs-io/bbn-wallet-connect";
import { twJoin } from "tailwind-merge";

import { useBTCWallet } from "@/app/context/wallet/BTCWalletProvider";
import { useAppState } from "@/app/state";
import { shouldDisplayTestingMsg } from "@/config";

import { ConnectedSmall } from "../Connect/ConnectedSmall";
import { ConnectSmall } from "../Connect/ConnectSmall";
import { Logo } from "../Logo/Logo";
import { TestingInfo } from "../TestingInfo/TestingInfo";
import { Connect } from "../Wallet/Connect";

export const Header = () => {
const { connected, disconnect, open } = useWalletConnect();
const { address } = useBTCWallet();
const { totalBalance, isLoading: loading } = useAppState();
const { open } = useWalletConnect();
const { isLoading: loading } = useAppState();

return (
<nav>
Expand All @@ -28,29 +24,7 @@ export const Header = () => {
)}
</div>
<div className="flex items-center gap-4">
<ConnectSmall
connected={connected}
loading={loading}
onConnect={open}
address={address}
btcWalletBalanceSat={totalBalance}
onDisconnect={disconnect}
/>
{/* <ThemeToggle /> */}
</div>
<div
className={twJoin(
address && "justify-end p-6 pt-0",
"container mx-auto flex w-full items-center gap-4 md:hidden md:p-0",
)}
>
<ConnectedSmall
connected={connected}
loading={loading}
address={address}
btcWalletBalanceSat={totalBalance}
onDisconnect={disconnect}
/>
<Connect loading={loading} onConnect={open} />
</div>
</div>
</section>
Expand Down
Loading

0 comments on commit 3299275

Please sign in to comment.