Skip to content

Commit 53043ec

Browse files
committed
feat: migrate DocsNav to tailwind
1 parent f2ab047 commit 53043ec

File tree

1 file changed

+39
-67
lines changed

1 file changed

+39
-67
lines changed

src/components/DocsNav.tsx

Lines changed: 39 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,30 @@
11
import { useRouter } from "next/router"
22
import { useTranslation } from "next-i18next"
3-
import {
4-
Box,
5-
Flex,
6-
FlexProps,
7-
LinkBox,
8-
LinkOverlay,
9-
Spacer,
10-
} from "@chakra-ui/react"
113

124
import { TranslationKey } from "@/lib/types"
135
import type { DeveloperDocsLink } from "@/lib/interfaces"
146

157
import Emoji from "@/components/Emoji"
16-
import { BaseLink } from "@/components/Link"
17-
import Text from "@/components/OldText"
188

199
import { cn } from "@/lib/utils/cn"
20-
import { trackCustomEvent } from "@/lib/utils/matomo"
2110

2211
import docLinks from "@/data/developer-docs-links.yaml"
2312

13+
import { Flex, Stack } from "./ui/flex"
14+
import { BaseLink } from "./ui/Link"
15+
2416
import { useRtlFlip } from "@/hooks/useRtlFlip"
2517

26-
const TextDiv = ({ children, ...props }: FlexProps) => (
27-
<Flex
28-
direction="column"
29-
justify="space-between"
30-
maxW="166px"
31-
h="100%"
32-
wordwrap="break-word"
33-
p={4}
34-
lineHeight={4}
18+
const TextDiv = ({ children, className, ...props }) => (
19+
<Stack
20+
className={cn(
21+
"h-full max-w-[166px] justify-between gap-0 break-words p-4",
22+
className
23+
)}
3524
{...props}
3625
>
3726
{children}
38-
</Flex>
27+
</Stack>
3928
)
4029

4130
type DocsArrayProps = {
@@ -53,51 +42,40 @@ const CardLink = ({ docData, isPrev, contentNotTranslated }: CardLinkProps) => {
5342
const { t } = useTranslation("page-developers-docs")
5443
const { isRtl } = useRtlFlip()
5544

56-
const xPadding = isPrev ? { ps: "0" } : { pe: 0 }
45+
const xPaddingClass = isPrev ? "ps-0" : "pe-0"
5746

5847
return (
59-
<LinkBox
60-
as={Flex}
61-
alignItems="center"
62-
w="full"
63-
flex="1"
64-
h="82px"
65-
bg="background.base"
66-
border="1px"
67-
borderColor="border"
68-
borderRadius={1}
69-
justify={isPrev ? "flex-start" : "flex-end"}
48+
<BaseLink
49+
href={docData.href}
50+
className={cn(
51+
"flex w-full flex-1 items-center no-underline",
52+
"h-[82px] rounded-[1px] border bg-background",
53+
isPrev ? "justify-start" : "justify-end"
54+
)}
55+
rel={isPrev ? "prev" : "next"}
56+
customEventOptions={{
57+
eventCategory: "next/previous article DocsNav",
58+
eventAction: "click",
59+
eventName: isPrev ? "previous" : "next",
60+
}}
7061
>
71-
<Box textDecoration="none" p={4} h="100%" order={isPrev ? 0 : 1}>
62+
<div className={cn("h-full p-4", isPrev ? "order-[0]" : "order-1")}>
7263
<Emoji
7364
text={isPrev ? ":point_left:" : ":point_right:"}
7465
className={cn(
7566
"text-5xl",
7667
!contentNotTranslated && isRtl ? "-scale-x-100" : ""
7768
)}
7869
/>
79-
</Box>
80-
<TextDiv {...xPadding} {...(!isPrev && { textAlign: "end" })}>
81-
<Text textTransform="uppercase" m="0">
82-
{t(isPrev ? "previous" : "next")}
83-
</Text>
84-
<LinkOverlay
85-
as={BaseLink}
86-
href={docData.href}
87-
textAlign={isPrev ? "start" : "end"}
88-
rel={isPrev ? "prev" : "next"}
89-
onClick={() => {
90-
trackCustomEvent({
91-
eventCategory: "next/previous article DocsNav",
92-
eventAction: "click",
93-
eventName: isPrev ? "previous" : "next",
94-
})
95-
}}
96-
>
70+
</div>
71+
<TextDiv className={cn(xPaddingClass, !isPrev ? "text-end" : "")}>
72+
<p className="uppercase text-body">{t(isPrev ? "previous" : "next")}</p>
73+
74+
<p className={cn("underline", isPrev ? "text-start" : "text-end")}>
9775
{t(docData.id)}
98-
</LinkOverlay>
76+
</p>
9977
</TextDiv>
100-
</LinkBox>
78+
</BaseLink>
10179
)
10280
}
10381

@@ -146,18 +124,12 @@ const DocsNav = ({ contentNotTranslated }: DocsNavProps) => {
146124

147125
return (
148126
<Flex
149-
as="nav"
127+
className={cn(
128+
"flex-col-reverse md:flex-row lg:flex-col-reverse xl:flex-row",
129+
"mt-8 justify-between gap-4",
130+
"items-center md:items-start"
131+
)}
150132
aria-label="Paginate to document"
151-
direction={{
152-
base: "column-reverse",
153-
md: "row",
154-
lg: "column-reverse",
155-
xl: "row",
156-
}}
157-
mt="8"
158-
gap="4"
159-
justify="space-between"
160-
alignItems={{ base: "center", md: "flex-start" }}
161133
>
162134
{previousDoc ? (
163135
<CardLink
@@ -166,15 +138,15 @@ const DocsNav = ({ contentNotTranslated }: DocsNavProps) => {
166138
isPrev
167139
/>
168140
) : (
169-
<Spacer />
141+
<div className="hidden flex-grow xl:block"></div>
170142
)}
171143
{nextDoc ? (
172144
<CardLink
173145
docData={nextDoc}
174146
contentNotTranslated={contentNotTranslated}
175147
/>
176148
) : (
177-
<Spacer />
149+
<div className="hidden flex-grow xl:block"></div>
178150
)}
179151
</Flex>
180152
)

0 commit comments

Comments
 (0)