Skip to content

Commit b77cf93

Browse files
authored
Merge pull request #14811 from iusx/dev
[ShadCN]: Fix #13405 and end #13523 use shadcn
2 parents a2d75ae + b8ce23b commit b77cf93

File tree

1 file changed

+44
-43
lines changed

1 file changed

+44
-43
lines changed

src/components/DocsNav.tsx

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
1+
import { FaChevronLeft, FaChevronRight } from "react-icons/fa"
2+
13
import { TranslationKey } from "@/lib/types"
24
import type { DeveloperDocsLink } from "@/lib/interfaces"
35

4-
import Emoji from "@/components/Emoji"
6+
import { BaseLink } from "@/components/ui/Link"
57

68
import { cn } from "@/lib/utils/cn"
79
import { trackCustomEvent } from "@/lib/utils/matomo"
810

911
import docLinks from "@/data/developer-docs-links.yaml"
1012

11-
import { Stack } from "./ui/flex"
12-
import { LinkBox, LinkOverlay } from "./ui/link-box"
13-
1413
import { useRtlFlip } from "@/hooks/useRtlFlip"
1514
import { useTranslation } from "@/hooks/useTranslation"
1615
import { usePathname } from "@/i18n/routing"
1716

1817
const TextDiv = ({ children, className, ...props }) => (
19-
<Stack
18+
<div
2019
className={cn(
21-
"h-full max-w-[166px] justify-between gap-0 break-words p-4",
20+
"flex h-full w-full flex-col justify-center break-words p-4",
2221
className
2322
)}
2423
{...props}
2524
>
2625
{children}
27-
</Stack>
26+
</div>
2827
)
2928

3029
type DocsArrayProps = {
@@ -40,43 +39,45 @@ type CardLinkProps = {
4039

4140
const CardLink = ({ docData, isPrev, contentNotTranslated }: CardLinkProps) => {
4241
const { t } = useTranslation("page-developers-docs")
43-
const { isRtl } = useRtlFlip()
42+
const { twFlipForRtl } = useRtlFlip()
4443

4544
return (
46-
<LinkBox
45+
<BaseLink
46+
href={docData.href}
4747
className={cn(
48-
"flex w-full flex-1 items-center no-underline",
49-
"h-[82px] rounded-sm border bg-background",
50-
isPrev ? "justify-start" : "justify-end"
48+
"group flex w-full items-center rounded-sm border border-primary bg-background !no-underline",
49+
isPrev ? "justify-start" : "justify-end",
50+
"hover:border-primary-hover"
5151
)}
52+
rel={isPrev ? "prev" : "next"}
53+
onClick={() => {
54+
trackCustomEvent({
55+
eventCategory: "next/previous article DocsNav",
56+
eventAction: "click",
57+
eventName: isPrev ? "previous" : "next",
58+
})
59+
}}
5260
>
53-
<div className={cn("h-full p-4", isPrev ? "order-[0]" : "order-1")}>
54-
<Emoji
55-
text={isPrev ? ":point_left:" : ":point_right:"}
56-
className={cn(
57-
"text-5xl",
58-
!contentNotTranslated && isRtl ? "-scale-x-100" : ""
59-
)}
60-
/>
61+
<div
62+
className={cn(
63+
"p-4",
64+
isPrev ? "order-0" : "order-1",
65+
!contentNotTranslated && twFlipForRtl
66+
)}
67+
>
68+
{isPrev ? (
69+
<FaChevronLeft className="text-xl group-hover:fill-primary-hover" />
70+
) : (
71+
<FaChevronRight className="text-xl group-hover:fill-primary-hover" />
72+
)}
6173
</div>
62-
<TextDiv className={cn(!isPrev ? "pe-0 text-end" : "ps-0")}>
63-
<p className="uppercase text-body">{t(isPrev ? "previous" : "next")}</p>
64-
<LinkOverlay
65-
href={docData.href}
66-
onClick={() => {
67-
trackCustomEvent({
68-
eventCategory: "next/previous article DocsNav",
69-
eventAction: "click",
70-
eventName: isPrev ? "previous" : "next",
71-
})
72-
}}
73-
className={cn("underline", isPrev ? "text-start" : "text-end")}
74-
rel={isPrev ? "prev" : "next"}
75-
>
76-
{t(docData.id)}
77-
</LinkOverlay>
74+
<TextDiv className={cn(isPrev ? "ps-0" : "pe-0 text-end")}>
75+
<p className="btn-txt !m-0 text-lg text-primary group-hover:text-primary-hover">
76+
{t(isPrev ? "previous" : "next")}
77+
</p>
78+
<p className="!mb-0 text-sm no-underline">{t(docData.id)}</p>
7879
</TextDiv>
79-
</LinkBox>
80+
</BaseLink>
8081
)
8182
}
8283

@@ -89,11 +90,11 @@ const DocsNav = ({ contentNotTranslated }: DocsNavProps) => {
8990
// Construct array of all linkable documents in order recursively
9091
const docsArray: DocsArrayProps[] = []
9192
const getDocs = (links: Array<DeveloperDocsLink>): void => {
93+
// If object has 'items' key
9294
for (const item of links) {
93-
// If object has 'items' key
95+
// And if item has a 'to' key
96+
// Add 'to' path and 'id' to docsArray
9497
if (item.items) {
95-
// And if item has a 'to' key
96-
// Add 'to' path and 'id' to docsArray
9798
item.href && docsArray.push({ href: item.href, id: item.id })
9899
// Then recursively add sub-items
99100
getDocs(item.items)
@@ -128,7 +129,7 @@ const DocsNav = ({ contentNotTranslated }: DocsNavProps) => {
128129
className={cn(
129130
"flex flex-col-reverse md:flex-row lg:flex-col-reverse xl:flex-row",
130131
"mt-8 justify-between gap-4",
131-
"items-center md:items-start"
132+
"items-stretch"
132133
)}
133134
aria-label="Paginate to document"
134135
>
@@ -139,15 +140,15 @@ const DocsNav = ({ contentNotTranslated }: DocsNavProps) => {
139140
isPrev
140141
/>
141142
) : (
142-
<div className="hidden flex-grow xl:block"></div>
143+
<div className="hidden flex-grow xl:block" />
143144
)}
144145
{nextDoc ? (
145146
<CardLink
146147
docData={nextDoc}
147148
contentNotTranslated={contentNotTranslated}
148149
/>
149150
) : (
150-
<div className="hidden flex-grow xl:block"></div>
151+
<div className="hidden flex-grow xl:block" />
151152
)}
152153
</nav>
153154
)

0 commit comments

Comments
 (0)