Skip to content

Commit

Permalink
feat: streamline copy value and address
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Jan 28, 2025
1 parent 8181342 commit 1f07d98
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .changeset/forty-shoes-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'explorer': minor
'hostd': minor
'renterd': minor
'walletd': minor
---

Displayed entity values which are often truncated can now be copied to clipboard by double-clicking directly on the visible characters.
7 changes: 7 additions & 0 deletions .changeset/quick-lobsters-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'hostd': minor
'renterd': minor
'walletd': minor
---

Wallet addresses can now be copied to clipboard by clicking on the QR code in the address dialog.
5 changes: 5 additions & 0 deletions .changeset/swift-bears-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@siafoundation/design-system': minor
---

ValueCopyable now supports double click to copy to clipboard.
10 changes: 8 additions & 2 deletions libs/design-system/src/app/WalletAddressCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Heading } from '../core/Heading'
import { Text } from '../core/Text'
import { ValueCopyable } from '../components/ValueCopyable'
import QRCode from 'react-qr-code'
import { useCallback } from 'react'
import { copyToClipboard } from '../lib/clipboard'

type Props = {
title?: string
Expand All @@ -10,6 +12,10 @@ type Props = {
}

export function WalletAddressCode({ title, description, address }: Props) {
const copy = useCallback(() => {
copyToClipboard(address, 'address')
}, [address])

return (
<div className="flex flex-col gap-4 items-center justify-center">
{title && (
Expand All @@ -18,8 +24,8 @@ export function WalletAddressCode({ title, description, address }: Props) {
</Heading>
)}
{description && <Text>{description}</Text>}
<div className="relative p-[5px] bg-white h-[210px] w-[210px]">
<div className="absolute">
<div className="relative p-[5px] bg-white h-[210px] w-[210px] hover:outline hover:outline-4 hover:outline-blue-500">
<div onClick={copy} className="absolute cursor-pointer">
<QRCode size={200} value={address} />
</div>
</div>
Expand Down
7 changes: 7 additions & 0 deletions libs/design-system/src/components/ValueCopyable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ export function ValueCopyable({
weight={weight}
font={font}
ellipsis
onDoubleClick={(e) => {
e.preventDefault()
copyToClipboard(cleanValue, label)
}}
>
{text}
</Link>
Expand All @@ -89,6 +93,9 @@ export function ValueCopyable({
weight={weight}
font={font}
ellipsis
onDoubleClick={() => {
copyToClipboard(cleanValue, label)
}}
>
{text}
</Text>
Expand Down

0 comments on commit 1f07d98

Please sign in to comment.