1import React from "react"
2
3import { cn } from "@/lib/utils"
4
5export interface OrbitingCirclesProps extends React.HTMLAttributes<HTMLDivElement> {
6 className?: string
7 children?: React.ReactNode
8 reverse?: boolean
9 duration?: number
10 delay?: number
11 radius?: number
12 path?: boolean
13 iconSize?: number
14 speed?: number
15}
16
17export function OrbitingCircles({
18 className,
19 children,
20 reverse,
21 duration = 20,
22 radius = 160,
23 path = true,
24 iconSize = 30,
25 speed = 1,
26 ...props
27}: OrbitingCirclesProps) {
28 const calculatedDuration = duration / speed
29 return (
30 <>
31 {path && (
32 <svg
33 xmlns="http://www.w3.org/2000/svg"
34 version="1.1"
35 className="pointer-events-none absolute inset-0 size-full"
36 >
37 <circle
38 className="stroke-black/10 stroke-1 dark:stroke-white/10"
39 cx="50%"
40 cy="50%"
41 r={radius}
42 fill="none"
43 />
44 </svg>
45 )}
46 {React.Children.map(children, (child, index) => {
47 const angle = (360 / React.Children.count(children)) * index
48 return (
49 <div
50 style={
51 {
52 "--duration": calculatedDuration,
53 "--radius": radius,
54 "--angle": angle,
55 "--icon-size": `${iconSize}px`,
56 } as React.CSSProperties
57 }
58 className={cn(
59 `animate-orbit absolute flex size-(--icon-size) transform-gpu items-center justify-center rounded-full`,
60 { "[animation-direction:reverse]": reverse },
61 className
62 )}
63 {...props}
64 >
65 {child}
66 </div>
67 )
68 })}
69 </>
70 )
71}
72