Spaces:
Running
Running
Create src/components/logo-animation/LogoAnimation.tsx
Browse files
src/components/logo-animation/LogoAnimation.tsx
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// src/components/logo-animation/LogoAnimation.tsx
|
2 |
+
import React from 'react';
|
3 |
+
import cn from 'classnames';
|
4 |
+
|
5 |
+
// آیکون انسان - میتوانید این را از App.tsx کپی کنید یا از یک فایل مشترک ایمپورت کنید
|
6 |
+
const SvgHumanIcon = () => (
|
7 |
+
<svg width="100%" height="100%" viewBox="0 0 88 89" fill="none" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid meet">
|
8 |
+
<path d="M75.1481 81.6361H12.9259C9.66667 81.6361 7 78.9721 7 75.7161V58.5112C7 57.5862 7 57.1052 7.44444 56.2172C8.85185 52.9612 13 50.2232 19.4815 47.8922C24.1111 56.6982 33.3704 62.6921 44 62.6921C54.6296 62.6921 63.9259 56.6982 68.5185 47.8922C75 50.1862 79.1852 52.9982 80.5556 56.2172C81 56.6612 81 57.6232 81 58.5112V75.7161C81 78.9721 78.3333 81.6361 75.0741 81.6361H75.1481Z" stroke="currentColor" strokeWidth="6.42146" strokeLinecap="round" strokeLinejoin="round"/>
|
9 |
+
<path d="M44.0371 50.1862C33.8519 50.1862 25.5186 41.8612 25.5186 31.6863V26.1363C25.5186 15.9613 33.8519 7.63635 44.0371 7.63635C54.2223 7.63635 62.5556 15.9613 62.5556 26.1363V31.6863C62.5556 41.8612 54.2223 50.1862 44.0371 50.1862Z" stroke="currentColor" strokeWidth="6.42146" strokeLinecap="round" strokeLinejoin="round"/>
|
10 |
+
</svg>
|
11 |
+
);
|
12 |
+
|
13 |
+
// این پیکربندی رنگها را هم به اینجا منتقل میکنیم یا از App.tsx ایمپورت میکنیم
|
14 |
+
// برای سادگی، فعلاً اینجا کپی میکنیم
|
15 |
+
const logoColorConfigInternal = {
|
16 |
+
blue: {
|
17 |
+
ping: "bg-blue-200 dark:bg-blue-700",
|
18 |
+
outer: "bg-blue-200 dark:bg-blue-700",
|
19 |
+
mid: "bg-blue-300 dark:bg-blue-600",
|
20 |
+
inner: "bg-blue-400 dark:bg-blue-500",
|
21 |
+
},
|
22 |
+
green: {
|
23 |
+
ping: "bg-green-200 dark:bg-green-700",
|
24 |
+
outer: "bg-green-200 dark:bg-green-700",
|
25 |
+
mid: "bg-green-300 dark:bg-green-600",
|
26 |
+
inner: "bg-green-400 dark:bg-green-500",
|
27 |
+
},
|
28 |
+
gray: {
|
29 |
+
ping: "bg-gray-200 dark:bg-gray-700",
|
30 |
+
outer: "bg-gray-200 dark:bg-gray-700",
|
31 |
+
mid: "bg-gray-300 dark:bg-gray-600",
|
32 |
+
inner: "bg-gray-400 dark:bg-gray-500",
|
33 |
+
}
|
34 |
+
};
|
35 |
+
|
36 |
+
interface LogoAnimationProps {
|
37 |
+
isMini: boolean;
|
38 |
+
isActive: boolean;
|
39 |
+
type?: 'human' | 'ai';
|
40 |
+
forFooter?: boolean; // برای استایلدهی احتمالی متفاوت در فوتر
|
41 |
+
}
|
42 |
+
|
43 |
+
const LogoAnimation: React.FC<LogoAnimationProps> = ({
|
44 |
+
isMini,
|
45 |
+
isActive,
|
46 |
+
type = 'human',
|
47 |
+
forFooter = false,
|
48 |
+
}) => {
|
49 |
+
if (!isActive) return null;
|
50 |
+
|
51 |
+
const colorKey = type === 'human' ? 'blue' : (type === 'ai' ? 'green' : 'gray');
|
52 |
+
const currentColors = logoColorConfigInternal[colorKey as keyof typeof logoColorConfigInternal] || logoColorConfigInternal.gray;
|
53 |
+
|
54 |
+
const size = isMini ? 80 : 200;
|
55 |
+
const iconDisplaySize = isMini ? 35 : 70;
|
56 |
+
const iconInset = (size - iconDisplaySize) / 2;
|
57 |
+
|
58 |
+
// مقادیر inset برای حلقهها بر اساس HTML مرجع شما
|
59 |
+
// این مقادیر باید برای انیمیشن کامل و صحیح، دقیق باشند
|
60 |
+
const insetValues = {
|
61 |
+
ping: isMini ? 10 : 40,
|
62 |
+
outerRing: isMini ? 0 : 0, // در HTML شما، حلقه بیرونی اصلی هم inset 0 دارد
|
63 |
+
midRing: isMini ? 5 : 20,
|
64 |
+
innerRing: isMini ? 12 : 50, // این همان حلقهای است که در HTML شما `inset-[50px]` دارد
|
65 |
+
iconContainer: iconInset
|
66 |
+
};
|
67 |
+
// در HTML شما `inset: ${insetBase.outer}px` و `inset: ${insetBase.mid}px` و `inset: ${insetBase.inner}px` استفاده شده.
|
68 |
+
// مطمئن میشویم از مقادیر صحیح استفاده میکنیم.
|
69 |
+
|
70 |
+
const IconComponent = type === 'human' ? SvgHumanIcon : null; // در صورت نیاز، آیکون AI را اینجا اضافه کنید
|
71 |
+
|
72 |
+
return (
|
73 |
+
<div
|
74 |
+
className={cn("logo-animation-wrapper", { "for-footer": forFooter })}
|
75 |
+
style={{ width: `${size}px`, height: `${size}px` }}
|
76 |
+
>
|
77 |
+
{/* حلقه پینگ */}
|
78 |
+
<div
|
79 |
+
className={`absolute rounded-full opacity-50 animate-ping ${currentColors.ping}`}
|
80 |
+
style={{ inset: `${insetValues.ping}px` }}
|
81 |
+
></div>
|
82 |
+
{/* حلقه بیرونی ثابت */}
|
83 |
+
<div
|
84 |
+
className={`absolute rounded-full opacity-50 ${currentColors.outer}`}
|
85 |
+
style={{ inset: `${insetValues.outerRing}px` }}
|
86 |
+
></div>
|
87 |
+
{/* حلقه میانی */}
|
88 |
+
<div
|
89 |
+
className={`absolute rounded-full opacity-50 ${currentColors.mid}`}
|
90 |
+
style={{ inset: `${insetValues.midRing}px` }}
|
91 |
+
></div>
|
92 |
+
{/* حلقه داخلی (مهمترین حلقه رنگی نزدیک به آیکون) */}
|
93 |
+
<div
|
94 |
+
className={`absolute rounded-full opacity-50 ${currentColors.inner}`}
|
95 |
+
style={{ inset: `${insetValues.innerRing}px` }} // این باید با HTML شما مطابقت داشته باشد
|
96 |
+
></div>
|
97 |
+
{/* کانتینر آیکون */}
|
98 |
+
<div
|
99 |
+
className="z-10 absolute flex items-center justify-center"
|
100 |
+
style={{
|
101 |
+
inset: `${insetValues.iconContainer}px`,
|
102 |
+
width: `${iconDisplaySize}px`,
|
103 |
+
height: `${iconDisplaySize}px`,
|
104 |
+
}}
|
105 |
+
>
|
106 |
+
{IconComponent && <IconComponent />}
|
107 |
+
</div>
|
108 |
+
</div>
|
109 |
+
);
|
110 |
+
};
|
111 |
+
|
112 |
+
export default LogoAnimation;
|