Skip to content

Commit 6e8e31d

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

File tree

12 files changed

+780
-825
lines changed

12 files changed

+780
-825
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: 19 additions & 21 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(
@@ -217,25 +217,23 @@ export const ContractParamsFieldset: React.FC<ContractParamsFieldsetProps> = ({
217217

218218
{/* Inputs */}
219219
{!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>
220+
<SolidityInput
221+
className="!bg-background !text-sm placeholder:!text-sm"
222+
client={client}
223+
placeholder={
224+
isMobile ||
225+
paramTemplateValues?.[0]?.value ===
226+
"{{trusted_forwarders}}"
227+
? "Pre-filled value."
228+
: "This value will be pre-filled in the deploy form."
229+
}
230+
solidityType={param.type}
231+
{...form.register(
232+
`constructorParams.${
233+
param.name ? param.name : "*"
234+
}.defaultValue`,
235+
)}
236+
/>
239237
) : param.type === "address" || param.type === "address[]" ? (
240238
<RefInputFieldset client={client} param={param} />
241239
) : (

0 commit comments

Comments
 (0)