Skip to content

Commit a2ce5f5

Browse files
committed
[Dashboard] Remove <Code /> component (ez mode) (#4787)
## Problem solved Short description of the bug fixed or feature added <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on enhancing code readability by replacing instances of the `Code` component from Chakra UI with a new `InlineCode` component, which provides a consistent styling for inline code snippets across various files. ### Detailed summary - Added `InlineCode` component in `inline-code.tsx`. - Replaced `Code` with `InlineCode` in multiple components for improved consistency: - `ChainValidation` - `EngineCorsConfig` - `EngineIpAllowlistConfig` - `InteractiveAbiFunction` - `EngineAccessTokens` - `SnapshotUpload` - `UploadStep` > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 6beec7a commit a2ce5f5

File tree

11 files changed

+74
-54
lines changed

11 files changed

+74
-54
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { cn } from "@/lib/utils";
2+
3+
export function InlineCode({
4+
code,
5+
className,
6+
}: { code: string; className?: string }) {
7+
return (
8+
<code
9+
className={cn(
10+
"inline-block rounded bg-muted px-2 font-mono text-sm",
11+
className,
12+
)}
13+
>
14+
{code}
15+
</code>
16+
);
17+
}

apps/dashboard/src/components/chain-validation/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { InlineCode } from "@/components/ui/inline-code";
12
import {
2-
Code,
33
FormControl,
44
Icon,
55
Input,
@@ -104,7 +104,7 @@ const ChainValidation: React.FC = () => {
104104
<>
105105
<Tr>
106106
<Td>
107-
RPC supports <Code>eth_chainId</Code> method
107+
RPC supports <InlineCode code="eth_chainId" /> method
108108
</Td>
109109
<Td textAlign="right">
110110
<StatusCheck
@@ -118,7 +118,8 @@ const ChainValidation: React.FC = () => {
118118
</Tr>
119119
<Tr>
120120
<Td>
121-
RPC supports <Code>eth_blockNumber</Code> method
121+
RPC supports <InlineCode code="eth_blockNumber" />{" "}
122+
method
122123
</Td>
123124
<Td textAlign="right">
124125
<StatusCheck
@@ -135,7 +136,7 @@ const ChainValidation: React.FC = () => {
135136
<Td>
136137
Chain ID{" "}
137138
{existingChain?.id ? (
138-
<Code mr={1}>{existingChain.id}</Code>
139+
<code className="mr-1">{existingChain.id}</code>
139140
) : (
140141
""
141142
)}

apps/dashboard/src/components/contract-functions/interactive-abi-function.tsx

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"use client";
22

3+
import { InlineCode } from "@/components/ui/inline-code";
34
import { ToolTipLabel } from "@/components/ui/tooltip";
45
import {
56
ButtonGroup,
6-
Code,
77
Divider,
88
Flex,
99
FormControl,
@@ -408,21 +408,11 @@ export const InteractiveAbiFunction: React.FC<InteractiveAbiFunctionProps> = ({
408408
<>
409409
<Divider />
410410
<Heading size="label.sm">Error</Heading>
411-
<Text
412-
borderColor="borderColor"
413-
as={Code}
414-
p={4}
415-
w="full"
416-
bgColor="backgroundHighlight"
417-
borderRadius="md"
418-
color="red.500"
419-
whiteSpace="pre-wrap"
420-
borderWidth="1px"
421-
position="relative"
422-
>
423-
{/* biome-ignore lint/suspicious/noExplicitAny: FIXME */}
424-
{formatError(error as any)}
425-
</Text>
411+
<InlineCode
412+
// biome-ignore lint/suspicious/noExplicitAny: FIXME
413+
code={formatError(error as any)}
414+
className="relative w-full whitespace-pre-wrap rounded-md border border-border p-4 text-red-500"
415+
/>
426416
</>
427417
) : formattedResponseData ? (
428418
<>

apps/dashboard/src/components/engine/configuration/cors.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import { InlineCode } from "@/components/ui/inline-code";
12
import {
23
useEngineCorsConfiguration,
34
useEngineSetCorsConfiguration,
45
} from "@3rdweb-sdk/react/hooks/useEngine";
5-
import { Code, Flex, Textarea } from "@chakra-ui/react";
6+
import { Flex, Textarea } from "@chakra-ui/react";
67
import { useTxNotifications } from "hooks/useTxNotifications";
78
import { useForm } from "react-hook-form";
89
import { Button, Heading, Text } from "tw-components";
@@ -55,7 +56,8 @@ export const EngineCorsConfig: React.FC<EngineCorsConfigProps> = ({
5556
<Heading size="title.md">Allowlisted Domains</Heading>
5657
<Text>
5758
Specify the origins that can call Engine (
58-
<Code>https://example.com</Code>).
59+
<InlineCode code="https://example.com" />
60+
).
5961
<br />
6062
Enter one origin per line, or leave this list empty to disallow calls
6163
from web clients.

apps/dashboard/src/components/engine/configuration/ip-allowlist.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import { InlineCode } from "@/components/ui/inline-code";
12
import {
23
useEngineIpAllowlistConfiguration,
34
useEngineSetIpAllowlistConfiguration,
45
useEngineSystemHealth,
56
} from "@3rdweb-sdk/react/hooks/useEngine";
6-
import { Code, Flex, Textarea } from "@chakra-ui/react";
7+
import { Flex, Textarea } from "@chakra-ui/react";
78
import { useTxNotifications } from "hooks/useTxNotifications";
89
import { isValid } from "ipaddr.js";
910
import { useForm } from "react-hook-form";
@@ -74,7 +75,9 @@ export const EngineIpAllowlistConfig: React.FC<
7475
<Flex flexDir="column" gap={2}>
7576
<Heading size="title.md">Allowlist IPs</Heading>
7677
<Text>
77-
Specify the IP Addresses that can call Engine (<Code>8.8.8.8</Code>).
78+
Specify the IP Addresses that can call Engine (
79+
<InlineCode code="8.8.8.8" />
80+
).
7881
<br />
7982
Enter a comma separated list of IPs, or one IP per line, or leave this
8083
list empty to allow all IPs.

apps/dashboard/src/components/engine/permissions/engine-access-tokens.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
"use client";
22

3+
import { InlineCode } from "@/components/ui/inline-code";
34
import {
45
useEngineAccessTokens,
56
useEngineKeypairs,
67
useEngineSystemHealth,
78
} from "@3rdweb-sdk/react/hooks/useEngine";
8-
import { ButtonGroup, Code, Flex } from "@chakra-ui/react";
9+
import { ButtonGroup, Flex } from "@chakra-ui/react";
910
import { useState } from "react";
1011
import { Button, CodeBlock, Heading, Link, Text } from "tw-components";
1112
import { AccessTokensTable } from "./access-tokens-table";
@@ -104,7 +105,7 @@ const StandardAccessTokensPanel = ({
104105
<Flex direction="column" gap={2} mt={16}>
105106
<Heading size="title.md">Authenticate with your access token</Heading>
106107
<Text>
107-
Set the <Code>authorization</Code> header.
108+
Set the <InlineCode code="authorization" /> header.
108109
</Text>
109110
<CodeBlock
110111
language="typescript"
@@ -155,7 +156,7 @@ const KeypairAuthenticationPanel = ({
155156
<Heading size="title.md">Authenticate with your access token</Heading>
156157

157158
<Text>
158-
Set the <Code>authorization</Code> header.
159+
Set the <InlineCode code="authorization" /> header.
159160
</Text>
160161
<CodeBlock
161162
language="typescript"

apps/dashboard/src/contract-ui/tabs/claim-conditions/components/snapshot-upload.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import { InlineCode } from "@/components/ui/inline-code";
12
import { useThirdwebClient } from "@/constants/thirdweb.client";
23
import { cn } from "@/lib/utils";
34
import {
45
Box,
5-
Code,
66
Container,
77
Flex,
88
Icon,
@@ -266,8 +266,9 @@ export const SnapshotUpload: React.FC<SnapshotUploadProps> = ({
266266
<>
267267
<Text as={ListItem}>
268268
Files <em>must</em> contain one .csv file with a list
269-
of addresses and their <Code>maxClaimable</Code>.
270-
(amount each wallet is allowed to claim)
269+
of addresses and their{" "}
270+
<InlineCode code="maxClaimable" />. (amount each
271+
wallet is allowed to claim)
271272
<br />
272273
<Link
273274
download
@@ -279,10 +280,10 @@ export const SnapshotUpload: React.FC<SnapshotUploadProps> = ({
279280
</Link>
280281
</Text>
281282
<Text as={ListItem}>
282-
You may optionally add <Code>price</Code> and{" "}
283-
<Code>currencyAddress</Code> overrides as well. This
284-
lets you override the currency and price you would
285-
like to charge per wallet you specified
283+
You may optionally add <InlineCode code="price" /> and
284+
<InlineCode code="currencyAddress" /> overrides as
285+
well. This lets you override the currency and price
286+
you would like to charge per wallet you specified
286287
<br />
287288
<Link
288289
download
@@ -306,7 +307,8 @@ export const SnapshotUpload: React.FC<SnapshotUploadProps> = ({
306307
</Link>
307308
</Text>
308309
<Text as={ListItem}>
309-
You may optionally add a <Code>maxClaimable</Code>{" "}
310+
You may optionally add a{" "}
311+
<InlineCode code="maxClaimable" />
310312
column override. (amount each wallet is allowed to
311313
claim) If not specified, the default value is the one
312314
you have set on your claim phase.
@@ -321,10 +323,10 @@ export const SnapshotUpload: React.FC<SnapshotUploadProps> = ({
321323
</Link>
322324
</Text>
323325
<Text as={ListItem}>
324-
You may optionally add <Code>price</Code> and{" "}
325-
<Code>currencyAddress</Code> overrides. This lets you
326-
override the currency and price you would like to
327-
charge per wallet you specified.{" "}
326+
You may optionally add <InlineCode code="price" /> and
327+
<InlineCode code="currencyAddress" /> overrides. This
328+
lets you override the currency and price you would
329+
like to charge per wallet you specified.{" "}
328330
<strong>
329331
When defining a custom currency address, you must
330332
also define a price override.

apps/dashboard/src/contract-ui/tabs/nfts/components/airdrop-tab.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"use client";
22

3-
import {} from "@chakra-ui/react";
43
import { Flex, Icon, useDisclosure } from "@chakra-ui/react";
54
import { TransactionButton } from "components/buttons/TransactionButton";
65
import {

apps/dashboard/src/contract-ui/tabs/nfts/components/transfer-tab.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"use client";
22

3-
import {} from "@chakra-ui/react";
43
import { FormControl, Input } from "@chakra-ui/react";
54
import { TransactionButton } from "components/buttons/TransactionButton";
65
import { SolidityInput } from "contract-ui/components/solidity-inputs";

apps/dashboard/src/contract-ui/tabs/permissions/page.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"use client";
22

3+
import { InlineCode } from "@/components/ui/inline-code";
34
import { useIsomorphicLayoutEffect } from "@/lib/useIsomorphicLayoutEffect";
4-
import { ButtonGroup, Code, Divider, Flex } from "@chakra-ui/react";
5+
import { ButtonGroup, Divider, Flex } from "@chakra-ui/react";
56
import type { ThirdwebContract } from "thirdweb";
67
import { Card, Heading, Link, LinkButton, Text } from "tw-components";
78
import { Permissions } from "./components";
@@ -29,7 +30,8 @@ export const ContractPermissionsPage: React.FC<
2930
Missing PermissionsEnumerable Extension
3031
</Heading>
3132
<Text>
32-
This contract does not support the <Code>PermissionsEnumerable</Code>{" "}
33+
This contract does not support the{" "}
34+
<InlineCode code="PermissionsEnumerable" />
3335
extension.
3436
<br />
3537
As a result, you can only view and manage basic permissions via the{" "}

0 commit comments

Comments
 (0)