Skip to content

Commit a030dad

Browse files
committed
feat: add BD page and circling elements animation component
1 parent 4553934 commit a030dad

File tree

10 files changed

+578
-4
lines changed

10 files changed

+578
-4
lines changed

public/pic.png

77.9 KB
Loading

src/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Route, Routes } from "react-router";
2-
import { BackgroundChange, Home, NotFound, PhoneShowcase } from "./pages";
2+
import { BackgroundChange, Home, NotFound, PhoneShowcase, BD } from "./pages";
33
import TestPage from "./pages/test";
44

55
const App = () => {
@@ -9,6 +9,7 @@ const App = () => {
99
<Route path="phone" element={<PhoneShowcase />} />
1010
<Route path="bg" element={<BackgroundChange />} />
1111
<Route path="test" element={<TestPage />} />
12+
<Route path="bd" element={<BD />} />
1213
<Route path="*" element={<NotFound />} />
1314
</Routes>
1415
);

src/components/animations/circle.tsx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"use client";
2+
3+
import React from "react";
4+
import { motion } from "motion/react";
5+
6+
type CirclingElementsProps = {
7+
children: React.ReactNode;
8+
radius?: number;
9+
duration?: number;
10+
className?: string;
11+
};
12+
13+
const CirclingElements: React.FC<CirclingElementsProps> = ({
14+
children,
15+
radius = 100,
16+
duration = 10,
17+
className,
18+
}) => {
19+
return (
20+
<div className={`relative w-full h-full ${className}`}>
21+
{React.Children.map(children, (child, index) => {
22+
const offset = (index * 360) / React.Children.count(children);
23+
return (
24+
<motion.div
25+
key={index}
26+
className="transform-gpu absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 animate-circling"
27+
style={
28+
{
29+
"--circling-duration": duration,
30+
"--circling-radius": radius,
31+
"--circling-offset": offset,
32+
} as React.CSSProperties
33+
}
34+
>
35+
{child}
36+
</motion.div>
37+
);
38+
})}
39+
</div>
40+
);
41+
};
42+
43+
export default CirclingElements;

0 commit comments

Comments
 (0)