Ezmary commited on
Commit
c1a2f76
·
verified ·
1 Parent(s): 923b6fb

Update src/components/logo-animation/LogoAnimation.tsx

Browse files
src/components/logo-animation/LogoAnimation.tsx CHANGED
@@ -2,7 +2,7 @@
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"/>
@@ -10,26 +10,25 @@ const SvgHumanIcon = () => (
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
 
@@ -37,7 +36,7 @@ interface LogoAnimationProps {
37
  isMini: boolean;
38
  isActive: boolean;
39
  type?: 'human' | 'ai';
40
- forFooter?: boolean; // برای استایل‌دهی احتمالی متفاوت در فوتر
41
  }
42
 
43
  const LogoAnimation: React.FC<LogoAnimationProps> = ({
@@ -49,56 +48,61 @@ const LogoAnimation: React.FC<LogoAnimationProps> = ({
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
  }}
 
2
  import React from 'react';
3
  import cn from 'classnames';
4
 
5
+ // آیکون انسان
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"/>
 
10
  </svg>
11
  );
12
 
13
+ // *** NEW: پیکربندی رنگ‌های لوگو به این کامپوننت منتقل شد ***
14
+ const logoColorConfig = {
15
+ blue: { // برای انسان
16
+ ping: "bg-blue-200 dark:bg-blue-700", // حلقه پینگ
17
+ ring1: "bg-blue-200 dark:bg-blue-700", // بیرونی ترین حلقه ثابت (مشابه پینگ)
18
+ ring2: "bg-blue-300 dark:bg-blue-600", // حلقه میانی
19
+ ring3: "bg-blue-400 dark:bg-blue-500", // داخلی ترین حلقه رنگی
 
20
  },
21
+ green: { // برای AI (اگر اضافه شود)
22
  ping: "bg-green-200 dark:bg-green-700",
23
+ ring1: "bg-green-200 dark:bg-green-700",
24
+ ring2: "bg-green-300 dark:bg-green-600",
25
+ ring3: "bg-green-400 dark:bg-green-500",
26
  },
27
+ gray: { // پیش‌فرض
28
  ping: "bg-gray-200 dark:bg-gray-700",
29
+ ring1: "bg-gray-200 dark:bg-gray-700",
30
+ ring2: "bg-gray-300 dark:bg-gray-600",
31
+ ring3: "bg-gray-400 dark:bg-gray-500",
32
  }
33
  };
34
 
 
36
  isMini: boolean;
37
  isActive: boolean;
38
  type?: 'human' | 'ai';
39
+ forFooter?: boolean;
40
  }
41
 
42
  const LogoAnimation: React.FC<LogoAnimationProps> = ({
 
48
  if (!isActive) return null;
49
 
50
  const colorKey = type === 'human' ? 'blue' : (type === 'ai' ? 'green' : 'gray');
51
+ // *** MODIFIED: استفاده از logoColorConfig داخلی ***
52
+ const currentColors = logoColorConfig[colorKey as keyof typeof logoColorConfig] || logoColorConfig.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
+ // این مقادیر از HTML شما (`inset: 40px`, `inset: 0px`, `inset: 20px`, `inset: 50px` برای لوگوی بزرگ)
60
+ // و (`inset: 10px`, `inset: 0px`, `inset: 5px`, `inset: 12px` برای لوگوی کوچک) استخراج شده‌اند.
61
+ const insets = {
62
+ ping: isMini ? "10px" : "40px",
63
+ ring1: isMini ? "0px" : "0px", // بیرونی ترین حلقه ثابت
64
+ ring2: isMini ? "5px" : "20px", // حلقه میانی
65
+ ring3: isMini ? "12px" : "50px", // داخلی ترین حلقه رنگی (نزدیک آیکون)
66
+ iconContainer: `${iconInset}px`
67
  };
 
 
68
 
69
+ const IconComponent = type === 'human' ? SvgHumanIcon : null;
70
 
71
  return (
72
  <div
73
  className={cn("logo-animation-wrapper", { "for-footer": forFooter })}
74
  style={{ width: `${size}px`, height: `${size}px` }}
75
  >
76
+ {/* اطمینان حاصل کنید که Tailwind این کلاس‌های رنگی را می‌بیند */}
77
+ {/* این div فقط برای این است که Tailwind کلاس‌ها را در build نهایی نگه دارد */}
78
+ {/* شما می‌توانید این را در فایل tailwind.config.js در بخش safelist هم اضافه کنید */}
79
+ <div className="hidden bg-blue-200 bg-blue-300 bg-blue-400 bg-green-200 bg-green-300 bg-green-400 bg-gray-200 bg-gray-300 bg-gray-400 dark:bg-blue-700 dark:bg-blue-600 dark:bg-blue-500 dark:bg-green-700 dark:bg-green-600 dark:bg-green-500 dark:bg-gray-700 dark:bg-gray-600 dark:bg-gray-500"></div>
80
+
81
  {/* حلقه پینگ */}
82
  <div
83
  className={`absolute rounded-full opacity-50 animate-ping ${currentColors.ping}`}
84
+ style={{ inset: insets.ping }}
85
  ></div>
86
  {/* حلقه بیرونی ثابت */}
87
  <div
88
+ className={`absolute rounded-full opacity-50 ${currentColors.ring1}`}
89
+ style={{ inset: insets.ring1 }}
90
  ></div>
91
  {/* حلقه میانی */}
92
  <div
93
+ className={`absolute rounded-full opacity-50 ${currentColors.ring2}`}
94
+ style={{ inset: insets.ring2 }}
95
  ></div>
96
+ {/* حلقه داخلی */}
97
  <div
98
+ className={`absolute rounded-full opacity-50 ${currentColors.ring3}`}
99
+ style={{ inset: insets.ring3 }}
100
  ></div>
101
  {/* کانتینر آیکون */}
102
  <div
103
  className="z-10 absolute flex items-center justify-center"
104
  style={{
105
+ inset: insets.iconContainer,
106
  width: `${iconDisplaySize}px`,
107
  height: `${iconDisplaySize}px`,
108
  }}