Skip to content

Commit d15d2ff

Browse files
committed
fix: flip specific icons for rtl
1 parent b68b738 commit d15d2ff

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/components/Homepage/useHome.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useRouter } from "next/router"
33
import { useTranslation } from "next-i18next"
44
import { FaDiscord, FaGithub, FaXTwitter } from "react-icons/fa6"
55

6-
import type { EventCardProps, Lang } from "@/lib/types"
6+
import type { EventCardProps } from "@/lib/types"
77
import type { CodeExample } from "@/lib/interfaces"
88

99
import { useBentoBox } from "@/components/Homepage/useBentoBox"
@@ -16,8 +16,8 @@ import TryAppsIcon from "@/components/icons/phone-homescreen.svg"
1616
import RoadmapSign from "@/components/icons/roadmap-sign.svg"
1717
import Whitepaper from "@/components/icons/whitepaper.svg"
1818

19+
import { cn } from "@/lib/utils/cn"
1920
import { isValidDate } from "@/lib/utils/date"
20-
import { isLangRightToLeft } from "@/lib/utils/translations"
2121

2222
import events from "@/data/community-events.json"
2323
import CreateWalletContent from "@/data/CreateWallet"
@@ -27,6 +27,7 @@ import { GITHUB_REPO_URL } from "@/lib/constants"
2727
import SimpleDomainRegistryContent from "!!raw-loader!@/data/SimpleDomainRegistry.sol"
2828
import SimpleTokenContent from "!!raw-loader!@/data/SimpleToken.sol"
2929
import SimpleWalletContent from "!!raw-loader!@/data/SimpleWallet.sol"
30+
import { useRtlFlip } from "@/hooks/useRtlFlip"
3031

3132
export const useHome = () => {
3233
const { t } = useTranslation(["common", "page-index"])
@@ -37,7 +38,7 @@ export const useHome = () => {
3738

3839
const bentoItems = useBentoBox()
3940

40-
const dir = isLangRightToLeft(locale as Lang) ? "rtl" : "ltr"
41+
const { direction, isRtl } = useRtlFlip()
4142

4243
const toggleCodeExample = (id: number): void => {
4344
setActiveCode(id)
@@ -106,7 +107,10 @@ export const useHome = () => {
106107
description: t("page-index:page-index-cta-dapps-description"),
107108
href: "/dapps/",
108109
Svg: TryAppsIcon,
109-
className: "text-accent-c hover:text-accent-c-hover",
110+
className: cn(
111+
"text-accent-c hover:text-accent-c-hover",
112+
isRtl && "[&_svg]:-scale-x-100"
113+
),
110114
},
111115
]
112116

@@ -129,11 +133,13 @@ export const useHome = () => {
129133
{
130134
label: t("page-index:page-index-popular-topics-whitepaper"),
131135
Svg: Whitepaper,
136+
className: cn(isRtl && "[&_svg]:-scale-x-100"),
132137
href: "/whitepaper/",
133138
},
134139
{
135140
label: t("page-index:page-index-popular-topics-roadmap"),
136141
Svg: RoadmapSign,
142+
className: cn(isRtl && "[&_svg]:-scale-x-100"),
137143
href: "/roadmap/",
138144
},
139145
]
@@ -188,7 +194,7 @@ export const useHome = () => {
188194
t,
189195
locale,
190196
asPath,
191-
dir,
197+
dir: direction,
192198
isModalOpen,
193199
setModalOpen,
194200
activeCode,

src/pages/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,15 @@ const HomePage = ({
313313
{t("page-index:page-index-popular-topics-header")}
314314
</h3>
315315
<div className="grid grid-cols-1 gap-8 sm:grid-cols-2 md:grid-cols-1 lg:grid-cols-2">
316-
{popularTopics.map(({ label, Svg, href }) => (
316+
{popularTopics.map(({ label, Svg, href, className }) => (
317317
<SvgButtonLink
318318
key={label}
319319
Svg={Svg}
320320
href={href}
321-
className="text-accent-b hover:text-accent-b-hover [&>:first-child]:flex-row"
321+
className={cn(
322+
"text-accent-b hover:text-accent-b-hover [&>:first-child]:flex-row",
323+
className
324+
)}
322325
>
323326
<p className="text-start text-xl font-bold text-body group-hover:underline">
324327
{label}

0 commit comments

Comments
 (0)