Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homepage RTL patches #13834

Merged
merged 2 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/components/Homepage/useHome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useRouter } from "next/router"
import { useTranslation } from "next-i18next"
import { FaDiscord, FaGithub, FaXTwitter } from "react-icons/fa6"

import type { EventCardProps, Lang } from "@/lib/types"
import type { EventCardProps } from "@/lib/types"
import type { CodeExample } from "@/lib/interfaces"

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

import { cn } from "@/lib/utils/cn"
import { isValidDate } from "@/lib/utils/date"
import { isLangRightToLeft } from "@/lib/utils/translations"

import events from "@/data/community-events.json"
import CreateWalletContent from "@/data/CreateWallet"
Expand All @@ -27,6 +27,7 @@ import { GITHUB_REPO_URL } from "@/lib/constants"
import SimpleDomainRegistryContent from "!!raw-loader!@/data/SimpleDomainRegistry.sol"
import SimpleTokenContent from "!!raw-loader!@/data/SimpleToken.sol"
import SimpleWalletContent from "!!raw-loader!@/data/SimpleWallet.sol"
import { useRtlFlip } from "@/hooks/useRtlFlip"

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

const bentoItems = useBentoBox()

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

const toggleCodeExample = (id: number): void => {
setActiveCode(id)
Expand Down Expand Up @@ -106,7 +107,10 @@ export const useHome = () => {
description: t("page-index:page-index-cta-dapps-description"),
href: "/dapps/",
Svg: TryAppsIcon,
className: "text-accent-c hover:text-accent-c-hover",
className: cn(
"text-accent-c hover:text-accent-c-hover",
isRtl && "[&_svg]:-scale-x-100"
),
},
]

Expand All @@ -129,11 +133,13 @@ export const useHome = () => {
{
label: t("page-index:page-index-popular-topics-whitepaper"),
Svg: Whitepaper,
className: cn(isRtl && "[&_svg]:-scale-x-100"),
href: "/whitepaper/",
},
{
label: t("page-index:page-index-popular-topics-roadmap"),
Svg: RoadmapSign,
className: cn(isRtl && "[&_svg]:-scale-x-100"),
href: "/roadmap/",
},
]
Expand Down Expand Up @@ -188,7 +194,7 @@ export const useHome = () => {
t,
locale,
asPath,
dir,
dir: direction,
isModalOpen,
setModalOpen,
activeCode,
Expand Down
9 changes: 5 additions & 4 deletions src/components/ui/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const BaseLink = forwardRef<HTMLAnchorElement, LinkProps>(function Link(
ref
) {
const { asPath } = useRouter()
const { flipForRtl } = useRtlFlip()
const { twFlipForRtl } = useRtlFlip()

if (!href) {
console.warn("Link component is missing href prop")
Expand Down Expand Up @@ -102,9 +102,10 @@ export const BaseLink = forwardRef<HTMLAnchorElement, LinkProps>(function Link(
<VisuallyHidden>(opens in a new tab)</VisuallyHidden>
{!hideArrow && (
<RxExternalLink
className={cn("-me-1 inline h-6 w-6 p-1 align-middle", {
transform: flipForRtl,
})}
className={cn(
"-me-1 inline h-6 w-6 p-1 align-middle",
twFlipForRtl
)}
/>
)}
</a>
Expand Down
7 changes: 5 additions & 2 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,15 @@ const HomePage = ({
{t("page-index:page-index-popular-topics-header")}
</h3>
<div className="grid grid-cols-1 gap-8 sm:grid-cols-2 md:grid-cols-1 lg:grid-cols-2">
{popularTopics.map(({ label, Svg, href }) => (
{popularTopics.map(({ label, Svg, href, className }) => (
<SvgButtonLink
key={label}
Svg={Svg}
href={href}
className="text-accent-b hover:text-accent-b-hover [&>:first-child]:flex-row"
className={cn(
"text-accent-b hover:text-accent-b-hover [&>:first-child]:flex-row",
className
)}
>
<p className="text-start text-xl font-bold text-body group-hover:underline">
{label}
Expand Down
Loading