Skip to content

Commit

Permalink
fix: copy to clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Jan 2, 2024
1 parent 96cae6d commit 0fc1c36
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
10 changes: 10 additions & 0 deletions .changeset/khaki-badgers-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'website': minor
'@siafoundation/design-system': minor
'explorer': minor
'hostd': minor
'renterd': minor
'walletd': minor
---

Fixed an issue with the copy to clipboard feature.
1 change: 1 addition & 0 deletions libs/design-system/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"@visx/tooltip": "^2.17.0",
"@visx/event": "^2.17.0",
"d3-array": "^3.1.6",
"clipboard-polyfill": "^4.0.1",
"@visx/xychart": "^2.18.0",
"react-dropzone": "^14.2.3",
"@radix-ui/react-radio-group": "^1.0.0",
Expand Down
5 changes: 3 additions & 2 deletions libs/design-system/src/lib/clipboard.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React from 'react'
import * as clipboard from 'clipboard-polyfill'
import { ToastOptions, triggerToast, triggerToastNode } from './toast'

export const copyToClipboard = (text: string, entity?: string) => {
const message = entity
? `Copied ${entity} to clipboard`
: 'Copied to clipboard'
triggerToast(message)
navigator.clipboard.writeText(text)
clipboard.writeText(text)
}

export const copyToClipboardCustom = (
Expand All @@ -15,5 +16,5 @@ export const copyToClipboardCustom = (
options?: ToastOptions
) => {
triggerToastNode(message, options)
navigator.clipboard.writeText(text)
clipboard.writeText(text)
}
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"bignumber.js": "^9.0.2",
"blakejs": "^1.2.1",
"class-variance-authority": "^0.7.0",
"clipboard-polyfill": "^4.0.1",
"cmdk": "^0.2.0",
"cobe": "^0.6.3",
"core-js": "^3.6.5",
Expand Down

0 comments on commit 0fc1c36

Please sign in to comment.