Skip to content

Commit 031b59f

Browse files
committed
Dashboard: Migrate contract deployment UI from chakra to tailwind
1 parent 6b7983f commit 031b59f

File tree

4 files changed

+44
-45
lines changed

4 files changed

+44
-45
lines changed

apps/dashboard/src/@/components/contract-components/contract-deploy-form/custom-contract.tsx

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
"use client";
2-
import { Flex, FormControl } from "@chakra-ui/react";
32
import { useMutation, useQuery } from "@tanstack/react-query";
43
import { verifyContract } from "app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/sources/ContractSourcesPage";
5-
import { FormHelperText, FormLabel } from "chakra/form";
6-
import { Text } from "chakra/text";
74
import {
85
ArrowUpFromLineIcon,
96
CircleAlertIcon,
@@ -27,6 +24,7 @@ import {
2724
reportContractDeployed,
2825
reportContractDeployFailed,
2926
} from "@/analytics/report";
27+
import { FormFieldSetup } from "@/components/blocks/FormFieldSetup";
3028
import { NetworkSelectorButton } from "@/components/misc/NetworkSelectorButton";
3129
import { SolidityInput } from "@/components/solidity-inputs";
3230
import {
@@ -932,14 +930,17 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
932930
<Fieldset legend="Deploy Options">
933931
<div className="flex flex-col gap-6">
934932
{/* Chain */}
935-
<FormControl isRequired>
936-
<FormLabel>Chain</FormLabel>
937-
938-
<p className="mb-3 text-muted-foreground text-sm">
939-
Select a network to deploy this contract on. We recommend
940-
starting with a testnet
941-
</p>
942-
933+
<FormFieldSetup
934+
isRequired
935+
label="Chain"
936+
errorMessage={undefined}
937+
helperText={
938+
<span>
939+
Select a network to deploy this contract on. We recommend
940+
starting with a testnet
941+
</span>
942+
}
943+
>
943944
<div className="flex flex-col gap-3">
944945
<div className="flex flex-col gap-4 md:flex-row">
945946
<NetworkSelectorButton
@@ -953,7 +954,6 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
953954
: metadata?.networksForDeployment?.networksEnabled
954955
}
955956
/>
956-
957957
<Button asChild variant="outline">
958958
<Link
959959
className="gap-3"
@@ -967,12 +967,11 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
967967
</Button>
968968
</div>
969969
</div>
970-
</FormControl>
970+
</FormFieldSetup>
971971

972972
{metadata?.deployType === "standard" && (
973973
<>
974974
{/* Deterministic deploy */}
975-
976975
<div className="flex flex-col gap-3">
977976
<CheckboxWithLabel>
978977
<Checkbox
@@ -1006,16 +1005,21 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
10061005

10071006
{/* Optional Salt Input */}
10081007
{isCreate2Deployment && (
1009-
<FormControl>
1010-
<Flex alignItems="center" my={1}>
1011-
<FormLabel display="flex" flex="1" mb={0}>
1012-
<Flex alignItems="baseline" gap={1}>
1013-
Optional Salt Input
1014-
<Text size="label.sm">(saltForCreate2)</Text>
1015-
</Flex>
1016-
</FormLabel>
1017-
<FormHelperText mt={0}>string</FormHelperText>
1018-
</Flex>
1008+
<FormFieldSetup
1009+
isRequired={false}
1010+
label={
1011+
<span className="flex items-center gap-1">
1012+
Optional Salt Input
1013+
<span className="font-normal text-muted-foreground text-xs">
1014+
(saltForCreate2)
1015+
</span>
1016+
</span>
1017+
}
1018+
errorMessage={
1019+
form.getFieldState("saltForCreate2", form.formState)
1020+
.error?.message
1021+
}
1022+
>
10191023
<SolidityInput
10201024
solidityType="string"
10211025
{...form.register("saltForCreate2")}
@@ -1034,7 +1038,7 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
10341038
Include deployer wallet address in salt (recommended)
10351039
</span>
10361040
</CheckboxWithLabel>
1037-
</FormControl>
1041+
</FormFieldSetup>
10381042
)}
10391043
</>
10401044
)}

apps/dashboard/src/@/components/contract-components/contract-deploy-form/modular-contract-default-modules-fieldset.tsx

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { FormControl } from "@chakra-ui/react";
2-
import { FormErrorMessage, FormLabel } from "chakra/form";
31
import { useMemo } from "react";
42
import type { ThirdwebClient } from "thirdweb";
53
import type { FetchDeployMetadataResult } from "thirdweb/contract";
4+
import { FormFieldSetup } from "@/components/blocks/FormFieldSetup";
65
import { SolidityInput } from "@/components/solidity-inputs";
76
import type { CustomContractDeploymentForm } from "./custom-contract";
87
import { PrimarySaleFieldset } from "./primary-sale-fieldset";
@@ -104,28 +103,23 @@ function RenderModule(props: {
104103
`moduleData.${module.name}.${param.name}` as const;
105104

106105
return (
107-
<FormControl
108-
isInvalid={
109-
!!form.getFieldState(formFieldKey, form.formState).error
110-
}
111-
isRequired
106+
<FormFieldSetup
112107
key={formFieldKey}
108+
htmlFor={formFieldKey}
109+
label={param.name}
110+
isRequired={true}
111+
errorMessage={
112+
form.getFieldState(formFieldKey, form.formState).error?.message
113+
}
113114
>
114-
<FormLabel> {param.name}</FormLabel>
115115
<SolidityInput
116116
client={props.client}
117117
// @ts-expect-error - old types, need to update
118118
solidityComponents={param.components}
119119
solidityType={param.type}
120120
{...form.register(formFieldKey)}
121121
/>
122-
<FormErrorMessage>
123-
{
124-
form.getFieldState(formFieldKey, form.formState).error
125-
?.message
126-
}
127-
</FormErrorMessage>
128-
</FormControl>
122+
</FormFieldSetup>
129123
);
130124
})}
131125
</div>

