Skip to content

Commit

Permalink
[Dashboard] Remove AddressCopyButton (#5077)
Browse files Browse the repository at this point in the history
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on removing the `AddressCopyButton` component from various files and replacing it with `CopyTextButton` and `CopyAddressButton` components to optimize bundle size and improve code consistency.

### Detailed summary
- Deleted `AddressCopyButton.tsx` file.
- Removed all imports of `AddressCopyButton` from multiple files.
- Replaced instances of `AddressCopyButton` with `CopyTextButton` in `webhooks-table.tsx` and `token-id.tsx`.
- Replaced `AddressCopyButton` with `CopyAddressButton` in `transaction-timeline.tsx` and `contract-subscriptions-table.tsx`.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
  • Loading branch information
kien-ngo committed Oct 19, 2024
1 parent a68830c commit f2d1085
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { getNFT as getErc1155NFT } from "thirdweb/extensions/erc1155";
import { useReadContract } from "thirdweb/react";
import { resolveScheme } from "thirdweb/storage";
import { Badge, Button, Card, CodeBlock, Heading, Text } from "tw-components";
import { AddressCopyButton } from "tw-components/AddressCopyButton";
import { NFTMediaWithEmptyState } from "tw-components/nft-media";
import { shortenString } from "utils/usedapp-external";
import { NftProperty } from "../components/nft-property";
Expand Down Expand Up @@ -210,10 +209,11 @@ export const TokenIdPage: React.FC<TokenIdPageProps> = ({
<Heading size="label.md">Token ID</Heading>
</GridItem>
<GridItem colSpan={8}>
<AddressCopyButton
size="xs"
address={nft.id?.toString()}
title="Token ID"
<CopyTextButton
textToCopy={nft.id?.toString()}
textToShow={nft.id?.toString()}
tooltip="Token ID"
copyIconPosition="right"
/>
</GridItem>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CopyTextButton } from "@/components/ui/CopyTextButton";
import {
type EngineWebhook,
useEngineRevokeWebhook,
Expand All @@ -23,7 +24,7 @@ import { useTxNotifications } from "hooks/useTxNotifications";
import { Trash2Icon } from "lucide-react";
import { useState } from "react";
import { Button, Card, FormLabel, Text } from "tw-components";
import { AddressCopyButton } from "tw-components/AddressCopyButton";
import { shortenString } from "utils/usedapp-external";

export function beautifyString(str: string): string {
return str
Expand Down Expand Up @@ -58,10 +59,11 @@ const columns = [
header: "Secret",
cell: (cell) => {
return (
<AddressCopyButton
address={cell.getValue() || ""}
title="secret"
size="xs"
<CopyTextButton
textToCopy={cell.getValue() || ""}
textToShow={shortenString(cell.getValue() || "")}
tooltip="Secret"
copyIconPosition="right"
/>
);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";

import { CopyAddressButton } from "@/components/ui/CopyAddressButton";
import { useThirdwebClient } from "@/constants/thirdweb.client";
import {
type EngineContractSubscription,
Expand Down Expand Up @@ -34,7 +35,6 @@ import { useState } from "react";
import { eth_getBlockByNumber, getRpcClient } from "thirdweb";
import { shortenAddress as shortenAddresThrows } from "thirdweb/utils";
import { Button, Card, FormLabel, LinkButton, Text } from "tw-components";
import { AddressCopyButton } from "../../../tw-components/AddressCopyButton";

function shortenAddress(address: string) {
if (!address) {
Expand Down Expand Up @@ -93,9 +93,9 @@ export const ContractSubscriptionTable: React.FC<
const explorer = chain?.explorers?.[0];
if (!explorer) {
return (
<AddressCopyButton
<CopyAddressButton
address={cell.getValue()}
title="Contract address"
copyIconPosition="right"
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { WalletAddress } from "@/components/blocks/wallet-address";
import { CopyAddressButton } from "@/components/ui/CopyAddressButton";
import type { Transaction } from "@3rdweb-sdk/react/hooks/useEngine";
import { useLoggedInUser } from "@3rdweb-sdk/react/hooks/useLoggedInUser";
import {
Expand All @@ -22,7 +23,6 @@ import { useTxNotifications } from "hooks/useTxNotifications";
import { CheckIcon } from "lucide-react";
import { useRef } from "react";
import { Button, FormLabel, Text } from "tw-components";
import { AddressCopyButton } from "tw-components/AddressCopyButton";

interface TimelineStep {
step: string;
Expand Down Expand Up @@ -242,10 +242,9 @@ const CancelTransactionButton = ({
</FormControl>
<FormControl>
<FormLabel>To</FormLabel>
<AddressCopyButton
<CopyAddressButton
address={transaction.toAddress ?? ""}
size="xs"
shortenAddress={false}
copyIconPosition="right"
/>
</FormControl>
<FormControl>
Expand Down
99 changes: 0 additions & 99 deletions apps/dashboard/src/tw-components/AddressCopyButton.tsx

This file was deleted.

6 changes: 0 additions & 6 deletions apps/dashboard/src/tw-components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,3 @@ export * from "./link";
export * from "./menu";
export * from "./table-container";
export * from "./text";

/**
* ❗️❗️❗️ @DANGER
* Do not export `AddressCopyButton` from here
* It will result in a HUGE bundle size
*/

0 comments on commit f2d1085

Please sign in to comment.