-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Michael/agora 1686 copy addresses when clicking on 0x5f4 shorten addresses UI #246
Merged
mcgingras
merged 6 commits into
main
from
michael/agora-1686-copy-addresses-when-clicking-on-0x5f4-shorten-addresses-ui
Apr 23, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6c6aa3d
Adds improvement to copy delegate address to clipboard when clicking …
mcgingras edc0681
Adds CopyableHumanAddress which shows a human readable address which …
mcgingras 67c8703
Adds copyable flag to DelegateProfileImage to prevent copy functional…
mcgingras a6f7366
Runs prettier on AGORA-1686 code changes
mcgingras 6a5dedb
Fixes vercel build issue on copy-pasteable delegate branch
mcgingras c84f0cf
Adds thicker clipboard icon
mcgingras File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
"use client"; | ||
|
||
import React, { useState, useEffect } from "react"; | ||
import Image from "next/image"; | ||
import ENSName from "./ENSName"; // adjust the import path as per your project structure | ||
import { HStack } from "@/components/Layout/Stack"; | ||
import { CheckCircleIcon } from "@heroicons/react/20/solid"; | ||
import { icons } from "@/icons/icons"; | ||
|
||
// This component will display the ENS name for a given address | ||
// It will also be copyable, meaning that when clicked, it will copy the address to the clipboard | ||
// It will also show a checkmark when the address has been copied | ||
function CopyableHumanAddress({ address }: { address: string }) { | ||
const [isInCopiedState, setIsInCopiedState] = useState<boolean>(false); | ||
|
||
useEffect(() => { | ||
let id: NodeJS.Timeout | number | null = null; | ||
if (isInCopiedState) { | ||
id = setTimeout(() => { | ||
setIsInCopiedState(false); | ||
}, 750); | ||
} | ||
return () => { | ||
if (id) clearTimeout(id); | ||
}; | ||
}, [isInCopiedState]); | ||
|
||
return ( | ||
<HStack | ||
alignItems="items-center" | ||
className="cursor-pointer group" | ||
gap={1} | ||
onClick={(e) => { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
navigator.clipboard.writeText(address); | ||
setIsInCopiedState(true); | ||
}} | ||
> | ||
<ENSName address={address} /> | ||
{isInCopiedState ? ( | ||
<CheckCircleIcon className="text-green-600 w-4 h-4" /> | ||
) : ( | ||
<Image | ||
src={icons.clipboard} | ||
alt={"clipboard icon"} | ||
className="w-4 h-4 hidden group-hover:block group-hover:opacity-90" | ||
/> | ||
)} | ||
</HStack> | ||
); | ||
} | ||
|
||
export default CopyableHumanAddress; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found myself wanting to add onClick to an
HStack
and was about to wrap it in a div so I could add an onClick to the div wrapping it. But then I figured theHStack
is just a div itself... theres no reason it shouldn't just accept an onClick prop. So I'm adding it here... if we don't like this I can take it out!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol i've been here a thousand times. i've been out of the code base long enough that i've forgotten we don't have a click handler on stack. guess it's to keep it to a positioning only thing
(please don't mind anything i say on this tho, i'm just a tourist in eng lol)