apps/dashboard/src/@/components/solidity-inputs/button.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type { UseMutationResult } from "@tanstack/react-query";
2-
import { Button, type ButtonProps } from "chakra/button";
32
import { UploadIcon } from "lucide-react";
43
import { toast } from "sonner";
54
import type { ThirdwebClient } from "thirdweb";
65
import { FileInput } from "@/components/blocks/FileInput";
6+
import { Button, type ButtonProps } from "@/components/ui/button";
77
import { useErrorHandler } from "@/contexts/error-handler";
88
import type { ComponentWithChildren } from "@/types/component-with-children";
99

@@ -39,12 +39,13 @@ export const IpfsUploadButton: ComponentWithChildren<IpfsUploadButtonProps> = ({
3939
<FileInput client={client} setValue={handleUpload}>
4040
<Button
4141
aria-label="Upload to IPFS"
42-
isLoading={storageUpload.isPending}
43-
rightIcon={<UploadIcon className="size-4" />}
42+
variant="secondary"
43+
disabled={storageUpload.isPending}
4444
size="sm"
45-
variant="solid"
45+
className="h-auto py-1.5 text-xs -translate-x-0.5 rounded-sm"
4646
{...buttonProps}
4747
>
48+
<UploadIcon className="size-3 mr-2 text-muted-foreground" />
4849
{children}
4950
</Button>
5051
</FileInput>

apps/dashboard/src/chakra/button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const buttonSizesMap = {
3030

3131
type PossibleButtonSize = keyof typeof buttonSizesMap;
3232

33-
export interface ButtonProps extends Omit<ChakraButtonProps, "size"> {
33+
interface ButtonProps extends Omit<ChakraButtonProps, "size"> {
3434
size?: PossibleButtonSize;
3535
fromcolor?: string;
3636
tocolor?: string;

0 commit comments

Comments
 (0)