From 8c1fa1b7b463cbdc42480687e60f66976c0cde58 Mon Sep 17 00:00:00 2001 From: kien-ngo Date: Mon, 11 Nov 2024 00:09:20 +0000 Subject: [PATCH] [Dashboard] Remove tw-components from claim condition UI (#5368) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Problem solved Short description of the bug fixed or feature added --- ## PR-Codex overview This PR focuses on improving the user interface and functionality of the `claim-conditions` components in the dashboard application. It enhances accessibility, updates styling, and refines the input handling for claim conditions. ### Detailed summary - Updated `MaxClaimablePerWalletInput` to use `className` for styling and added a `target` attribute to the `Link`. - Simplified `CustomFormControl` by replacing `Heading` with `FormLabel`. - Changed `Text` components to `p` tags in `PricePreview` for better semantic structure. - Refactored `QuantityInputWithUnlimited` to use new UI components and improved props handling. - Enhanced `ClaimConditionsPhase` layout with Tailwind CSS classes, replacing Chakra UI components. - Updated button styles and functionalities, including the removal button and editing toggle. - Improved readability and structure of the phase details display. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` --- .../Inputs/MaxClaimablePerWalletInput.tsx | 6 +- .../claim-conditions-form/common.tsx | 11 +- .../claim-conditions-form/phase.tsx | 196 +++++++++--------- .../claim-conditions/price-preview.tsx | 11 +- .../quantity-input-with-unlimited.tsx | 49 ++--- 5 files changed, 128 insertions(+), 145 deletions(-) diff --git a/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/claim-conditions-form/Inputs/MaxClaimablePerWalletInput.tsx b/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/claim-conditions-form/Inputs/MaxClaimablePerWalletInput.tsx index fb20e0dfa6c..ced8b660476 100644 --- a/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/claim-conditions-form/Inputs/MaxClaimablePerWalletInput.tsx +++ b/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/claim-conditions-form/Inputs/MaxClaimablePerWalletInput.tsx @@ -1,4 +1,4 @@ -import { Link } from "tw-components"; +import Link from "next/link"; import { QuantityInputWithUnlimited } from "../../quantity-input-with-unlimited"; import { CustomFormControl } from "../common"; import { useClaimConditionsFormContext } from "../index"; @@ -41,8 +41,8 @@ export const MaxClaimablePerWalletInput: React.FC = () => { Limits are set per wallets and not per user, sophisticated actors could get around wallet restrictions.{" "} Learn more diff --git a/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/claim-conditions-form/common.tsx b/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/claim-conditions-form/common.tsx index d0b9d96e3ae..edeebd7b604 100644 --- a/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/claim-conditions-form/common.tsx +++ b/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/claim-conditions-form/common.tsx @@ -1,11 +1,6 @@ import { Flex, FormControl } from "@chakra-ui/react"; import type { FieldError } from "react-hook-form"; -import { - FormErrorMessage, - FormHelperText, - FormLabel, - Heading, -} from "tw-components"; +import { FormErrorMessage, FormHelperText, FormLabel } from "tw-components"; import type { ComponentWithChildren } from "types/component-with-children"; import { useClaimConditionsFormContext } from "."; @@ -22,9 +17,7 @@ export const CustomFormControl: ComponentWithChildren< return ( {/* label */} - - {props.label} - + {props.label} {/* input */} {props.children} diff --git a/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/claim-conditions-form/phase.tsx b/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/claim-conditions-form/phase.tsx index 7f08a7953a3..063ed1d40bd 100644 --- a/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/claim-conditions-form/phase.tsx +++ b/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/claim-conditions-form/phase.tsx @@ -1,8 +1,9 @@ +import { Badge } from "@/components/ui/badge"; +import { Button } from "@/components/ui/button"; +import { Card } from "@/components/ui/card"; import { AdminOnly } from "@3rdweb-sdk/react/components/roles/admin-only"; -import { Flex, SimpleGrid } from "@chakra-ui/react"; import { ChevronDownIcon, ChevronUpIcon, XIcon } from "lucide-react"; import type { ThirdwebContract } from "thirdweb"; -import { Badge, Button, Card, Heading, Text } from "tw-components"; import { ClaimConditionTypeData, useClaimConditionsFormContext } from "."; import { PricePreview } from "../price-preview"; import { ClaimPriceInput } from "./Inputs/ClaimPriceInput"; @@ -41,117 +42,114 @@ export const ClaimConditionsPhase: React.FC = ({ }; return ( - - - +
+ + - - - - + +
- - - {ClaimConditionTypeData[claimConditionType].name} - {isActive && ( - - Currently active - - )} - +
+
+

+ {ClaimConditionTypeData[claimConditionType].name} +

+ {isActive && ( + + Currently active + + )} +
- {ClaimConditionTypeData[claimConditionType].description} - +

+ {ClaimConditionTypeData[claimConditionType].description} +

+
- {!field.isEditing ? ( - -
- Phase start - {field.startTime?.toLocaleString()} -
-
- - {isErc20 ? "Tokens" : "NFTs"} to drop - - {field.maxClaimableSupply} -
- -
- Limit per wallet - {claimConditionType === "specific" ? ( - Set in the snapshot - ) : claimConditionType === "creator" ? ( - Unlimited - ) : ( - - {field.maxClaimablePerWallet} - - )} -
-
- ) : ( - <> - - {/* Phase Name Input / Form Title */} - {isMultiPhase ? : null} - - + {!field.isEditing ? ( +
+
+

Phase start

+

+ {field.startTime?.toLocaleString()} +

+
+
+

+ {isErc20 ? "Tokens" : "NFTs"} to drop +

+

+ {field.maxClaimableSupply} +

+
+ +
+

Limit per wallet

+ {claimConditionType === "specific" ? ( +

Set in the snapshot

+ ) : claimConditionType === "creator" ? ( +

Unlimited

+ ) : ( +

+ {field.maxClaimablePerWallet} +

+ )} +
+
+ ) : ( + <> + + {/* Phase Name Input / Form Title */} + {isMultiPhase ? : null} + + - + + + + + + + {claimConditionType === "specific" || + claimConditionType === "creator" ? null : ( - - + + )} - {claimConditionType === "specific" || - claimConditionType === "creator" ? null : ( - - - - )} - - - - )} -
+ + + )}
); }; diff --git a/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/price-preview.tsx b/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/price-preview.tsx index 67a078009f2..95ab6389393 100644 --- a/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/price-preview.tsx +++ b/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/price-preview.tsx @@ -1,6 +1,5 @@ import { CURRENCIES } from "constants/currencies"; import { useAllChainsData } from "hooks/chains/allChains"; -import { Text } from "tw-components"; import { shortenIfAddress } from "utils/usedapp-external"; import { isAddressZero } from "utils/zeroAddress"; @@ -25,19 +24,19 @@ export const PricePreview: React.FC = ({ ); return ( -
- Default price +
+

Default price

{Number(price) === 0 ? ( - Free +

Free

) : ( - +

{price}{" "} {foundCurrency ? foundCurrency.symbol : isAddressZero(currencyAddress || "") ? chain?.nativeCurrency.symbol || "(Native Token)" : `(${shortenIfAddress(currencyAddress)})`} - +

)}
); diff --git a/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/quantity-input-with-unlimited.tsx b/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/quantity-input-with-unlimited.tsx index af7bc006abb..d540531ab74 100644 --- a/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/quantity-input-with-unlimited.tsx +++ b/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/quantity-input-with-unlimited.tsx @@ -1,18 +1,14 @@ -import { - Input, - InputGroup, - type InputProps, - InputRightElement, -} from "@chakra-ui/react"; +import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; import { useEffect, useState } from "react"; -import { Button } from "tw-components"; -interface QuantityInputWithUnlimitedProps - extends Omit { +interface QuantityInputWithUnlimitedProps { value: string; onChange: (value: string) => void; hideMaxButton?: true; decimals?: number; + isDisabled: boolean; + isRequired: boolean; } export const QuantityInputWithUnlimited: React.FC< @@ -24,7 +20,6 @@ export const QuantityInputWithUnlimited: React.FC< isDisabled, isRequired, decimals, - ...restInputProps }) => { const [stringValue, setStringValue] = useState( Number.isNaN(Number(value)) ? "0" : value.toString(), @@ -50,10 +45,10 @@ export const QuantityInputWithUnlimited: React.FC< }; return ( - +
updateValue(e.currentTarget.value)} onBlur={() => { @@ -65,23 +60,21 @@ export const QuantityInputWithUnlimited: React.FC< setStringValue("0"); } }} + className="border-none" /> {hideMaxButton ? null : ( - - - + )} - +
); };