Skip to content

Commit 6c180b5

Browse files
committed
[Dashboard] migrate solidity inputs to shadcn (#7148)
## Summary - migrate solidity bool, int, bytes, and string inputs to shadcn/ui and tailwind ## Testing - `pnpm biome check --apply apps/dashboard/src/contract-ui/components/solidity-inputs/bool-input.tsx apps/dashboard/src/contract-ui/components/solidity-inputs/bytes-input.tsx apps/dashboard/src/contract-ui/components/solidity-inputs/int-input.tsx apps/dashboard/src/contract-ui/components/solidity-inputs/string-input.tsx` - `pnpm test` *(fails: spawn anvil ENOENT)* <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on refactoring the UI components in the `solidity-inputs` directory to use a consistent styling approach and improve the layout by replacing certain components with more flexible alternatives. ### Detailed summary - Updated imports from `tw-components` to a local `@/components/ui` for `Button` and `Input`. - Replaced `ButtonGroup` with a `div` for better styling control in `SolidityBoolInput`. - Adjusted button variants from `solid` to `default` for consistency. - Introduced a `showConversionButton` flag in `SolidityIntInput` for conditional rendering. - Changed `InputGroup` to `div` in `SolidityIntInput` and `SolidityStringInput` for layout flexibility. - Used `cn` utility for conditional class names in `Input` components. - Updated button and input placements to enhance responsiveness and styling. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Style** - Updated input components to use custom UI elements and Tailwind CSS for consistent styling. - Replaced Chakra UI and third-party components with locally defined UI components and native HTML elements. - Improved button and input layouts for better visual consistency across boolean, integer, byte, and string input fields. - **New Features** - Enhanced integer input with conditional display of a conversion button based on input value format. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 3489ece commit 6c180b5

File tree

4 files changed

+31
-25
lines changed

4 files changed

+31
-25
lines changed
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { ButtonGroup } from "@chakra-ui/react";
2-
import { Button } from "tw-components";
1+
import { Button } from "@/components/ui/button";
32
import type { SolidityInputProps } from ".";
43

54
export const SolidityBoolInput: React.FC<SolidityInputProps> = ({
@@ -11,22 +10,24 @@ export const SolidityBoolInput: React.FC<SolidityInputProps> = ({
1110
const watchInput = form.watch(inputName);
1211
return (
1312
<div className="flex flex-row">
14-
<ButtonGroup isAttached size="sm" colorScheme="blue">
13+
<div className="inline-flex overflow-hidden rounded-md border border-border">
1514
<Button
15+
size="sm"
1616
onClick={() => form.setValue(inputName, "true")}
17-
borderColor="borderColor"
18-
variant={watchInput === "true" ? "solid" : "outline"}
17+
variant={watchInput === "true" ? "default" : "outline"}
18+
className="rounded-none border-r-0"
1919
>
2020
True
2121
</Button>
2222
<Button
23+
size="sm"
2324
onClick={() => form.setValue(inputName, "false")}
24-
borderColor="borderColor"
25-
variant={watchInput === "false" ? "solid" : "outline"}
25+
variant={watchInput === "false" ? "default" : "outline"}
26+
className="rounded-none rounded-l-none"
2627
>
2728
False
2829
</Button>
29-
</ButtonGroup>
30+
</div>
3031
</div>
3132
);
3233
};

apps/dashboard/src/contract-ui/components/solidity-inputs/bytes-input.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Input } from "@chakra-ui/react";
1+
import { Input } from "@/components/ui/input";
22
import { validateBytes } from "./helpers";
33
import type { SolidityInputWithTypeProps } from "./index";
44

apps/dashboard/src/contract-ui/components/solidity-inputs/int-input.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import { Button } from "@/components/ui/button";
12
import { Input } from "@/components/ui/input";
2-
import { InputGroup, InputRightElement } from "@chakra-ui/react";
3+
import { cn } from "@/lib/utils";
34
import { useCallback } from "react";
45
import { toWei } from "thirdweb";
5-
import { Button } from "tw-components";
66
import type { SolidityInputWithTypeProps } from ".";
77
import { validateInt } from "./helpers";
88

@@ -47,21 +47,28 @@ export const SolidityIntInput: React.FC<SolidityInputWithTypeProps> = ({
4747

4848
const formValue = form.watch(inputName) || "";
4949

50+
const showConversionButton =
51+
formValue.includes(".") || formValue.includes(",");
52+
5053
return (
51-
<InputGroup>
54+
<div className="relative">
5255
<Input
5356
placeholder={solidityType}
5457
{...restOfInputProps}
5558
value={form.watch(inputName)}
5659
onChange={handleChange}
60+
className={cn(
61+
showConversionButton && "pr-28",
62+
restOfInputProps.className,
63+
)}
5764
/>
58-
{(formValue.includes(".") || formValue.includes(",")) && (
59-
<InputRightElement width="auto" px={1}>
65+
{showConversionButton && (
66+
<div className="absolute inset-y-0 right-0 flex items-center pr-1">
6067
<Button variant="ghost" size="sm" onClick={handleConversion}>
6168
Convert to WEI
6269
</Button>
63-
</InputRightElement>
70+
</div>
6471
)}
65-
</InputGroup>
72+
</div>
6673
);
6774
};

apps/dashboard/src/contract-ui/components/solidity-inputs/string-input.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Input } from "@/components/ui/input";
2+
import { cn } from "@/lib/utils";
23
import { useDashboardStorageUpload } from "@3rdweb-sdk/react/hooks/useDashboardStorageUpload";
3-
import { Box, InputGroup, InputRightElement } from "@chakra-ui/react";
44
import { useQueryClient } from "@tanstack/react-query";
55
import { PINNED_FILES_QUERY_KEY_ROOT } from "app/(app)/team/[team_slug]/(team)/~/usage/storage/your-files";
66
import { IpfsUploadButton } from "components/ipfs-upload/button";
@@ -33,17 +33,17 @@ export const SolidityStringInput: React.FC<SolidityInputWithTypeProps> = ({
3333
nameOrInput !== "_baseURIForTokens";
3434

3535
return (
36-
<InputGroup display="flex">
36+
<div className="relative flex">
3737
<Input
3838
placeholder="string"
3939
disabled={storageUpload.isPending}
40-
className="pr-[90px] md:pr-[160px]"
40+
className={cn("pr-[90px] md:pr-[160px]", restOfInputProps.className)}
4141
{...restOfInputProps}
4242
value={form.watch(inputName)}
4343
onChange={handleChange}
4444
/>
4545
{showButton && (
46-
<InputRightElement mx={1} width={{ base: "75px", md: "160px" }}>
46+
<div className="absolute inset-y-0 right-0 flex items-center pr-1">
4747
<IpfsUploadButton
4848
onUpload={(uri) => {
4949
if (functionName) {
@@ -66,13 +66,11 @@ export const SolidityStringInput: React.FC<SolidityInputWithTypeProps> = ({
6666
}}
6767
storageUpload={storageUpload}
6868
>
69-
<Box display={{ base: "none", md: "block" }} mr={1} as="span">
70-
Upload to
71-
</Box>
69+
<span className="mr-1 hidden md:block">Upload to</span>
7270
IPFS
7371
</IpfsUploadButton>
74-
</InputRightElement>
72+
</div>
7573
)}
76-
</InputGroup>
74+
</div>
7775
);
7876
};

0 commit comments

Comments
 (0)