Skip to content

Commit 12595c4

Browse files
authored
Merge pull request #14244 from yun-chiao/migrate/action-card
Migrate ActionCard.tsx to tailwind
2 parents 34bab34 + 89d1915 commit 12595c4

File tree

4 files changed

+43
-125
lines changed

4 files changed

+43
-125
lines changed

src/components/ActionCard.tsx

Lines changed: 37 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,18 @@
11
import { StaticImageData } from "next/image"
2-
import type { ReactNode } from "react"
3-
import {
4-
Box,
5-
type BoxProps,
6-
Flex,
7-
Heading,
8-
LinkBox,
9-
type LinkBoxProps,
10-
LinkOverlay,
11-
useColorModeValue,
12-
} from "@chakra-ui/react"
2+
import type { BaseHTMLAttributes, ElementType, ReactNode } from "react"
133

14-
import { Image } from "@/components/Image"
15-
import { BaseLink } from "@/components/Link"
16-
import Text from "@/components/OldText"
4+
import { TwImage } from "@/components/Image"
5+
import InlineLink from "@/components/ui/Link"
6+
import { LinkBox, LinkOverlay } from "@/components/ui/link-box"
177

18-
const linkBoxFocusStyles: BoxProps = {
19-
borderRadius: "base",
20-
boxShadow: "0px 8px 17px rgba(0, 0, 0, 0.15)",
21-
bg: "tableBackgroundHover",
22-
transition: "transform 0.1s",
23-
transform: "scale(1.02)",
24-
}
25-
26-
const linkFocusStyles: BoxProps = {
27-
textDecoration: "none",
28-
}
8+
import { cn } from "@/lib/utils/cn"
299

