From 53043ecef2fa0f2fa0dc3f44b2503ada3ba32174 Mon Sep 17 00:00:00 2001 From: saurabhburade Date: Thu, 3 Oct 2024 13:48:22 +0530 Subject: [PATCH 1/4] feat: migrate DocsNav to tailwind --- src/components/DocsNav.tsx | 106 ++++++++++++++----------------------- 1 file changed, 39 insertions(+), 67 deletions(-) diff --git a/src/components/DocsNav.tsx b/src/components/DocsNav.tsx index 62ee9b5ad2f..d3e639021ae 100644 --- a/src/components/DocsNav.tsx +++ b/src/components/DocsNav.tsx @@ -1,41 +1,30 @@ import { useRouter } from "next/router" import { useTranslation } from "next-i18next" -import { - Box, - Flex, - FlexProps, - LinkBox, - LinkOverlay, - Spacer, -} from "@chakra-ui/react" import { TranslationKey } from "@/lib/types" import type { DeveloperDocsLink } from "@/lib/interfaces" import Emoji from "@/components/Emoji" -import { BaseLink } from "@/components/Link" -import Text from "@/components/OldText" import { cn } from "@/lib/utils/cn" -import { trackCustomEvent } from "@/lib/utils/matomo" import docLinks from "@/data/developer-docs-links.yaml" +import { Flex, Stack } from "./ui/flex" +import { BaseLink } from "./ui/Link" + import { useRtlFlip } from "@/hooks/useRtlFlip" -const TextDiv = ({ children, ...props }: FlexProps) => ( - ( + {children} - + ) type DocsArrayProps = { @@ -53,22 +42,24 @@ const CardLink = ({ docData, isPrev, contentNotTranslated }: CardLinkProps) => { const { t } = useTranslation("page-developers-docs") const { isRtl } = useRtlFlip() - const xPadding = isPrev ? { ps: "0" } : { pe: 0 } + const xPaddingClass = isPrev ? "ps-0" : "pe-0" return ( - - +
{ !contentNotTranslated && isRtl ? "-scale-x-100" : "" )} /> - - - - {t(isPrev ? "previous" : "next")} - - { - trackCustomEvent({ - eventCategory: "next/previous article DocsNav", - eventAction: "click", - eventName: isPrev ? "previous" : "next", - }) - }} - > +
+ +

{t(isPrev ? "previous" : "next")}

+ +

{t(docData.id)} - +

-
+ ) } @@ -146,18 +124,12 @@ const DocsNav = ({ contentNotTranslated }: DocsNavProps) => { return ( {previousDoc ? ( { isPrev /> ) : ( - +
)} {nextDoc ? ( { contentNotTranslated={contentNotTranslated} /> ) : ( - +
)}
) From a093da15a4bc1c8be428f615f2e2a9ab6f38c111 Mon Sep 17 00:00:00 2001 From: saurabhburade Date: Wed, 9 Oct 2024 11:16:00 +0530 Subject: [PATCH 2/4] chore: update with suggested changes --- src/components/DocsNav.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/components/DocsNav.tsx b/src/components/DocsNav.tsx index d3e639021ae..764c30f0320 100644 --- a/src/components/DocsNav.tsx +++ b/src/components/DocsNav.tsx @@ -42,14 +42,12 @@ const CardLink = ({ docData, isPrev, contentNotTranslated }: CardLinkProps) => { const { t } = useTranslation("page-developers-docs") const { isRtl } = useRtlFlip() - const xPaddingClass = isPrev ? "ps-0" : "pe-0" - return ( { )} /> - +

{t(isPrev ? "previous" : "next")}

From 410df970069b252914b1db169247ac47b70e7c01 Mon Sep 17 00:00:00 2001 From: saurabhburade Date: Wed, 9 Oct 2024 11:21:53 +0530 Subject: [PATCH 3/4] chore: refactor with LinkBox & LinkOverlay --- src/components/DocsNav.tsx | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/components/DocsNav.tsx b/src/components/DocsNav.tsx index 764c30f0320..9f4ded86b49 100644 --- a/src/components/DocsNav.tsx +++ b/src/components/DocsNav.tsx @@ -7,11 +7,12 @@ import type { DeveloperDocsLink } from "@/lib/interfaces" import Emoji from "@/components/Emoji" import { cn } from "@/lib/utils/cn" +import { trackCustomEvent } from "@/lib/utils/matomo" import docLinks from "@/data/developer-docs-links.yaml" import { Flex, Stack } from "./ui/flex" -import { BaseLink } from "./ui/Link" +import { LinkBox, LinkOverlay } from "./ui/link-box" import { useRtlFlip } from "@/hooks/useRtlFlip" @@ -43,19 +44,12 @@ const CardLink = ({ docData, isPrev, contentNotTranslated }: CardLinkProps) => { const { isRtl } = useRtlFlip() return ( -

{

{t(isPrev ? "previous" : "next")}

- -

+ { + trackCustomEvent({ + eventCategory: "next/previous article DocsNav", + eventAction: "click", + eventName: isPrev ? "previous" : "next", + }) + }} + className={cn("underline", isPrev ? "text-start" : "text-end")} + rel={isPrev ? "prev" : "next"} + > {t(docData.id)} -

+
-
+ ) } From 26f2e05d3729fbf15332afcf05f847bf2dc0c668 Mon Sep 17 00:00:00 2001 From: Pablo Pettinari Date: Wed, 16 Oct 2024 13:18:51 +0200 Subject: [PATCH 4/4] use nav for semantics --- src/components/DocsNav.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/DocsNav.tsx b/src/components/DocsNav.tsx index 9f4ded86b49..6465116d450 100644 --- a/src/components/DocsNav.tsx +++ b/src/components/DocsNav.tsx @@ -11,7 +11,7 @@ import { trackCustomEvent } from "@/lib/utils/matomo" import docLinks from "@/data/developer-docs-links.yaml" -import { Flex, Stack } from "./ui/flex" +import { Stack } from "./ui/flex" import { LinkBox, LinkOverlay } from "./ui/link-box" import { useRtlFlip } from "@/hooks/useRtlFlip" @@ -125,9 +125,9 @@ const DocsNav = ({ contentNotTranslated }: DocsNavProps) => { currentIndex + 1 < docsArray.length ? docsArray[currentIndex + 1] : null return ( - { ) : (
)} -
+ ) }