Skip to content

Commit b86fd64

Browse files
committed
feat: migrate DocLink to tailwind
1 parent f2ab047 commit b86fd64

File tree

1 file changed

+28
-61
lines changed

1 file changed

+28
-61
lines changed

src/components/DocLink.tsx

Lines changed: 28 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
import { AiOutlineArrowRight } from "react-icons/ai"
2-
import {
3-
Box,
4-
Flex,
5-
Icon,
6-
LinkBox,
7-
LinkOverlay,
8-
useToken,
9-
} from "@chakra-ui/react"
102

3+
import { cn } from "@/lib/utils/cn"
4+
5+
import { Center, Flex, Stack } from "./ui/flex"
6+
import { BaseLink } from "./ui/Link"
117
import Emoji from "./Emoji"
12-
import { BaseLink } from "./Link"
13-
import Text from "./OldText"
148

159
import { useRtlFlip } from "@/hooks/useRtlFlip"
1610

@@ -21,64 +15,37 @@ export type DocLinkProps = {
2115
}
2216

2317
const DocLink = ({ href, children, isExternal = false }: DocLinkProps) => {
24-
const linkBoxShadowColor = useToken("colors", "primary.base")
2518
const { flipForRtl } = useRtlFlip()
2619

2720
return (
28-
<LinkBox
29-
padding={4}
30-
borderRadius="sm"
31-
color="text"
32-
border="1px"
33-
borderStyle="solid"
34-
borderColor="border"
35-
_hover={{
36-
background: "tableBackgroundHover",
37-
borderRadius: "base",
38-
boxShadow: `0 0 1px ${linkBoxShadowColor}`,
39-
}}
21+
<BaseLink
22+
className={cn(
23+
"flex rounded-sm border p-4 text-current no-underline",
24+
"hover:rounded hover:bg-background-highlight hover:no-underline",
25+
"group hover:shadow-[0_0_1px] hover:shadow-primary"
26+
)}
27+
href={href}
4028
>
41-
<Flex
42-
zIndex={1}
43-
display="flex"
44-
flexDirection="row"
45-
flex={1}
46-
justifyContent="space-between"
47-
data-group
48-
>
49-
<Flex align="center">
29+
<Flex className="flex-1 justify-between">
30+
<Center>
5031
<Emoji className="me-4 text-md" text=":page_with_curl:" />
51-
</Flex>
52-
<Box flex={1} flexDirection="column">
53-
<LinkOverlay
54-
href={href}
55-
as={BaseLink}
56-
isExternal={isExternal}
57-
textDecoration="none"
58-
_hover={{ textDecoration: "none" }}
59-
hideArrow
60-
>
61-
<Text color="text300" fontWeight="semibold" margin={0}>
62-
{children}
63-
</Text>
64-
</LinkOverlay>
65-
</Box>
66-
<Icon
67-
as={AiOutlineArrowRight}
68-
alignSelf="center"
69-
minWidth={8}
70-
boxSize={6}
71-
marginX={6}
72-
_groupHover={{
73-
fill: "primary.base",
74-
transition: "transform 0.1s",
75-
transform: `${flipForRtl} scale(1.2)`,
76-
rotate: isExternal ? "-45deg" : "0",
77-
}}
78-
transform={flipForRtl}
32+
</Center>
33+
<Stack className="flex-1">
34+
<p className="font-semibold text-[#4c4c4c] dark:text-[#cccccc]">
35+
{children}
36+
</p>
37+
</Stack>
38+
39+
<AiOutlineArrowRight
40+
className={cn(
41+
"mx-6 h-6 w-6 self-center",
42+
"transition-transform duration-100 group-hover:scale-[1.2] group-hover:fill-primary",
43+
isExternal ? "-rotate-45" : "rotate-0",
44+
flipForRtl && isExternal ? "-rotate-[135deg]" : ""
45+
)}
7946
/>
8047
</Flex>
81-
</LinkBox>
48+
</BaseLink>
8249
)
8350
}
8451

0 commit comments

Comments
 (0)