Skip to content

Commit

Permalink
[Dashboard] Remove tw-components Button from contract action-buttons (#…
Browse files Browse the repository at this point in the history
…5369)

## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on refactoring the button components across various files to standardize the usage of the `Button` component from the `@/components/ui/button` module, updating properties for consistency, and improving the UI elements.

### Detailed summary
- Replaced `Button` imports from `tw-components` with `@/components/ui/button`.
- Changed `colorScheme` to `variant` for button styling.
- Updated `isDisabled` to `disabled` for button state management.
- Added `className="gap-2"` for consistent spacing.
- Modified button content to include icons before text.

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

<!-- end pr-codex -->
  • Loading branch information
kien-ngo committed Nov 11, 2024
1 parent 8c1fa1b commit a1b518c
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 81 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";

import { Button } from "@/components/ui/button";
import {
Sheet,
SheetContent,
Expand All @@ -17,7 +18,6 @@ import type { ThirdwebContract } from "thirdweb";
import * as ERC721Ext from "thirdweb/extensions/erc721";
import * as ERC1155Ext from "thirdweb/extensions/erc1155";
import { useReadContract, useSendAndConfirmTransaction } from "thirdweb/react";
import { Button } from "tw-components";

interface BatchLazyMintButtonProps {
canCreateDelayedRevealBatch: boolean;
Expand Down Expand Up @@ -55,10 +55,8 @@ export const BatchLazyMintButton: React.FC<BatchLazyMintButtonProps> = ({
<MinterOnly contract={contract}>
<Sheet onOpenChange={setOpen} open={open}>
<SheetTrigger asChild>
<Button
colorScheme="primary"
leftIcon={<FileStackIcon className="size-4" />}
>
<Button variant="primary" className="gap-2">
<FileStackIcon className="size-4" />
Batch Upload
</Button>
</SheetTrigger>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";

import { Button } from "@/components/ui/button";
import {
Sheet,
SheetContent,
Expand All @@ -18,7 +19,6 @@ import { type ThirdwebContract, ZERO_ADDRESS } from "thirdweb";
import { getApprovalForTransaction } from "thirdweb/extensions/erc20";
import { claimTo } from "thirdweb/extensions/erc721";
import { useActiveAccount, useSendAndConfirmTransaction } from "thirdweb/react";
import { Button } from "tw-components";
import { FormErrorMessage, FormHelperText, FormLabel } from "tw-components";

const CLAIM_FORM_ID = "nft-claim-form";
Expand All @@ -45,8 +45,8 @@ export const NFTClaimButton: React.FC<NFTClaimButtonProps> = ({ contract }) => {
return (
<Sheet open={open} onOpenChange={setOpen}>
<SheetTrigger asChild>
<Button colorScheme="primary" leftIcon={<GemIcon className="size-4" />}>
Claim
<Button variant="primary" className="gap-2">
<GemIcon className="size-4" /> Claim
</Button>
</SheetTrigger>
<SheetContent className="overflow-y-auto sm:w-[540px] sm:max-w-[90%] lg:w-[700px]">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"use client";
import { Button } from "@/components/ui/button";
import {
Sheet,
SheetContent,
Expand All @@ -10,7 +11,6 @@ import { MinterOnly } from "@3rdweb-sdk/react/components/roles/minter-only";
import { PlusIcon } from "lucide-react";
import { useState } from "react";
import type { ThirdwebContract } from "thirdweb";
import { Button } from "tw-components";
import { LazyMintNftForm } from "./lazy-mint-form";

interface NFTLazyMintButtonProps {
Expand All @@ -28,11 +28,8 @@ export const NFTLazyMintButton: React.FC<NFTLazyMintButtonProps> = ({
<MinterOnly contract={contract}>
<Sheet open={open} onOpenChange={setOpen}>
<SheetTrigger asChild>
<Button
colorScheme="primary"
leftIcon={<PlusIcon className="size-5" />}
{...restButtonProps}
>
<Button variant="primary" className="gap-2" {...restButtonProps}>
<PlusIcon className="size-5" />
Single Upload
</Button>
</SheetTrigger>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";

import { Button } from "@/components/ui/button";
import {
Accordion,
AccordionButton,
Expand All @@ -25,7 +26,6 @@ import { lazyMint as lazyMint721 } from "thirdweb/extensions/erc721";
import { lazyMint as lazyMint1155 } from "thirdweb/extensions/erc1155";
import { useActiveAccount, useSendAndConfirmTransaction } from "thirdweb/react";
import {
Button,
FormErrorMessage,
FormHelperText,
FormLabel,
Expand Down Expand Up @@ -313,9 +313,9 @@ export const LazyMintNftForm: React.FC<LazyMintNftFormParams> = ({
</form>
<div className="mt-8 flex flex-row justify-end gap-3">
<Button
isDisabled={sendAndConfirmTx.isPending}
disabled={sendAndConfirmTx.isPending}
variant="outline"
mr={3}
className="mr-3"
onClick={() => setOpen(false)}
>
Cancel
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";

import { Button } from "@/components/ui/button";
import {
Sheet,
SheetContent,
Expand All @@ -11,7 +12,6 @@ import { MinterOnly } from "@3rdweb-sdk/react/components/roles/minter-only";
import { PlusIcon } from "lucide-react";
import { useState } from "react";
import type { ThirdwebContract } from "thirdweb";
import { Button } from "tw-components";
import { NFTMintForm } from "./mint-form";

interface NFTMintButtonProps {
Expand All @@ -30,11 +30,8 @@ export const NFTMintButton: React.FC<NFTMintButtonProps> = ({
<MinterOnly contract={contract}>
<Sheet open={open} onOpenChange={setOpen}>
<SheetTrigger asChild>
<Button
colorScheme="primary"
leftIcon={<PlusIcon className="size-5" />}
{...restButtonProps}
>
<Button variant="primary" className="gap-2" {...restButtonProps}>
<PlusIcon className="size-5" />
Mint
</Button>
</SheetTrigger>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";

import { Button } from "@/components/ui/button";
import {
Sheet,
SheetContent,
Expand All @@ -18,7 +19,7 @@ import { toast } from "sonner";
import type { ThirdwebContract } from "thirdweb";
import { getBatchesToReveal, reveal } from "thirdweb/extensions/erc721";
import { useReadContract, useSendAndConfirmTransaction } from "thirdweb/react";
import { Button, FormErrorMessage, FormLabel } from "tw-components";
import { FormErrorMessage, FormLabel } from "tw-components";

interface NFTRevealButtonProps {
contract: ThirdwebContract;
Expand Down Expand Up @@ -48,11 +49,8 @@ export const NFTRevealButton: React.FC<NFTRevealButtonProps> = ({
<MinterOnly contract={contract}>
<Sheet open={open} onOpenChange={setOpen}>
<SheetTrigger asChild>
<Button
colorScheme="primary"
leftIcon={<EyeIcon className="size-4" />}
>
Reveal NFTs
<Button variant="primary" className="gap-2">
<EyeIcon className="size-4" /> Reveal NFTs
</Button>
</SheetTrigger>
<SheetContent className="w-full overflow-y-auto sm:min-w-[540px] lg:min-w-[700px]">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"use client";
import { Button } from "@/components/ui/button";
import {
Sheet,
SheetContent,
Expand All @@ -10,7 +11,6 @@ import { MinterOnly } from "@3rdweb-sdk/react/components/roles/minter-only";
import { PlusIcon } from "lucide-react";
import { useState } from "react";
import type { ThirdwebContract } from "thirdweb";
import { Button } from "tw-components";
import { SharedMetadataForm } from "./shared-metadata-form";

interface NFTSharedMetadataButtonProps {
Expand All @@ -25,12 +25,8 @@ export const NFTSharedMetadataButton: React.FC<
<MinterOnly contract={contract}>
<Sheet open={open} onOpenChange={setOpen}>
<SheetTrigger asChild>
<Button
colorScheme="primary"
leftIcon={<PlusIcon className="size-5" />}
{...restButtonProps}
>
Set NFT Metadata
<Button variant="primary" className="gap-2" {...restButtonProps}>
<PlusIcon className="size-5" /> Set NFT Metadata
</Button>
</SheetTrigger>
<SheetContent className="w-full overflow-y-auto sm:min-w-[540px] lg:min-w-[700px]">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"use client";

import { Button } from "@/components/ui/button";
import { useSplitDistributeFunds } from "@3rdweb-sdk/react/hooks/useSplit";
import { MismatchButton } from "components/buttons/MismatchButton";
import { TransactionButton } from "components/buttons/TransactionButton";
import { useTrack } from "hooks/analytics/useTrack";
import { useTxNotifications } from "hooks/useTxNotifications";
import { useMemo } from "react";
import type { ThirdwebContract } from "thirdweb";
import { Button } from "tw-components";
import type { Balance } from "../ContractSplitPage";

interface DistributeButtonProps {
Expand Down Expand Up @@ -90,7 +90,7 @@ export const DistributeButton: React.FC<DistributeButtonProps> = ({

if (numTransactions === 0) {
return (
<Button isDisabled colorScheme="primary" {...restButtonProps}>
<Button disabled variant="primary" {...restButtonProps}>
Nothing to distribute
</Button>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
"use client";

import { Button } from "@/components/ui/button";
import {
Sheet,
SheetContent,
SheetHeader,
SheetTitle,
SheetTrigger,
} from "@/components/ui/sheet";
import { Droplet } from "lucide-react";
import { DropletIcon } from "lucide-react";
import { useState } from "react";
import type { ThirdwebContract } from "thirdweb";
import { balanceOf } from "thirdweb/extensions/erc20";
import { useActiveAccount, useReadContract } from "thirdweb/react";
import { Button } from "tw-components";
import { TokenAirdropForm } from "./airdrop-form";
interface TokenAirdropButtonProps {
contract: ThirdwebContract;
Expand All @@ -33,12 +33,12 @@ export const TokenAirdropButton: React.FC<TokenAirdropButtonProps> = ({
<Sheet open={open} onOpenChange={setOpen}>
<SheetTrigger asChild>
<Button
colorScheme="primary"
leftIcon={<Droplet size={16} />}
variant="primary"
{...restButtonProps}
isDisabled={!hasBalance}
disabled={!hasBalance}
className="gap-2"
>
Airdrop
<DropletIcon size={16} /> Airdrop
</Button>
</SheetTrigger>
<SheetContent className="w-full overflow-y-auto sm:min-w-[540px] lg:min-w-[700px]">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";

import { Button } from "@/components/ui/button";
import {
Sheet,
SheetContent,
Expand All @@ -23,7 +24,6 @@ import {
useSendAndConfirmTransaction,
} from "thirdweb/react";
import {
Button,
FormErrorMessage,
FormHelperText,
FormLabel,
Expand Down Expand Up @@ -59,12 +59,12 @@ export const TokenBurnButton: React.FC<TokenBurnButtonProps> = ({
<Sheet open={open} onOpenChange={setOpen}>
<SheetTrigger asChild>
<Button
colorScheme="primary"
leftIcon={<Flame size={16} />}
variant="primary"
{...restButtonProps}
isDisabled={!hasBalance}
disabled={!hasBalance}
className="gap-2"
>
Burn
<Flame size={16} /> Burn
</Button>
</SheetTrigger>
<SheetContent className="z-[10000]">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";

import { Button } from "@/components/ui/button";
import {
Sheet,
SheetContent,
Expand All @@ -11,7 +12,7 @@ import {
import { FormControl, Input } from "@chakra-ui/react";
import { TransactionButton } from "components/buttons/TransactionButton";
import { useTrack } from "hooks/analytics/useTrack";
import { Gem } from "lucide-react";
import { GemIcon } from "lucide-react";
import { useState } from "react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
Expand All @@ -22,12 +23,7 @@ import {
useReadContract,
useSendAndConfirmTransaction,
} from "thirdweb/react";
import {
Button,
FormErrorMessage,
FormHelperText,
FormLabel,
} from "tw-components";
import { FormErrorMessage, FormHelperText, FormLabel } from "tw-components";

interface TokenClaimButtonProps {
contract: ThirdwebContract;
Expand All @@ -52,12 +48,8 @@ export const TokenClaimButton: React.FC<TokenClaimButtonProps> = ({
return (
<Sheet open={open} onOpenChange={setOpen}>
<SheetTrigger asChild>
<Button
colorScheme="primary"
leftIcon={<Gem size={16} />}
{...restButtonProps}
>
Claim
<Button variant="primary" className="gap-2" {...restButtonProps}>
<GemIcon size={16} /> Claim
</Button>
</SheetTrigger>
<SheetContent className="z-[10000]">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";

import { Button } from "@/components/ui/button";
import {
Sheet,
SheetContent,
Expand All @@ -12,7 +13,7 @@ import { MinterOnly } from "@3rdweb-sdk/react/components/roles/minter-only";
import { FormControl, Input } from "@chakra-ui/react";
import { TransactionButton } from "components/buttons/TransactionButton";
import { useTrack } from "hooks/analytics/useTrack";
import { Plus } from "lucide-react";
import { PlusIcon } from "lucide-react";
import { useState } from "react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
Expand All @@ -23,7 +24,7 @@ import {
useReadContract,
useSendAndConfirmTransaction,
} from "thirdweb/react";
import { Button, FormErrorMessage, FormLabel } from "tw-components";
import { FormErrorMessage, FormLabel } from "tw-components";

interface TokenMintButtonProps {
contract: ThirdwebContract;
Expand All @@ -50,12 +51,8 @@ export const TokenMintButton: React.FC<TokenMintButtonProps> = ({
<MinterOnly contract={contract}>
<Sheet open={open} onOpenChange={setOpen}>
<SheetTrigger asChild>
<Button
colorScheme="primary"
leftIcon={<Plus size={16} />}
{...restButtonProps}
>
Mint
<Button variant="primary" {...restButtonProps} className="gap-2">
<PlusIcon size={16} /> Mint
</Button>
</SheetTrigger>
<SheetContent className="z-[10000]">
Expand Down
Loading

0 comments on commit a1b518c

Please sign in to comment.