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

feat: copy address icon transition to check mark after clicking on it #140

Merged
merged 2 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion packages/circle-react-elements/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@circle-libs/react-elements",
"version": "0.1.0",
"version": "0.1.1",
"description": "React components compatible with Circle SDK",
"keywords": [
"react",
Expand Down
21 changes: 15 additions & 6 deletions packages/circle-react-elements/src/NextJsGuide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -613,12 +613,21 @@ Update the wallet set list page at `src/app/page.tsx` by including a link to the
// Add the following import
import Link from 'next/link';

// Extend the WalletSetDetails component with a link to the wallet set page
<WalletSetDetails walletSet={walletSet}>
<Link href={`/wallets/${walletSet.id}`} className="text-blue-500 hover:underline">
Show Wallets
</Link>
</WalletSetDetails>;
// Update the WalletSets component
export default function WalletSets() {
// Existing code

return (
// Existing code

// Extend the WalletSetDetails component with a link to the wallet set page
<WalletSetDetails walletSet={walletSet}>
<Link href={`/wallets/${walletSet.id}`} className="text-blue-500 hover:underline">
Show Wallets
</Link>
</WalletSetDetails>
);
}
```

And that's it! You've successfully implemented wallet creation and listing within a wallet set. Go back to your development server and navigate to the wallet set page to see the new features in action.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AccountType } from '@circle-fin/developer-controlled-wallets';
import makeBlockie from 'ethereum-blockies-base64';
import { Copy } from 'lucide-react';
import { useMemo } from 'react';
import { Check, Copy } from 'lucide-react';
import { useMemo, useState } from 'react';

import { Badge } from '~/components/ui/badge';
import { Button } from '~/components/ui/button';
Expand Down Expand Up @@ -52,17 +52,19 @@ const ACCOUNT_TYPE_TO_TEXT: Record<AccountType, string> = {
* - Displays shortened wallet address with copy button
* - Shows blockchain network with icon
* - Supports custom child components for extensibility
* - Address clipboard copy with optional callback
* - Responsive layout with consistent spacing
* - Uses design system components (Badge, Button)
* - Full address available in tooltip
*/
export function WalletDetails({ wallet, onAddressCopy, children }: WalletDetailsProps) {
const shortAddress = useMemo(() => shortenAddress(wallet.address), [wallet]);
const walletImage = useMemo(() => makeBlockie(wallet.address), [wallet]);
const [copied, setCopied] = useState(false);

const copyToClipboard = () => {
void navigator.clipboard.writeText(wallet.address);
setCopied(true);

setTimeout(() => setCopied(false), 2000); // Reset after 2 seconds

if (typeof onAddressCopy === 'function') {
onAddressCopy(wallet.address);
}
Expand All @@ -88,7 +90,11 @@ export function WalletDetails({ wallet, onAddressCopy, children }: WalletDetails
</span>

<Button onClick={copyToClipboard} variant="ghost" size="sm">
<Copy size={16} strokeWidth={1} />
{copied ? (
<Check size={16} strokeWidth={1} />
) : (
<Copy size={16} strokeWidth={1} />
)}
</Button>
</p>

Expand Down