Skip to content

Commit 10a84d2

Browse files
committed
[Dashboard] Remove <Center /> (#4765)
## Problem solved Short description of the bug fixed or feature added <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on replacing the usage of the `Center` component from `@chakra-ui/react` with `div` elements styled with Flexbox classes for better layout control across various components in the dashboard. ### Detailed summary - Replaced `Center` with `div` and applied Flexbox utility classes in multiple components for consistent styling. - Updated components include `TransactionButton`, `ContractSplitPage`, `OnboardingPaymentForm`, and more. - Maintained existing functionality while improving layout responsiveness. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 3e8c074 commit 10a84d2

File tree

36 files changed

+153
-265
lines changed

36 files changed

+153
-265
lines changed

apps/dashboard/src/components/FTUX/components/ContentContainer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CustomConnectWallet } from "@3rdweb-sdk/react/components/connect-wallet";
2-
import { Box, ButtonGroup, Center, Flex } from "@chakra-ui/react";
2+
import { Box, ButtonGroup, Flex } from "@chakra-ui/react";
33
import { motion } from "framer-motion";
44
import { useTrack } from "hooks/analytics/useTrack";
55
import { FiArrowRight } from "react-icons/fi";
@@ -98,7 +98,7 @@ export const ContentContainer: React.FC<SlideStateProps> = ({
9898
h="100%"
9999
justify="space-between"
100100
>
101-
<Center flexGrow={1} position="relative">
101+
<div className="relative flex grow items-center justify-center">
102102
<Flex gap={8} direction="column" height="100%" width="100%">
103103
<Box position="relative" w="full" mt="auto">
104104
<SlideContent
@@ -128,7 +128,7 @@ export const ContentContainer: React.FC<SlideStateProps> = ({
128128
)}
129129
</ButtonGroup>
130130
</Flex>
131-
</Center>
131+
</div>
132132
</Flex>
133133
);
134134
};

