Skip to content

Commit 92bea77

Browse files
committed
Migrate ActionCard.tsx to tailwind
1 parent 78f2ae3 commit 92bea77

File tree

1 file changed

+34
-73
lines changed

1 file changed

+34
-73
lines changed

src/components/ActionCard.tsx

Lines changed: 34 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,17 @@
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"
3+
import { useColorModeValue } from "@chakra-ui/react"
134

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

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-
}
29-
30-
export type ActionCardProps = Omit<LinkBoxProps, "title"> & {
9+
import { Flex } from "./ui/flex"
10+
export type ActionCardProps = Omit<
11+
BaseHTMLAttributes<HTMLDivElement>,
12+
"title"
13+
> & {
14+
as?: ElementType
3115
children?: ReactNode
3216
href: string
3317
alt?: string
@@ -53,64 +37,41 @@ const ActionCard = ({
5337
isBottom = true,
5438
...props
5539
}: ActionCardProps) => {
56-
const descriptionColor = useColorModeValue("blackAlpha.700", "whiteAlpha.800")
40+
const descriptionColor = useColorModeValue(
41+
"text-black opacity-65",
42+
"text-white opacity-80"
43+
)
5744

5845
return (
5946
<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}
47+
className={`focus:bg-table-bg-hover m-4 flex flex-none 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 ${className}`}
6948
{...props}
7049
>
7150
<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)"
51+
className={`action-card-image-wrapper flex h-[260px] flex-row bg-gradient-to-r from-accent-a/10 to-accent-c/10 ${isBottom ? "items-end" : "items-center"} ${isRight ? "justify-end" : "justify-center"} shadow-[inset_0px_-1px_0px_rgba(0,0,0,0.1)]`}
7952
>
80-
<Image
53+
<TwImage
8154
src={image}
82-
width={imageWidth}
83-
maxH="full"
8455
alt={alt || ""}
85-
style={{ objectFit: "cover" }}
56+
className="max-h-full object-cover"
57+
style={{ width: `${imageWidth}px` }}
8658
/>
8759
</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}
60+
<div className="action-card-content p-6">
61+
<h3 className="mb-4 mt-2 text-2xl font-semibold leading-snug">
62+
<LinkOverlay asChild>
63+
<InlineLink
64+
href={href}
65+
hideArrow
66+
className="text-body no-underline hover:no-underline focus:no-underline"
67+
>
68+
{title}
69+
</InlineLink>
10770
</LinkOverlay>
108-
</Heading>
109-
<Text mb={0} color={descriptionColor}>
110-
{description}
111-
</Text>
112-
{children && <Box mt={8}>{children}</Box>}
113-
</Box>
71+
</h3>
72+
<p className={`mb-0 ${descriptionColor}`}>{description}</p>
73+
{children && <div className="mt-8">{children}</div>}
74+
</div>
11475
</LinkBox>
11576
)
11677
}

0 commit comments

Comments
 (0)