Ezmary's picture
Update src/components/logo-animation/LogoAnimation.tsx
c1a2f76 verified
raw
history blame
5.47 kB
// src/components/logo-animation/LogoAnimation.tsx
import React from 'react';
import cn from 'classnames';
// آیکون انسان
const SvgHumanIcon = () => (
<svg width="100%" height="100%" viewBox="0 0 88 89" fill="none" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid meet">
<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"/>
<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"/>
</svg>
);
// *** NEW: پیکربندی رنگ‌های لوگو به این کامپوننت منتقل شد ***
const logoColorConfig = {
blue: { // برای انسان
ping: "bg-blue-200 dark:bg-blue-700", // حلقه پینگ
ring1: "bg-blue-200 dark:bg-blue-700", // بیرونی ترین حلقه ثابت (مشابه پینگ)
ring2: "bg-blue-300 dark:bg-blue-600", // حلقه میانی
ring3: "bg-blue-400 dark:bg-blue-500", // داخلی ترین حلقه رنگی
},
green: { // برای AI (اگر اضافه شود)
ping: "bg-green-200 dark:bg-green-700",
ring1: "bg-green-200 dark:bg-green-700",
ring2: "bg-green-300 dark:bg-green-600",
ring3: "bg-green-400 dark:bg-green-500",
},
gray: { // پیش‌فرض
ping: "bg-gray-200 dark:bg-gray-700",
ring1: "bg-gray-200 dark:bg-gray-700",
ring2: "bg-gray-300 dark:bg-gray-600",
ring3: "bg-gray-400 dark:bg-gray-500",
}
};
interface LogoAnimationProps {
isMini: boolean;
isActive: boolean;
type?: 'human' | 'ai';
forFooter?: boolean;
}
const LogoAnimation: React.FC<LogoAnimationProps> = ({
isMini,
isActive,
type = 'human',
forFooter = false,
}) => {
if (!isActive) return null;
const colorKey = type === 'human' ? 'blue' : (type === 'ai' ? 'green' : 'gray');
// *** MODIFIED: استفاده از logoColorConfig داخلی ***
const currentColors = logoColorConfig[colorKey as keyof typeof logoColorConfig] || logoColorConfig.gray;
const size = isMini ? 80 : 200;
const iconDisplaySize = isMini ? 35 : 70;
const iconInset = (size - iconDisplaySize) / 2;
// مقادیر inset برای حلقه‌ها بر اساس HTML مرجع شما
// این مقادیر از HTML شما (`inset: 40px`, `inset: 0px`, `inset: 20px`, `inset: 50px` برای لوگوی بزرگ)
// و (`inset: 10px`, `inset: 0px`, `inset: 5px`, `inset: 12px` برای لوگوی کوچک) استخراج شده‌اند.
const insets = {
ping: isMini ? "10px" : "40px",
ring1: isMini ? "0px" : "0px", // بیرونی ترین حلقه ثابت
ring2: isMini ? "5px" : "20px", // حلقه میانی
ring3: isMini ? "12px" : "50px", // داخلی ترین حلقه رنگی (نزدیک آیکون)
iconContainer: `${iconInset}px`
};
const IconComponent = type === 'human' ? SvgHumanIcon : null;
return (
<div
className={cn("logo-animation-wrapper", { "for-footer": forFooter })}
style={{ width: `${size}px`, height: `${size}px` }}
>
{/* اطمینان حاصل کنید که Tailwind این کلاس‌های رنگی را می‌بیند */}
{/* این div فقط برای این است که Tailwind کلاس‌ها را در build نهایی نگه دارد */}
{/* شما می‌توانید این را در فایل tailwind.config.js در بخش safelist هم اضافه کنید */}
<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>
{/* حلقه پینگ */}
<div
className={`absolute rounded-full opacity-50 animate-ping ${currentColors.ping}`}
style={{ inset: insets.ping }}
></div>
{/* حلقه بیرونی ثابت */}
<div
className={`absolute rounded-full opacity-50 ${currentColors.ring1}`}
style={{ inset: insets.ring1 }}
></div>
{/* حلقه میانی */}
<div
className={`absolute rounded-full opacity-50 ${currentColors.ring2}`}
style={{ inset: insets.ring2 }}
></div>
{/* حلقه داخلی */}
<div
className={`absolute rounded-full opacity-50 ${currentColors.ring3}`}
style={{ inset: insets.ring3 }}
></div>
{/* کانتینر آیکون */}
<div
className="z-10 absolute flex items-center justify-center"
style={{
inset: insets.iconContainer,
width: `${iconDisplaySize}px`,
height: `${iconDisplaySize}px`,
}}
>
{IconComponent && <IconComponent />}
</div>
</div>
);
};
export default LogoAnimation;