1"use client"
2
3import { useEffect, useId, useRef, useState } from "react"
4import {
5 BarChart,
6 File,
7 Globe,
8 HeartHandshake,
9 Rss,
10 Shield,
11} from "lucide-react"
12import { motion, useAnimation, useInView } from "motion/react"
13
14import { cn } from "@/lib/utils"
15import { Marquee } from "../marquee/marquee"
16
17const tiles = [
18 {
19 icon: <HeartHandshake className="size-full" />,
20 bg: (
21 <div className="pointer-events-none absolute top-1/2 left-1/2 size-1/2 -translate-x-1/2 -translate-y-1/2 overflow-visible rounded-full bg-gradient-to-r from-orange-600 via-rose-600 to-violet-600 opacity-70 blur-[20px]"></div>
22 ),
23 },
24 {
25 icon: <Globe className="size-full" />,
26 bg: (
27 <div className="pointer-events-none absolute top-1/2 left-1/2 size-1/2 -translate-x-1/2 -translate-y-1/2 overflow-visible rounded-full bg-gradient-to-r from-cyan-500 via-blue-500 to-indigo-500 opacity-70 blur-[20px]"></div>
28 ),
29 },
30 {
31 icon: <File className="size-full" />,
32 bg: (
33 <div className="pointer-events-none absolute top-1/2 left-1/2 size-1/2 -translate-x-1/2 -translate-y-1/2 overflow-visible rounded-full bg-gradient-to-r from-green-500 via-teal-500 to-emerald-600 opacity-70 blur-[20px]"></div>
34 ),
35 },
36 {
37 icon: <Shield className="size-full" />,
38 bg: (
39 <div className="pointer-events-none absolute top-1/2 left-1/2 size-1/2 -translate-x-1/2 -translate-y-1/2 overflow-visible rounded-full bg-gradient-to-r from-yellow-400 via-orange-500 to-yellow-600 opacity-70 blur-[20px]"></div>
40 ),
41 },
42 {
43 icon: <Rss className="size-full" />,
44 bg: (
45 <div className="pointer-events-none absolute top-1/2 left-1/2 size-1/2 -translate-x-1/2 -translate-y-1/2 overflow-visible rounded-full bg-gradient-to-r from-orange-600 via-rose-600 to-violet-600 opacity-70 blur-[20px]"></div>
46 ),
47 },
48 {
49 icon: <BarChart className="size-full" />,
50 bg: (
51 <div className="pointer-events-none absolute top-1/2 left-1/2 size-1/2 -translate-x-1/2 -translate-y-1/2 overflow-visible rounded-full bg-gradient-to-r from-cyan-600 via-cyan-500 to-teal-400 opacity-70 blur-[20px]"></div>
52 ),
53 },
54]
55
56function shuffleArray<T>(array: T[]): T[] {
57 let currentIndex = array.length
58 let randomIndex
59 // While there remain elements to shuffle.
60 while (currentIndex !== 0) {
61 // Pick a remaining element.
62 randomIndex = Math.floor(Math.random() * currentIndex)
63 currentIndex--
64 // And swap it with the current element.
65 ;[array[currentIndex], array[randomIndex]] = [
66 array[randomIndex],
67 array[currentIndex],
68 ]
69 }
70 return array
71}
72
73function Card(card: { icon: React.ReactNode; bg: React.ReactNode }) {
74 const id = useId()
75 const controls = useAnimation()
76 const ref = useRef(null)
77 const inView = useInView(ref, { once: true })
78
79 useEffect(() => {
80 if (inView) {
81 controls.start({
82 opacity: 1,
83 transition: { delay: Math.random() * 2, ease: "easeOut", duration: 1 },
84 })
85 }
86 }, [controls, inView])
87
88 return (
89 <motion.div
90 key={id}
91 ref={ref}
92 initial={{ opacity: 0 }}
93 animate={controls}
94 className={cn(
95 "relative size-20 cursor-pointer overflow-hidden rounded-2xl border p-4",
96 // light styles
97 "bg-white [box-shadow:0_0_0_1px_rgba(0,0,0,.03),0_2px_4px_rgba(0,0,0,.05),0_12px_24px_rgba(0,0,0,.05)]",
98 // dark styles
99 "transform-gpu dark:bg-transparent dark:[box-shadow:0_-20px_80px_-20px_#ffffff1f_inset] dark:[border:1px_solid_rgba(255,255,255,.1)]"
100 )}
101 >
102 {card.icon}
103 {card.bg}
104 </motion.div>
105 )
106}
107
108export default function Integrations() {
109 const [randomTiles1, setRandomTiles1] = useState<typeof tiles>([])
110 const [randomTiles2, setRandomTiles2] = useState<typeof tiles>([])
111 const [randomTiles3, setRandomTiles3] = useState<typeof tiles>([])
112 const [randomTiles4, setRandomTiles4] = useState<typeof tiles>([])
113
114 useEffect(() => {
115 if (typeof window !== "undefined") {
116 // Ensures this runs client-side
117 setRandomTiles1(shuffleArray([...tiles]))
118 setRandomTiles2(shuffleArray([...tiles]))
119 setRandomTiles3(shuffleArray([...tiles]))
120 setRandomTiles4(shuffleArray([...tiles]))
121 }
122 }, [])
123
124 return (
125 <section id="cta">
126 <div className="container mx-auto px-4 py-12 md:px-8">
127 <div className="flex w-full flex-col items-center justify-center">
128 <div className="relative flex w-full flex-col items-center justify-center overflow-hidden">
129 <Marquee
130 reverse
131 className="-delay-[200ms] [--duration:10s]"
132 repeat={5}
133 >
134 {randomTiles1.map((review, idx) => (
135 <Card key={idx} {...review} />
136 ))}
137 </Marquee>
138 <Marquee reverse className="[--duration:25s]" repeat={5}>
139 {randomTiles2.map((review, idx) => (
140 <Card key={idx} {...review} />
141 ))}
142 </Marquee>
143 <Marquee
144 reverse
145 className="-delay-[200ms] [--duration:20s]"
146 repeat={5}
147 >
148 {randomTiles1.map((review, idx) => (
149 <Card key={idx} {...review} />
150 ))}
151 </Marquee>
152 <Marquee reverse className="[--duration:30s]" repeat={5}>
153 {randomTiles2.map((review, idx) => (
154 <Card key={idx} {...review} />
155 ))}
156 </Marquee>
157 <Marquee
158 reverse
159 className="-delay-[200ms] [--duration:20s]"
160 repeat={5}
161 >
162 {randomTiles3.map((review, idx) => (
163 <Card key={idx} {...review} />
164 ))}
165 </Marquee>
166 <Marquee reverse className="[--duration:30s]" repeat={5}>
167 {randomTiles4.map((review, idx) => (
168 <Card key={idx} {...review} />
169 ))}
170 </Marquee>
171 <div className="absolute">
172 <div className="bg-backtround dark:bg-background absolute inset-0 -z-10 rounded-full opacity-40 blur-xl" />
173 </div>
174 <div className="to-backtround dark:to-background absolute inset-x-0 bottom-0 h-full bg-gradient-to-b from-transparent to-70%" />
175 </div>
176 </div>
177 </div>
178 </section>
179 )
180}
181