-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wallet-ext: copy to clipboard use toast for confirmation feedback
* show a toast instead of scaling the copy icon * move copy to functionality to hooks to reuse it * also removes unused code for rendering sui objects
- Loading branch information
1 parent
778c98c
commit c84fb26
Showing
8 changed files
with
40 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 0 additions & 90 deletions
90
apps/wallet/src/ui/app/components/sui-object/SuiObject.module.scss
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
apps/wallet/src/ui/app/components/sui-object/field/Field.module.scss
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
apps/wallet/src/ui/app/components/sui-object/field/index.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { type MouseEventHandler, useCallback } from 'react'; | ||
import { toast } from 'react-hot-toast'; | ||
|
||
export type CopyOptions = { | ||
copySuccessMessage?: string; | ||
}; | ||
|
||
export function useCopyToClipboard( | ||
textToCopy: string, | ||
{ copySuccessMessage = 'Copied' }: CopyOptions = {} | ||
) { | ||
return useCallback<MouseEventHandler>( | ||
async (e) => { | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
try { | ||
await navigator.clipboard.writeText(textToCopy); | ||
toast.success(copySuccessMessage); | ||
} catch (e) { | ||
// silence clipboard errors | ||
} | ||
}, | ||
[textToCopy, copySuccessMessage] | ||
); | ||
} |