Skip to content

Commit 6ba7382

Browse files
authored
Merge pull request #14036 from saurabhburade/shadcn-migrate/DocLink
Shadcn migration - DocLink
2 parents b7fcc90 + 11a84d6 commit 6ba7382

File tree

1 file changed

+27
-58
lines changed

1 file changed

+27
-58
lines changed

src/components/DocLink.tsx

Lines changed: 27 additions & 58 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 { LinkBox, LinkOverlay } from "./ui/link-box"
117
import Emoji from "./Emoji"
12-
import { BaseLink } from "./Link"
13-
import Text from "./OldText"
148

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

@@ -21,61 +15,36 @@ export type DocLinkProps = {
2115
}
2216

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

2720
return (
2821
<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-
}}
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+
)}
4027
>
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">
28+
<Flex className="flex-1 justify-between">
29+
<Center>
5030
<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}>
31+
</Center>
32+
<Stack className="flex-1">
33+
<LinkOverlay href={href} className="no-underline">
34+
<p className="font-bold text-gray-600 dark:text-gray-200">
6235
{children}
63-
</Text>
36+
</p>
6437
</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}
38+
</Stack>
39+
40+
<AiOutlineArrowRight
41+
className={cn(
42+
"mx-6 h-6 w-6 self-center",
43+
"transition-transform duration-100 group-hover:scale-[1.2] group-hover:fill-primary",
44+
isExternal ? "-rotate-45" : "rotate-0",
45+
isRtl && isExternal ? "-rotate-[135deg]" : "",
46+
isRtl && !isExternal ? "-rotate-[180deg]" : ""
47+
)}
7948
/>
8049
</Flex>
8150
</LinkBox>

0 commit comments

Comments
 (0)