apps/dashboard/src/components/FTUX/components/Graphics.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Center, Flex } from "@chakra-ui/react";
1+
import { Flex } from "@chakra-ui/react";
22
import { ChakraNextImage } from "components/Image";
33
import { motion } from "framer-motion";
44
import { Heading } from "tw-components";
@@ -48,25 +48,25 @@ export const Titles: React.FC<SlideStateProps> = ({
4848

4949
export const DashboardImage: React.FC = () => (
5050
<motion.div {...moveDown}>
51-
<Center>
51+
<div className="flex items-center justify-center">
5252
<ChakraNextImage
5353
priority
5454
w={{ base: "45%", md: "90%" }}
5555
src={require("../../../../public/assets/product-pages/dashboard/hero.png")}
5656
alt=""
5757
/>
58-
</Center>
58+
</div>
5959
</motion.div>
6060
);
6161

6262
export const ConnectWalletImage: React.FC = () => (
6363
<motion.div {...moveDown}>
64-
<Center h="100%" w="100%">
64+
<div className="flex h-full w-full items-center justify-center">
6565
<ChakraNextImage
6666
alt=""
6767
boxSize="75px"
6868
src={require("../../../../public/logos/wallet.png")}
6969
/>
70-
</Center>
70+
</div>
7171
</motion.div>
7272
);

apps/dashboard/src/components/buttons/TransactionButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ export const TransactionButton: React.FC<TransactionButtonProps> = ({
119119
: `This action will trigger ${transactionCount} ${transactionCount > 1 ? "transactions" : "transaction"}`
120120
}
121121
>
122+
{/* to be completed */}
122123
<Center
123124
_groupHover={{
124125
bg:

apps/dashboard/src/components/contract-components/tables/published-contracts.tsx

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
import {
2-
Alert,
3-
AlertIcon,
4-
AlertTitle,
5-
Center,
6-
Flex,
7-
Spinner,
8-
} from "@chakra-ui/react";
1+
import { Alert, AlertIcon, AlertTitle, Flex, Spinner } from "@chakra-ui/react";
92
import { useTrack } from "hooks/analytics/useTrack";
103
import { useMemo, useState } from "react";
114
import { IoRefreshSharp } from "react-icons/io5";
@@ -90,15 +83,15 @@ export const PublishedContracts: React.FC<PublishedContractsProps> = ({
9083
hidePublisher
9184
>
9285
{publishedContractsQuery.isPending && (
93-
<Center>
86+
<div className="flex items-center justify-center">
9487
<Flex py={4} direction="row" gap={4} align="center">
9588
<Spinner size="sm" />
9689
<Text>Loading published contracts</Text>
9790
</Flex>
98-
</Center>
91+
</div>
9992
)}
10093
{publishedContractsQuery.isError && (
101-
<Center>
94+
<div className="flex items-center justify-center">
10295
<Flex mt={4} py={4} direction="column" gap={4} align="center">
10396
<Alert status="error" borderRadius="md">
10497
<AlertIcon />
@@ -116,15 +109,15 @@ export const PublishedContracts: React.FC<PublishedContractsProps> = ({
116109
</Button>
117110
</Alert>
118111
</Flex>
119-
</Center>
112+
</div>
120113
)}
121114
{publishedContractsQuery.isSuccess &&
122115
publishedContractsQuery.data.length === 0 && (
123-
<Center>
116+
<div className="flex items-center justify-center">
124117
<Flex py={4} direction="column" gap={4} align="center">
125118
<Text>No published contracts found.</Text>
126119
</Flex>
127-
</Center>
120+
</div>
128121
)}
129122
{publishedContractsQuery.isSuccess &&
130123
publishedContractsQuery.data.length > slicedData.length && (

apps/dashboard/src/components/custom-contract/contract-header/metadata-header.tsx

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

33
import { useThirdwebClient } from "@/constants/thirdweb.client";
4-
import { Center, Flex, Skeleton, useBreakpointValue } from "@chakra-ui/react";
4+
import { Flex, Skeleton, useBreakpointValue } from "@chakra-ui/react";
55
import { ChainIcon } from "components/icons/ChainIcon";
66
import Link from "next/link";
77
import type { ChainMetadata } from "thirdweb/chains";
@@ -119,13 +119,9 @@ export const MetadataHeader: React.FC<MetadataHeaderProps> = ({
119119
cursor="pointer"
120120
>
121121
{chain.icon?.url && (
122-
<Center
123-
boxSize={5}
124-
mr={{ base: 0, md: -0.5 }}
125-
borderRadius="full"
126-
>
122+
<div className="md:-mr-0.5 mr-0 flex h-5 w-5 items-center justify-center rounded-full">
127123
<ChainIcon ipfsSrc={chain.icon.url} size={24} />
128-
</Center>
124+
</div>
129125
)}
130126
<Heading
131127
display={{

apps/dashboard/src/components/homepage/sections/GetStartedSection.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Box, Center, Flex, LightMode } from "@chakra-ui/react";
1+
import { Box, Flex, LightMode } from "@chakra-ui/react";
22
import { ChakraNextImage } from "components/Image";
33
import { HomepageSection } from "components/product-pages/homepage/HomepageSection";
44
import { GeneralCta } from "components/shared/GeneralCta";
@@ -18,8 +18,8 @@ export const GetStartedSection = () => {
1818
align="center"
1919
gap={{ base: 6, md: 8 }}
2020
>
21-
<Center mb={6} pt={{ base: 8, lg: 24 }}>
22-
<Center p={2} position="relative" mb={6}>
21+
<div className="mb-6 flex items-center justify-center pt-8 lg:pt-24">
22+
<div className="relative mb-6 flex items-center justify-center p-2">
2323
<Box
2424
position="absolute"
2525
bgGradient="linear(to-r, #F213A4, #040BBF)"
@@ -38,8 +38,8 @@ export const GetStartedSection = () => {
3838
placeholder="empty"
3939
src={WhiteLogo}
4040
/>
41-
</Center>
42-
</Center>
41+
</div>
42+
</div>
4343
<Heading as="h2" size="display.md" textAlign="center">
4444
Get started with thirdweb
4545
</Heading>

apps/dashboard/src/components/homepage/sections/PricingCard.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AccountPlan } from "@3rdweb-sdk/react/hooks/useApi";
2-
import { Box, type CardProps, Center, Flex } from "@chakra-ui/react";
2+
import { Box, type CardProps, Flex } from "@chakra-ui/react";
33
import {
44
Badge,
55
Card,
@@ -174,7 +174,7 @@ export const PricingCard: React.FC<PricingCardProps> = ({
174174

175175
if (highlighted) {
176176
return (
177-
<Center position="relative" p={2} m={-2}>
177+
<div className="-m-2 relative flex items-center justify-center p-2">
178178
<Box
179179
position="absolute"
180180
bgGradient="linear(to-b, #4DABEE, #692AC1)"
@@ -187,7 +187,7 @@ export const PricingCard: React.FC<PricingCardProps> = ({
187187
filter="blur(8px)"
188188
/>
189189
{content}
190-
</Center>
190+
</div>
191191
);
192192
}
193193

apps/dashboard/src/components/ipfs-upload/dropzone.tsx

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { useDashboardStorageUpload } from "@3rdweb-sdk/react/hooks/useDashboardS
77
import {
88
Box,
99
ButtonGroup,
10-
Center,
1110
Divider,
1211
Flex,
1312
GridItem,
@@ -87,36 +86,22 @@ export const IpfsUploadDropzone: React.FC = () => {
8786
<FileUpload files={droppedFiles} updateFiles={setDroppedFiles} />
8887
</div>
8988
) : !address ? (
90-
<Center
91-
border="2px solid"
92-
borderColor="borderColor"
93-
borderRadius="xl"
94-
h="full"
95-
>
89+
<div className="flex h-full items-center justify-center rounded-xl border-2 border-border">
9690
<Text
9791
size="label.lg"
9892
className="text-muted-foreground"
9993
textAlign="center"
10094
>
10195
Please connect your wallet to begin uploading.
10296
</Text>
103-
</Center>
97+
</div>
10498
) : (
105-
<Center
99+
<div
100+
className={cn(
101+
"flex items-center justify-center rounded-xl border-2 border-border border-solid bg-transparent hover:border-blue-600 dark:border-blue-400",
102+
address ? "cursor-pointer" : "cursor-default",
103+
)}
106104
{...getRootProps()}
107-
bg="transparent"
108-
_hover={{
109-
_light: {
110-
borderColor: "blue.600",
111-
},
112-
_dark: {
113-
borderColor: "blue.400",
114-
},
115-
}}
116-
border="2px solid"
117-
borderColor="borderColor"
118-
borderRadius="xl"
119-
cursor={address ? "pointer" : "default"}
120105
>
121106
<input {...getInputProps()} />
122107

@@ -148,7 +133,7 @@ export const IpfsUploadDropzone: React.FC = () => {
148133
)}
149134
</Flex>
150135
}
151-
</Center>
136+
</div>
152137
)}
153138
</div>
154139
<Flex flexDir="column" gap={{ base: 6, md: 3 }} />
@@ -440,14 +425,7 @@ const FileUpload: React.FC<FileUploadProps> = ({ files, updateFiles }) => {
440425
isIndeterminate={storageUpload.isPending}
441426
position="relative"
442427
/>
443-
<Center
444-
display={{ base: "none", md: "block" }}
445-
position="absolute"
446-
left={0}
447-
right={0}
448-
top={0}
449-
bottom={0}
450-
>
428+
<div className="absolute top-0 right-0 bottom-0 left-0 hidden md:block">
451429
{/* <Text
452430
mt={0.5}
453431
size="label.xs"
@@ -474,7 +452,7 @@ const FileUpload: React.FC<FileUploadProps> = ({ files, updateFiles }) => {
474452
>
475453
{Math.round(progressPercent)}%
476454
</Text> */}
477-
</Center>
455+
</div>
478456
</Flex>
479457
)}
480458
<ButtonGroup ml={{ base: "0", md: "auto" }}>

apps/dashboard/src/components/onboarding/PaymentForm.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
Alert,
44
AlertDescription,
55
AlertIcon,
6-
Center,
76
Flex,
87
Spinner,
98
} from "@chakra-ui/react";
@@ -109,9 +108,9 @@ export const OnboardingPaymentForm: React.FC<OnboardingPaymentForm> = ({
109108
/>
110109

111110
{loading ? (
112-
<Center pb={16}>
111+
<div className="flex items-center justify-center pb-16">
113112
<Spinner size="sm" />
114-
</Center>
113+
</div>
115114
) : (
116115
<Flex flexDir="column" gap={4}>
117116
{paymentFailureCode ? (

apps/dashboard/src/components/product-pages/common/GameCard.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Box, Center, Flex, useBreakpointValue } from "@chakra-ui/react";
1+
import { Box, Flex, useBreakpointValue } from "@chakra-ui/react";
22
import { SiGithub } from "@react-icons/all-files/si/SiGithub";
33
import { useTrack } from "hooks/analytics/useTrack";
44
import NextImage, { type StaticImageData } from "next/image";
@@ -70,7 +70,7 @@ export const GameCard: React.FC<GameCardProps> = ({
7070
(max-width: 1200px) 50vw,
7171
33vw"
7272
/>
73-
<Center position="absolute" top={0} bottom={0} left={0} right={0}>
73+
<div className="absolute inset-0 flex items-center justify-center">
7474
<Button
7575
leftIcon={<IoGameControllerOutline />}
7676
color="white"
@@ -80,7 +80,7 @@ export const GameCard: React.FC<GameCardProps> = ({
8080
>
8181
Play Game
8282
</Button>
83-
</Center>
83+
</div>
8484
</Box>
8585

8686
<Flex direction="column" gap={2} pb={4} px={4}>

0 commit comments

Comments
 (0)