Skip to content

Commit 22693c0

Browse files
committed
Dashboard: Migrate publish contract page from chakra to tailwind
1 parent 3f8da59 commit 22693c0

File tree

12 files changed

+797
-841
lines changed

12 files changed

+797
-841
lines changed
Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
import type { Abi } from "abitype";
2-
import { Select } from "chakra-react-select";
32
import { useMemo } from "react";
3+
import {
4+
Select,
5+
SelectContent,
6+
SelectItem,
7+
SelectTrigger,
8+
SelectValue,
9+
} from "@/components/ui/select";
410

5-
interface AbiSelectorProps {
6-
abi: Abi;
7-
defaultValue: string;
8-
value: string;
9-
onChange: (fn: string) => void;
10-
}
11-
12-
export const AbiSelector: React.FC<AbiSelectorProps> = ({
11+
export function AbiSelector({
1312
abi,
1413
value,
1514
defaultValue,
1615
onChange,
17-
}) => {
16+
}: {
17+
abi: Abi;
18+
defaultValue: string;
19+
value: string;
20+
onChange: (fn: string) => void;
21+
}) {
1822
const options = useMemo(() => {
1923
return abi
2024
.filter((f) => f.type === "function")
@@ -26,24 +30,17 @@ export const AbiSelector: React.FC<AbiSelectorProps> = ({
2630
}, [abi]);
2731

2832
return (
29-
<div className="flex w-full flex-row items-center gap-2">
30-
<Select
31-
chakraStyles={{
32-
container: (provided) => ({
33-
...provided,
34-
width: "full",
35-
}),
36-
}}
37-
defaultValue={options.find((o) => o.value === defaultValue)}
38-
onChange={(selectedFn) => {
39-
if (selectedFn) {
40-
onChange((selectedFn as { label: string; value: string }).value);
41-
}
42-
}}
43-
options={options}
44-
placeholder="Select function"
45-
value={options.find((o) => o.value === value)}
46-
/>
47-
</div>
33+
<Select value={value} onValueChange={onChange} defaultValue={defaultValue}>
34+
<SelectTrigger className="w-full bg-card">
35+
<SelectValue placeholder="Select function" />
36+
</SelectTrigger>
37+
<SelectContent>
38+
{options.map((option) => (
39+
<SelectItem key={option.value} value={option.value}>
40+
{option.label}
41+
</SelectItem>
42+
))}
43+
</SelectContent>
44+
</Select>
4845
);
49-
};
46+
}

apps/dashboard/src/@/components/contract-components/contract-publish-form/contract-params-fieldset.tsx

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { FormControl, useBreakpointValue } from "@chakra-ui/react";
21
import type { AbiParameter } from "abitype";
32
import { useId, useState } from "react";
43
import { useFormContext } from "react-hook-form";
@@ -12,6 +11,7 @@ import { Input } from "@/components/ui/input";
1211
import { Separator } from "@/components/ui/separator";
1312
import { Switch } from "@/components/ui/switch";
1413
import { Textarea } from "@/components/ui/textarea";
14+
import { useIsMobile } from "@/hooks/use-mobile";
1515
import { getTemplateValuesForType } from "@/lib/deployment/template-values";
1616
import { DecodedInputArrayFieldset } from "./decoded-bytes-input/decoded-input-array-fieldset";
1717
import { RefInputFieldset } from "./ref-contract-input/ref-input-fieldset";
@@ -25,7 +25,7 @@ export const ContractParamsFieldset: React.FC<ContractParamsFieldsetProps> = ({
2525
client,
2626
}) => {
2727
const form = useFormContext();
28-
const isMobile = useBreakpointValue({ base: true, md: false });
28+
const isMobile = useIsMobile();
2929
const displayNameId = useId();
3030
const descriptionId = useId();
3131
const [isCustomInputEnabledArray, setIsCustomInputEnabledArray] = useState(
@@ -70,22 +70,20 @@ export const ContractParamsFieldset: React.FC<ContractParamsFieldsetProps> = ({
7070

7171
return (
7272
<fieldset>
73-
<h2 className="font-semibold text-3xl tracking-tight">
73+
<h2 className="text-2xl font-semibold tracking-tight mb-1">
7474
Contract Parameters
7575
</h2>
76-
<p className="text-muted-foreground">
76+
<p className="text-muted-foreground text-sm mb-6">
7777
These are the parameters users will need to fill in when deploying this
7878
contract.
7979
</p>
8080

81-
<div className="h-6" />
82-
8381
<div className="flex flex-col gap-8">
8482
{deployParams.map((param, idx) => {
8583
const paramTemplateValues = getTemplateValuesForType(param.type);
8684
return (
8785
<div
88-
className="rounded-lg border border-border bg-card p-6"
86+
className="rounded-lg border border-border bg-card p-4"
8987
key={`implementation_${param.name}`}
9088
>
9189
{/* Title + Type */}
@@ -100,12 +98,12 @@ export const ContractParamsFieldset: React.FC<ContractParamsFieldsetProps> = ({
10098
)}
10199
</h3>
102100
<InlineCode
103-
className="px-2 text-base text-muted-foreground"
101+
className="px-2 text-muted-foreground text-sm"
104102
code={param.type}
105103
/>
106104
</div>
107105

108-
<div className="h-5" />
106+
<div className="h-4" />
109107

110108
{/* Display Name */}
111109
<FormFieldSetup
@@ -140,7 +138,7 @@ export const ContractParamsFieldset: React.FC<ContractParamsFieldsetProps> = ({
140138
/>
141139
</FormFieldSetup>
142140

143-
<div className="h-5" />
141+
<div className="h-4" />
144142

145143
{/* Description */}
146144
<FormFieldSetup
@@ -217,25 +215,23 @@ export const ContractParamsFieldset: React.FC<ContractParamsFieldsetProps> = ({
217215

218216
{/* Inputs */}
219217
{!isCustomInputEnabledArray[idx] ? (
220-
<FormControl>
221-
<SolidityInput
222-
className="!bg-background !text-sm placeholder:!text-sm"
223-
client={client}
224-
placeholder={
225-
isMobile ||
226-
paramTemplateValues?.[0]?.value ===
227-
"{{trusted_forwarders}}"
228-
? "Pre-filled value."
229-
: "This value will be pre-filled in the deploy form."
230-
}
231-
solidityType={param.type}
232-
{...form.register(
233-
`constructorParams.${
234-
param.name ? param.name : "*"
235-
}.defaultValue`,
236-
)}
237-
/>
238-
</FormControl>
218+
<SolidityInput
219+
className="!bg-background !text-sm placeholder:!text-sm"
220+
client={client}
221+
placeholder={
222+
isMobile ||
223+
paramTemplateValues?.[0]?.value ===
224+
"{{trusted_forwarders}}"
225+
? "Pre-filled value."
226+
: "This value will be pre-filled in the deploy form."
227+
}
228+
solidityType={param.type}
229+
{...form.register(
230+
`constructorParams.${
231+
param.name ? param.name : "*"
232+
}.defaultValue`,
233+
)}
234+
/>
239235
) : param.type === "address" || param.type === "address[]" ? (
240236
<RefInputFieldset client={client} param={param} />
241237
) : (

0 commit comments

Comments
 (0)