Ezmary's picture
Create src/components/logo-animation/LogoAnimation.tsx
219be00 verified
raw
history blame
5.16 kB
// src/components/logo-animation/LogoAnimation.tsx
import React from 'react';
import cn from 'classnames';
// آیکون انسان - می‌توانید این را از App.tsx کپی کنید یا از یک فایل مشترک ایمپورت کنید
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>
);
// این پیکربندی رنگ‌ها را هم به اینجا منتقل می‌کنیم یا از App.tsx ایمپورت می‌کنیم
// برای سادگی، فعلاً اینجا کپی می‌کنیم
const logoColorConfigInternal = {
blue: {
ping: "bg-blue-200 dark:bg-blue-700",
outer: "bg-blue-200 dark:bg-blue-700",
mid: "bg-blue-300 dark:bg-blue-600",
inner: "bg-blue-400 dark:bg-blue-500",
},
green: {
ping: "bg-green-200 dark:bg-green-700",
outer: "bg-green-200 dark:bg-green-700",
mid: "bg-green-300 dark:bg-green-600",
inner: "bg-green-400 dark:bg-green-500",
},
gray: {
ping: "bg-gray-200 dark:bg-gray-700",
outer: "bg-gray-200 dark:bg-gray-700",
mid: "bg-gray-300 dark:bg-gray-600",
inner: "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');
const currentColors = logoColorConfigInternal[colorKey as keyof typeof logoColorConfigInternal] || logoColorConfigInternal.gray;
const size = isMini ? 80 : 200;
const iconDisplaySize = isMini ? 35 : 70;
const iconInset = (size - iconDisplaySize) / 2;
// مقادیر inset برای حلقه‌ها بر اساس HTML مرجع شما
// این مقادیر باید برای انیمیشن کامل و صحیح، دقیق باشند
const insetValues = {
ping: isMini ? 10 : 40,
outerRing: isMini ? 0 : 0, // در HTML شما، حلقه بیرونی اصلی هم inset 0 دارد
midRing: isMini ? 5 : 20,
innerRing: isMini ? 12 : 50, // این همان حلقه‌ای است که در HTML شما `inset-[50px]` دارد
iconContainer: iconInset
};
// در HTML شما `inset: ${insetBase.outer}px` و `inset: ${insetBase.mid}px` و `inset: ${insetBase.inner}px` استفاده شده.
// مطمئن می‌شویم از مقادیر صحیح استفاده می‌کنیم.
const IconComponent = type === 'human' ? SvgHumanIcon : null; // در صورت نیاز، آیکون AI را اینجا اضافه کنید
return (
<div
className={cn("logo-animation-wrapper", { "for-footer": forFooter })}
style={{ width: `${size}px`, height: `${size}px` }}
>
{/* حلقه پینگ */}
<div
className={`absolute rounded-full opacity-50 animate-ping ${currentColors.ping}`}
style={{ inset: `${insetValues.ping}px` }}
></div>
{/* حلقه بیرونی ثابت */}
<div
className={`absolute rounded-full opacity-50 ${currentColors.outer}`}
style={{ inset: `${insetValues.outerRing}px` }}
></div>
{/* حلقه میانی */}
<div
className={`absolute rounded-full opacity-50 ${currentColors.mid}`}
style={{ inset: `${insetValues.midRing}px` }}
></div>
{/* حلقه داخلی (مهمترین حلقه رنگی نزدیک به آیکون) */}
<div
className={`absolute rounded-full opacity-50 ${currentColors.inner}`}
style={{ inset: `${insetValues.innerRing}px` }} // این باید با HTML شما مطابقت داشته باشد
></div>
{/* کانتینر آیکون */}
<div
className="z-10 absolute flex items-center justify-center"
style={{
inset: `${insetValues.iconContainer}px`,
width: `${iconDisplaySize}px`,
height: `${iconDisplaySize}px`,
}}
>
{IconComponent && <IconComponent />}
</div>
</div>
);
};
export default LogoAnimation;