1
+ import { forwardRef , useEffect , useRef , useState } from "react"
1
2
import { FaCheck } from "react-icons/fa"
2
3
3
4
import Tooltip from "@/components/Tooltip"
@@ -18,6 +19,7 @@ type ItemProps = React.HTMLAttributes<HTMLButtonElement> & {
18
19
explanation : string [ ]
19
20
separatorClass : string
20
21
icon ?: React . ReactNode
22
+ container ?: HTMLElement | null
21
23
}
22
24
23
25
const Item = ( {
@@ -26,9 +28,11 @@ const Item = ({
26
28
explanation,
27
29
separatorClass,
28
30
icon,
31
+ container,
29
32
} : ItemProps ) => (
30
33
< >
31
34
< Tooltip
35
+ container = { container }
32
36
content = {
33
37
< >
34
38
< h3 className = "text-md uppercase text-body-medium" > { children } </ h3 >
@@ -63,38 +67,60 @@ type RowProps = React.HTMLAttributes<HTMLDivElement> & {
63
67
toRight ?: boolean
64
68
}
65
69
66
- const Row = ( { className, children, toRight } : RowProps ) => {
67
- const { prefersReducedMotion } = usePrefersReducedMotion ( )
68
- const fadeEdges = {
69
- mask : `linear-gradient(to right, transparent 1rem, white 15%, white 85%, transparent calc(100% - 1rem))` ,
70
- }
70
+ const Row = forwardRef < HTMLDivElement , RowProps > (
71
+ ( { className, children, toRight } , ref ) => {
72
+ const { prefersReducedMotion } = usePrefersReducedMotion ( )
73
+ const fadeEdges = {
74
+ mask : `linear-gradient(to right, transparent 1rem, white 15%, white 85%, transparent calc(100% - 1rem))` ,
75
+ }
71
76
72
- return (
73
- < div className = { cn ( "group" , className ) } >
74
- < div
75
- className = "flex max-w-full overflow-hidden motion-reduce:overflow-auto"
76
- style = { prefersReducedMotion ? { } : fadeEdges }
77
- >
78
- { Array ( prefersReducedMotion ? 1 : 3 )
79
- . fill ( 0 )
80
- . map ( ( _ , idx ) => (
81
- < div
82
- key = { idx }
83
- className = { cn (
84
- "group-hover:animate-pause flex min-w-fit items-center space-x-10 p-6 motion-reduce:w-full motion-reduce:animate-none motion-reduce:justify-center" ,
85
- toRight ? "animate-scroll-right" : "animate-scroll-left"
86
- ) }
87
- >
88
- { children }
89
- </ div >
90
- ) ) }
77
+ return (
78
+ < div ref = { ref } className = { cn ( "group" , className ) } >
79
+ < div
80
+ className = "flex max-w-full overflow-hidden motion-reduce:overflow-auto"
81
+ style = { prefersReducedMotion ? { } : fadeEdges }
82
+ >
83
+ { Array ( prefersReducedMotion ? 1 : 3 )
84
+ . fill ( 0 )
85
+ . map ( ( _ , idx ) => (
86
+ < div
87
+ key = { idx }
88
+ className = { cn (
89
+ "group-hover:animate-pause flex min-w-fit items-center space-x-10 p-6 motion-reduce:w-full motion-reduce:animate-none motion-reduce:justify-center" ,
90
+ toRight ? "animate-scroll-right" : "animate-scroll-left"
91
+ ) }
92
+ >
93
+ { children }
94
+ </ div >
95
+ ) ) }
96
+ </ div >
91
97
</ div >
92
- </ div >
93
- )
94
- }
98
+ )
99
+ }
100
+ )
101
+ Row . displayName = "Row"
95
102
96
103
const ValuesMarquee = ( ) => {
97
104
const { t, pairings } = useValuesMarquee ( )
105
+ const containerFirstRef = useRef < HTMLDivElement > ( null )
106
+ const containerSecondRef = useRef < HTMLDivElement > ( null )
107
+
108
+ const [ containerFirst , setContainerFirst ] = useState < HTMLDivElement | null > (
109
+ null
110
+ )
111
+ const [ containerSecond , setContainerSecond ] = useState < HTMLDivElement | null > (
112
+ null
113
+ )
114
+
115
+ useEffect ( ( ) => {
116
+ if ( containerFirstRef . current ) {
117
+ setContainerFirst ( containerFirstRef . current )
118
+ }
119
+ if ( containerSecondRef . current ) {
120
+ setContainerSecond ( containerSecondRef . current )
121
+ }
122
+ } , [ ] )
123
+
98
124
return (
99
125
< Section id = "values" className = "!my-64" >
100
126
< SectionContent className = "flex flex-col items-center text-center" >
@@ -107,11 +133,15 @@ const ValuesMarquee = () => {
107
133
</ p >
108
134
</ SectionContent >
109
135
< div className = "relative mt-19 overflow-hidden max-2xl:-mx-4 2xl:rounded-2xl" >
110
- < Row className = "border-b border-background bg-blue-50 dark:bg-blue-600" >
136
+ < Row
137
+ ref = { containerFirstRef }
138
+ className = "border-b border-background bg-blue-50 dark:bg-blue-600"
139
+ >
111
140
{ pairings . map ( ( { ethereum : { label, content } } ) => (
112
141
< Item
113
142
key = { label }
114
143
explanation = { content }
144
+ container = { containerFirst }
115
145
separatorClass = "bg-accent-a"
116
146
className = "group/item bg-blue-100 text-blue-600 hover:bg-blue-600 hover:text-white dark:hover:bg-blue-700"
117
147
icon = {
@@ -123,12 +153,14 @@ const ValuesMarquee = () => {
123
153
) ) }
124
154
</ Row >
125
155
< Row
156
+ ref = { containerSecondRef }
126
157
className = "border-t border-background bg-gray-50 dark:bg-gray-800"
127
158
toRight
128
159
>
129
160
{ pairings . map ( ( { legacy : { label, content } } ) => (
130
161
< Item
131
162
key = { label }
163
+ container = { containerSecond }
132
164
explanation = { content }
133
165
className = "bg-gray-200/20 text-body-medium hover:bg-gray-600 hover:text-white dark:bg-gray-950 dark:text-body"
134
166
separatorClass = "bg-gray-200 dark:bg-gray-950"
0 commit comments