Skip to content

Commit 61a235c

Browse files
authored
Merge pull request #14035 from Baystef/migrate/dataproductcard
Migrate DataProductCard component to shadcn/tailwind
2 parents bb91f48 + 0f27599 commit 61a235c

File tree

2 files changed

+34
-91
lines changed

2 files changed

+34
-91
lines changed

src/components/DataProductCard.tsx

Lines changed: 31 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
import React from "react"
22
import { StaticImageData } from "next/image"
3-
import {
4-
Box,
5-
Flex,
6-
Heading,
7-
LinkBox,
8-
LinkOverlay,
9-
useColorModeValue,
10-
} from "@chakra-ui/react"
113

12-
import { Image } from "@/components/Image"
4+
import { TwImage } from "@/components/Image"
5+
import { Flex } from "@/components/ui/flex"
136

14-
import Text from "./OldText"
7+
import InlineLink from "./ui/Link"
8+
import { LinkBox, LinkOverlay } from "./ui/link-box"
159

1610
export interface DataRow {
1711
logo: StaticImageData
@@ -23,7 +17,7 @@ export type DataProductCardProps = {
2317
url: string
2418
background: string
2519
image: StaticImageData
26-
imgWidth: string
20+
imgWidth: number
2721
alt?: string
2822
name: string
2923
description?: string
@@ -40,104 +34,53 @@ const DataProductCard = ({
4034
description,
4135
data,
4236
}: DataProductCardProps) => {
43-
const boxShadow = useColorModeValue("tableBox.light", "tableBox.dark")
44-
4537
return (
46-
<LinkBox
47-
color="text"
48-
background="searchBackground"
49-
border="1px solid"
50-
borderColor="lightBorder"
51-
borderRadius="base"
52-
overflow="hidden"
53-
boxShadow={boxShadow}
54-
display="flex"
55-
flexDirection="column"
56-
_hover={{
57-
background: "tableBackgroundHover",
58-
boxShadow: boxShadow,
59-
transition: "transform 0.1s ease 0s",
60-
transform: "scale(1.02)",
61-
}}
62-
>
38+
<LinkBox className="flex flex-col overflow-hidden rounded border shadow-table-box transition-transform duration-100 ease-linear hover:scale-[1.02] hover:bg-background-highlight focus:scale-[1.02] focus:bg-background-highlight">
6339
<Flex
64-
alignItems="center"
65-
justifyContent="center"
66-
boxShadow="rgb(0 0 0 / 10%) 0px -1px 0px inset;"
67-
minH="200px"
68-
bg={background}
40+
className={
41+
"min-h-[200px] items-center justify-center shadow-[rgb(0_0_0/_10%)_0px_-1px_0px_inset]"
42+
}
43+
style={{ background }}
6944
>
70-
<Image
71-
src={image}
72-
objectFit="cover"
45+
<TwImage
7346
alt={alt ? alt : `${name} logo`}
74-
w={imgWidth}
75-
alignSelf="center"
76-
maxWidth={{ base: "311px", sm: "372px" }}
77-
maxHeight="257px"
47+
className="max-h-[257px] max-w-[311px] self-center object-cover sm:max-w-[372px]"
48+
src={image}
49+
width={imgWidth}
7850
/>
7951
</Flex>
80-
<Flex
81-
textAlign="start"
82-
flexDirection="column"
83-
justifyContent="space-between"
84-
>
85-
<Box>
86-
<Heading
87-
as="h3"
88-
size="lg"
89-
fontSize="2xl"
90-
fontWeight="600"
91-
lineHeight="1.4"
92-
my={8}
93-
mx={4}
94-
mb={4}
95-
>
96-
<LinkOverlay href={url} isExternal>
97-
{name}
52+
<Flex className="flex-col justify-between text-left">
53+
<div>
54+
<h3 className="mx-4 my-8 mb-4 text-2xl font-semibold">
55+
<LinkOverlay asChild>
56+
<InlineLink href={url} hideArrow>
57+
{name}
58+
</InlineLink>
9859
</LinkOverlay>
99-
</Heading>
100-
<Text fontSize="sm" mx={4} mb={4} lineHeight="140%">
101-
{description}
102-
</Text>
103-
</Box>
60+
</h3>
61+
<p className="mx-4 mb-4 text-sm leading-[140%]">{description}</p>
62+
</div>
10463
{data && (
105-
<Box
106-
overflowY="scroll"
107-
maxHeight="160px"
108-
mb={4}
109-
borderTop="1px solid"
110-
borderColor="lightBorder"
111-
>
64+
<div className="mb-4 max-h-[160px] overflow-y-scroll border-t">
11265
{data.map(({ logo, coin, apy }, idx) => (
11366
<Flex
11467
key={idx}
115-
color="text300"
116-
fontSize="sm"
117-
justify="space-between"
118-
p={4}
119-
textTransform="uppercase"
120-
border="1px solid"
121-
borderColor="lightBorder"
122-
borderInlineStart="0"
123-
borderInlineEnd="0"
68+
className="justify-between border border-x-0 p-4 text-sm uppercase"
12469
>
125-
<Flex alignItems="center">
70+
<Flex className="items-center">
12671
{logo && (
127-
<Image
72+
<TwImage
73+
className="me-2 min-w-6 object-cover"
12874
src={logo}
129-
objectFit="cover"
13075
alt=""
131-
minWidth="24px"
132-
me={2}
13376
/>
13477
)}
13578
{coin}
13679
</Flex>
137-
<Flex alignItems="center">{apy}% APY</Flex>
80+
<Flex className="items-center">{apy}% APY</Flex>
13881
</Flex>
13982
))}
140-
</Box>
83+
</div>
14184
)}
14285
</Flex>
14386
</LinkBox>

src/pages/stablecoins.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ const StablecoinsPage = ({ markets, marketsHasError }) => {
349349
url: "https://aave.com",
350350
alt: t("aave-logo"),
351351
image: aaveImg,
352-
width: "64px",
352+
width: 64,
353353
name: "Aave",
354354
description: t("page-stablecoins-stablecoins-dapp-description-1"),
355355
},
@@ -358,7 +358,7 @@ const StablecoinsPage = ({ markets, marketsHasError }) => {
358358
url: "https://compound.finance",
359359
alt: t("compound-logo"),
360360
image: compoundImg,
361-
width: "160px",
361+
width: 160,
362362
name: "Compound",
363363
description: t("page-stablecoins-stablecoins-dapp-description-2"),
364364
},
@@ -367,7 +367,7 @@ const StablecoinsPage = ({ markets, marketsHasError }) => {
367367
url: "https://summer.fi/",
368368
alt: t("summerfi-logo"),
369369
image: summerfiImg,
370-
width: "80px",
370+
width: 80,
371371
name: "Summer.fi",
372372
description: t("page-stablecoins-stablecoins-dapp-description-4"),
373373
},

0 commit comments

Comments
 (0)