30-
export type ActionCardProps = Omit<LinkBoxProps, "title"> & {
10+
import { Flex } from "./ui/flex"
11+
export type ActionCardProps = Omit<
12+
BaseHTMLAttributes<HTMLDivElement>,
13+
"title"
14+
> & {
15+
as?: ElementType
3116
children?: ReactNode
3217
href: string
3318
alt?: string
@@ -53,64 +38,43 @@ const ActionCard = ({
5338
isBottom = true,
5439
...props
5540
}: ActionCardProps) => {
56-
const descriptionColor = useColorModeValue("blackAlpha.700", "whiteAlpha.800")
57-
5841
return (
5942
<LinkBox
60-
boxShadow="
61-
0px 14px 66px rgba(0, 0, 0, 0.07),
62-
0px 10px 17px rgba(0, 0, 0, 0.03), 0px 4px 7px rgba(0, 0, 0, 0.05)"
63-
color="text"
64-
flex="1 1 372px"
65-
_hover={linkBoxFocusStyles}
66-
_focus={linkBoxFocusStyles}
67-
className={className}
68-
m={4}
43+
className={cn(
44+
"flex shadow-table hover:scale-[1.02] hover:rounded hover:bg-background-highlight hover:shadow-table-box-hover hover:duration-100 focus:scale-[1.02] focus:rounded focus:shadow-table-box-hover focus:duration-100",
45+
className
46+
)}
6947
{...props}
7048
>
7149
<Flex
72-
h="260px"
73-
bg="cardGradient"
74-
direction="row"
75-
justify={isRight ? "flex-end" : "center"}
76-
align={isBottom ? "flex-end" : "center"}
77-
className="action-card-image-wrapper"
78-
boxShadow="inset 0px -1px 0px rgba(0, 0, 0, 0.1)"
50+
className={cn(
51+
"flex h-[260px] flex-row bg-gradient-to-r from-accent-a/10 to-accent-c/10",
52+
isBottom ? "items-end" : "items-center",
53+
isRight ? "justify-end" : "justify-center"
54+
)}
7955
>
80-
<Image
56+
<TwImage
8157
src={image}
82-
width={imageWidth}
83-
maxH="full"
8458
alt={alt || ""}
85-
style={{ objectFit: "cover" }}
59+
width={imageWidth}
60+
className="max-h-full object-cover p-4"
8661
/>
8762
</Flex>
88-
<Box p={6} className="action-card-content">
89-
<Heading
90-
as="h3"
91-
fontSize="2xl"
92-
mt={2}
93-
mb={4}
94-
fontWeight={600}
95-
lineHeight={1.4}
96-
>
97-
<LinkOverlay
98-
as={BaseLink}
99-
color="text"
100-
hideArrow
101-
textDecoration="none"
102-
href={href}
103-
_hover={linkFocusStyles}
104-
_focus={linkFocusStyles}
105-
>
106-
{title}
63+
<div className="flex flex-col justify-center p-6">
64+
<h3 className="mb-4 mt-2 text-2xl font-semibold leading-snug">
65+
<LinkOverlay asChild>
66+
<InlineLink
67+
href={href}
68+
hideArrow
69+
className="text-body no-underline"
70+
>
71+
{title}
72+
</InlineLink>
10773
</LinkOverlay>
108-
</Heading>
109-
<Text mb={0} color={descriptionColor}>
110-
{description}
111-
</Text>
112-
{children && <Box mt={8}>{children}</Box>}
113-
</Box>
74+
</h3>
75+
<p className={"mb-0 text-body/65"}>{description}</p>
76+
{children && <div className="mt-8">{children}</div>}
77+
</div>
11478
</LinkBox>
11579
)
11680
}

src/pages/community.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,8 @@ const CommunityPage = () => {
299299
</Flex>
300300
<SimpleGrid columns={{ base: 1, lg: 2 }} spacing={{ base: 8, lg: 0 }}>
301301
{cards.map((card, idx) => (
302-
<Box
303-
as={ActionCard}
304-
minW={{ base: "min(100%, 240px)", lg: "440px" }}
305-
m={{ base: 0, lg: 4 }}
306-
borderRadius="sm"
307-
border="1px solid"
308-
borderColor="text"
309-
bg="background.base"
310-
boxShadow={theme.colors.cardBoxShadow}
302+
<ActionCard
303+
className="m-0 flex-col rounded-sm border lg:m-4"
311304
key={idx}
312305
title={card.title}
313306
description={card.description}

src/pages/contributing/translation-program/acknowledgements.tsx

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,9 @@ const TranslatorAcknowledgements = () => {
198198
"page-contributing-translation-program-acknowledgements-our-translators-1"
199199
)}
200200
</Text>
201-
<Box
202-
as={ActionCard}
201+
<ActionCard
202+
className="my-8"
203+
imageWidth={260}
203204
href="/contributing/translation-program/contributors/"
204205
title={t(
205206
"page-contributing-translation-program-acknowledgements-our-translators-view-all"
@@ -208,25 +209,6 @@ const TranslatorAcknowledgements = () => {
208209
"page-contributing-translation-program-acknowledgements-our-translators-cta"
209210
)}
210211
image={whatIsEthereumImg}
211-
display={{ base: "block", sm: "flex" }}
212-
flex="none"
213-
my={8}
214-
mx={0}
215-
sx={{
216-
".action-card-image-wrapper": {
217-
p: 4,
218-
minW: { sm: "260px" },
219-
},
220-
".action-card-content": {
221-
display: { sm: "flex" },
222-
justifyContent: { sm: "center" },
223-
flexDirection: { sm: "column" },
224-
ms: { sm: 4 },
225-
},
226-
p: {
227-
mb: 0,
228-
},
229-
}}
230212
/>
231213
</Content>
232214

src/pages/eth.tsx

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -241,28 +241,7 @@ const CentralColumn = (props: ChildOnlyProp) => (
241241
)
242242

243243
const CentralActionCard = (props: ComponentProps<typeof ActionCard>) => (
244-
<ActionCard
245-
display={{ base: "block", sm: "flex" }}
246-
flex="none"
247-
my={8}
248-
mx={0}
249-
sx={{
250-
".action-card-image-wrapper": {
251-
p: 4,
252-
minW: { sm: "260px" },
253-
},
254-
".action-card-content": {
255-
display: { sm: "flex" },
256-
justifyContent: { sm: "center" },
257-
flexDirection: { sm: "column" },
258-
ms: { sm: 4 },
259-
},
260-
p: {
261-
mb: { sm: 0 },
262-
},
263-
}}
264-
{...props}
265-
/>
244+
<ActionCard className="my-8" imageWidth={260} {...props} />
266245
)
267246

268247
export const getStaticProps = (async ({ locale }) => {

0 commit comments

Comments
 (0)