From 6acf719a89354bafed0058c6a0fb8fe36774b365 Mon Sep 17 00:00:00 2001 From: Paul Wackerow <54227730+wackerow@users.noreply.github.com> Date: Wed, 2 Oct 2024 10:47:07 +0100 Subject: [PATCH] fix: RTL styling for ValuesMarquee --- src/components/Homepage/ValuesMarquee.tsx | 27 +++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/components/Homepage/ValuesMarquee.tsx b/src/components/Homepage/ValuesMarquee.tsx index d43be1e7889..abcd3ae66ec 100644 --- a/src/components/Homepage/ValuesMarquee.tsx +++ b/src/components/Homepage/ValuesMarquee.tsx @@ -19,6 +19,7 @@ import { } from "../ui/section" import { usePrefersReducedMotion } from "@/hooks/usePrefersReducedMotion" +import { useRtlFlip } from "@/hooks/useRtlFlip" type ItemProps = React.HTMLAttributes & { pairing: Pairing @@ -26,6 +27,7 @@ type ItemProps = React.HTMLAttributes & { container?: HTMLElement | null label: string eventCategory: string + direction: HTMLDivElement["dir"] } const Item = ({ @@ -36,6 +38,7 @@ const Item = ({ container, label, eventCategory, + direction, }: ItemProps) => ( <> {children} @@ -98,6 +102,7 @@ const Item = ({ /> ) +Item.displayName = "MarqueeItem" type RowProps = React.HTMLAttributes & { toRight?: boolean @@ -106,12 +111,15 @@ type RowProps = React.HTMLAttributes & { const Row = forwardRef( ({ className, children, toRight }, ref) => { const { prefersReducedMotion } = usePrefersReducedMotion() + const fadeEdges = { mask: `linear-gradient(to right, transparent 1rem, white 15%, white 85%, transparent calc(100% - 1rem))`, } return ( -
+ // Note: dir="ltr" forced on parent to prevent "translateX" animation bugs + // Locale "direction" passed to marquee Item for correction +
( ) } ) -Row.displayName = "Row" +Row.displayName = "MarqueeRow" const ValuesMarquee = () => { const { t, pairings, eventCategory } = useValuesMarquee() @@ -160,6 +168,8 @@ const ValuesMarquee = () => { } }, []) + const { direction, isRtl, twFlipForRtl } = useRtlFlip() + return (
@@ -185,6 +195,7 @@ const ValuesMarquee = () => { separatorClass="bg-accent-a" className="group/item bg-blue-100 text-blue-600 hover:bg-blue-600 hover:text-white dark:hover:bg-blue-700" eventCategory={eventCategory} + direction={direction} > {pairing.ethereum.label} @@ -206,13 +217,19 @@ const ValuesMarquee = () => { className="bg-gray-200/20 text-body-medium hover:bg-gray-600 hover:text-white dark:bg-gray-950 dark:text-body" separatorClass="bg-gray-200 dark:bg-gray-950" eventCategory={eventCategory} + direction={direction} > {pairing.legacy.label} ))} -
+

{t("page-index-values-legacy")}

@@ -222,7 +239,8 @@ const ValuesMarquee = () => { "border-t-[15px] border-t-blue-50 dark:border-t-blue-600", "border-r-8 border-r-blue-50 dark:border-r-blue-600", "border-b-[15px] border-b-gray-50 dark:border-b-gray-800", - "border-l-8 border-l-gray-50 dark:border-l-gray-800" + "border-l-8 border-l-gray-50 dark:border-l-gray-800", + twFlipForRtl )} /> @@ -234,5 +252,6 @@ const ValuesMarquee = () => {
) } +ValuesMarquee.displayName = "ValuesMarquee" export default ValuesMarquee