@@ -19,13 +19,15 @@ import {
19
19
} from "../ui/section"
20
20
21
21
import { usePrefersReducedMotion } from "@/hooks/usePrefersReducedMotion"
22
+ import { useRtlFlip } from "@/hooks/useRtlFlip"
22
23
23
24
type ItemProps = React . HTMLAttributes < HTMLButtonElement > & {
24
25
pairing : Pairing
25
26
separatorClass : string
26
27
container ?: HTMLElement | null
27
28
label : string
28
29
eventCategory : string
30
+ direction : HTMLDivElement [ "dir" ]
29
31
}
30
32
31
33
const Item = ( {
@@ -36,6 +38,7 @@ const Item = ({
36
38
container,
37
39
label,
38
40
eventCategory,
41
+ direction,
39
42
} : ItemProps ) => (
40
43
< >
41
44
< Tooltip
@@ -86,6 +89,7 @@ const Item = ({
86
89
"flex flex-nowrap items-center text-nowrap rounded-full px-4 py-1 font-bold uppercase" ,
87
90
className
88
91
) }
92
+ dir = { direction }
89
93
>
90
94
{ children }
91
95
</ div >
@@ -98,6 +102,7 @@ const Item = ({
98
102
/>
99
103
</ >
100
104
)
105
+ Item . displayName = "MarqueeItem"
101
106
102
107
type RowProps = React . HTMLAttributes < HTMLDivElement > & {
103
108
toRight ?: boolean
@@ -106,12 +111,15 @@ type RowProps = React.HTMLAttributes<HTMLDivElement> & {
106
111
const Row = forwardRef < HTMLDivElement , RowProps > (
107
112
( { className, children, toRight } , ref ) => {
108
113
const { prefersReducedMotion } = usePrefersReducedMotion ( )
114
+
109
115
const fadeEdges = {
110
116
mask : `linear-gradient(to right, transparent 1rem, white 15%, white 85%, transparent calc(100% - 1rem))` ,
111
117
}
112
118
113
119
return (
114
- < div ref = { ref } className = { cn ( "group" , className ) } >
120
+ // Note: dir="ltr" forced on parent to prevent "translateX" animation bugs
121
+ // Locale "direction" passed to marquee Item for correction
122
+ < div ref = { ref } className = { cn ( "group" , className ) } dir = "ltr" >
115
123
< div
116
124
className = "flex max-w-full overflow-hidden motion-reduce:overflow-auto"
117
125
style = { prefersReducedMotion ? { } : fadeEdges }
@@ -137,7 +145,7 @@ const Row = forwardRef<HTMLDivElement, RowProps>(
137
145
)
138
146
}
139
147
)
140
- Row . displayName = "Row "
148
+ Row . displayName = "MarqueeRow "
141
149
142
150
const ValuesMarquee = ( ) => {
143
151
const { t, pairings, eventCategory } = useValuesMarquee ( )
@@ -160,6 +168,8 @@ const ValuesMarquee = () => {
160
168
}
161
169
} , [ ] )
162
170
171
+ const { direction, isRtl, twFlipForRtl } = useRtlFlip ( )
172
+
163
173
return (
164
174
< Section id = "values" className = "!sm:my-64 !my-48 scroll-m-48" >
165
175
< SectionContent className = "flex flex-col items-center text-center" >
@@ -185,6 +195,7 @@ const ValuesMarquee = () => {
185
195
separatorClass = "bg-accent-a"
186
196
className = "group/item bg-blue-100 text-blue-600 hover:bg-blue-600 hover:text-white dark:hover:bg-blue-700"
187
197
eventCategory = { eventCategory }
198
+ direction = { direction }
188
199
>
189
200
< FaCheck className = "me-1 text-success group-hover/item:text-white" />
190
201
{ pairing . ethereum . label }
@@ -206,13 +217,19 @@ const ValuesMarquee = () => {
206
217
className = "bg-gray-200/20 text-body-medium hover:bg-gray-600 hover:text-white dark:bg-gray-950 dark:text-body"
207
218
separatorClass = "bg-gray-200 dark:bg-gray-950"
208
219
eventCategory = { eventCategory }
220
+ direction = { direction }
209
221
>
210
222
{ pairing . legacy . label }
211
223
</ Item >
212
224
) ) }
213
225
</ Row >
214
226
215
- < div className = "absolute start-[50%] top-[50%] flex -translate-x-[50%] -translate-y-[50%] items-center overflow-hidden rounded-lg text-sm font-bold" >
227
+ < div
228
+ className = { cn (
229
+ "absolute start-[50%] top-[50%] flex -translate-y-[50%] items-center overflow-hidden rounded-lg text-sm font-bold" ,
230
+ isRtl ? "translate-x-[50%]" : "-translate-x-[50%]"
231
+ ) }
232
+ >
216
233
< p className = "bg-gray-50 px-4 py-1 text-body-medium dark:bg-gray-800 dark:text-gray-200" >
217
234
{ t ( "page-index-values-legacy" ) }
218
235
</ p >
@@ -222,7 +239,8 @@ const ValuesMarquee = () => {
222
239
"border-t-[15px] border-t-blue-50 dark:border-t-blue-600" ,
223
240
"border-r-8 border-r-blue-50 dark:border-r-blue-600" ,
224
241
"border-b-[15px] border-b-gray-50 dark:border-b-gray-800" ,
225
- "border-l-8 border-l-gray-50 dark:border-l-gray-800"
242
+ "border-l-8 border-l-gray-50 dark:border-l-gray-800" ,
243
+ twFlipForRtl
226
244
) }
227
245
/>
228
246
@@ -234,5 +252,6 @@ const ValuesMarquee = () => {
234
252
</ Section >
235
253
)
236
254
}
255
+ ValuesMarquee . displayName = "ValuesMarquee"
237
256
238
257
export default ValuesMarquee
0 commit comments