Skip to content

Commit 9671459

Browse files
committed
refactor: create tw rtl-reponsive next/prev icons
as "Chevron" file with `ChevronNext` and `ChevronPrev` exports, deprecating non-tailwind "NextChevron" from nav component structure; updated references
1 parent 6d1f252 commit 9671459

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

src/components/Chevron/index.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { MdChevronLeft, MdChevronRight } from "react-icons/md"
2+
3+
import { cn } from "@/lib/utils/cn"
4+
5+
import { useRtlFlip } from "@/hooks/useRtlFlip"
6+
7+
export const ChevronNext = ({
8+
className,
9+
...props
10+
}: React.HTMLAttributes<SVGElement>) => {
11+
const { twFlipForRtl } = useRtlFlip()
12+
return <MdChevronRight className={cn(className, twFlipForRtl)} {...props} />
13+
}
14+
15+
export const ChevronPrev = ({
16+
className,
17+
...props
18+
}: React.HTMLAttributes<SVGElement>) => {
19+
const { twFlipForRtl } = useRtlFlip()
20+
return <MdChevronLeft className={cn(className, twFlipForRtl)} {...props} />
21+
}

src/components/Nav/Menu/NextChevron.tsx

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/components/Nav/Menu/SubMenu.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
} from "@radix-ui/react-navigation-menu"
2020

2121
import { ButtonProps } from "@/components/Buttons"
22+
import { ChevronNext } from "@/components/Chevron"
2223
import Link from "@/components/Link"
2324

2425
import { trackCustomEvent } from "@/lib/utils/matomo"
@@ -27,7 +28,6 @@ import { cleanPath } from "@/lib/utils/url"
2728
import type { Level, NavItem, NavSectionKey } from "../types"
2829

2930
import ItemContent from "./ItemContent"
30-
import NextChevron from "./NextChevron"
3131
import { useSubMenu } from "./useSubMenu"
3232

3333
type LvlContentProps = {
@@ -83,7 +83,7 @@ const SubMenu = ({ lvl, items, activeSection, onClose }: LvlContentProps) => {
8383
const buttonProps: ButtonProps = {
8484
color: menuColors.body,
8585
leftIcon: lvl === 1 && icon ? <Icon as={icon} /> : undefined,
86-
rightIcon: isLink ? undefined : <NextChevron />,
86+
rightIcon: isLink ? undefined : <ChevronNext />,
8787
position: "relative",
8888
w: "full",
8989
me: -PADDING,

0 commit comments

Comments
 (0)