Skip to content
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

fix: UI and add toast for address copy #133

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions src/components/Atoms/Address/Address.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,45 @@
import { copyToClipboard, truncate } from "@/utils/functions";
import { IconWrapper } from "@/components/Shared";
import { type AddressProps } from "@/utils/types/atoms.types";
import { toast } from "@/utils/hooks/use-toast";
import { useState } from "react";

export const Address: React.FC<AddressProps> = ({ address }) => {
const [showCopy, setShowCopy] = useState(false);

const handleCopyClick = () => {
toast({
description: "Address copied!",
});
setShowCopy(true);
setTimeout(() => {
setShowCopy(false);
}, 3000);
};

return (
<div className="flex items-center gap-x-2">
<p>{truncate(address)}</p>
<button
className="cursor-pointer"
onClick={() => copyToClipboard(address)}
onClick={() => {
copyToClipboard(address);
}}
>
<IconWrapper
icon_class_name="content_copy"
icon_size="text-sm"
class_name="text-secondary dark:text-secondary"
/>
{showCopy ? (
<IconWrapper
icon_class_name="done"
icon_size="text-sm"
class_name="text-secondary dark:text-secondary"
/>
) : (
<IconWrapper
icon_class_name="content_copy"
icon_size="text-sm"
class_name="text-secondary dark:text-secondary"
on_click={() => handleCopyClick()}
/>
)}
</button>
</div>
);
Expand Down
Loading