From 5cddbd7f59c470a759965772c70112f6294b0402 Mon Sep 17 00:00:00 2001 From: Andreas Greimel Date: Tue, 12 Nov 2024 16:53:25 +0100 Subject: [PATCH] Only show an icon button to copy the asset ID --- src/components/CopyBox.tsx | 28 ++++------------------------ src/components/CopyButton.tsx | 30 ++++++++++++++++++++++++++++++ src/components/Header.tsx | 2 +- src/pages/Token.tsx | 17 +++++++++++------ 4 files changed, 46 insertions(+), 31 deletions(-) create mode 100644 src/components/CopyButton.tsx diff --git a/src/components/CopyBox.tsx b/src/components/CopyBox.tsx index 204ab1a..52605dd 100644 --- a/src/components/CopyBox.tsx +++ b/src/components/CopyBox.tsx @@ -1,22 +1,10 @@ -import { writeText } from '@tauri-apps/plugin-clipboard-manager'; -import { CopyCheckIcon, CopyIcon } from 'lucide-react'; -import { useState } from 'react'; -import { Button } from './ui/button'; +import { CopyButton } from './CopyButton'; export function CopyBox(props: { title: string; content: string; className?: string; }) { - const [copied, setCopied] = useState(false); - - const copyAddress = () => { - writeText(props.content); - - setCopied(true); - setTimeout(() => setCopied(false), 2000); - }; - return (
- + />
); } diff --git a/src/components/CopyButton.tsx b/src/components/CopyButton.tsx new file mode 100644 index 0000000..b81d071 --- /dev/null +++ b/src/components/CopyButton.tsx @@ -0,0 +1,30 @@ +import { writeText } from '@tauri-apps/plugin-clipboard-manager'; +import { CopyCheckIcon, CopyIcon } from 'lucide-react'; +import { useState } from 'react'; +import { Button } from './ui/button'; + +export function CopyButton(props: { value: string; className?: string }) { + const [copied, setCopied] = useState(false); + + const copyAddress = () => { + writeText(props.value); + + setCopied(true); + setTimeout(() => setCopied(false), 2000); + }; + + return ( + + ); +} diff --git a/src/components/Header.tsx b/src/components/Header.tsx index a93fda5..31a5afc 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -11,7 +11,7 @@ import { Sheet, SheetContent, SheetTrigger } from './ui/sheet'; export default function Header( props: PropsWithChildren<{ - title: string; + title: string | ReactNode; back?: () => void; children?: ReactNode; }>, diff --git a/src/pages/Token.tsx b/src/pages/Token.tsx index 95ab33e..6f634b1 100644 --- a/src/pages/Token.tsx +++ b/src/pages/Token.tsx @@ -1,7 +1,6 @@ import CoinList from '@/components/CoinList'; import ConfirmationDialog from '@/components/ConfirmationDialog'; import Container from '@/components/Container'; -import { CopyBox } from '@/components/CopyBox'; import Header from '@/components/Header'; import { ReceiveAddress } from '@/components/ReceiveAddress'; import { Button } from '@/components/ui/button'; @@ -53,6 +52,7 @@ import { events, TransactionSummary, } from '../bindings'; +import { CopyButton } from '@/components/CopyButton'; export default function Token() { const navigate = useNavigate(); @@ -174,13 +174,18 @@ export default function Token() { return ( <> -
+
+ {asset ? (asset.name ?? 'Unknown asset') : ''}{' '} + {asset?.asset_id !== 'xch' && ( + + )} + + } + />
- {asset?.asset_id !== 'xch' && ( - - )} -