Spaces:
Build error
Build error
Create components/ai-tutor/TutorAvatar.tsx
Browse files
frontend/src/components/ai-tutor/TutorAvatar.tsx
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { useState, useEffect } from 'react';
|
| 2 |
+
|
| 3 |
+
const TutorAvatar = ({ state = 'neutral', speaking = false }) => {
|
| 4 |
+
const [isBlinking, setIsBlinking] = useState(false);
|
| 5 |
+
|
| 6 |
+
useEffect(() => {
|
| 7 |
+
const blinkInterval = setInterval(() => {
|
| 8 |
+
setIsBlinking(true);
|
| 9 |
+
setTimeout(() => setIsBlinking(false), 200);
|
| 10 |
+
}, Math.random() * 4000 + 2000);
|
| 11 |
+
|
| 12 |
+
return () => clearInterval(blinkInterval);
|
| 13 |
+
}, []);
|
| 14 |
+
|
| 15 |
+
return (
|
| 16 |
+
<div className="flex justify-center items-center p-4">
|
| 17 |
+
<svg viewBox="0 0 100 100" className="w-32 h-32 transition-transform duration-300 hover:scale-110">
|
| 18 |
+
<circle cx="50" cy="50" r="45" className="fill-blue-500" />
|
| 19 |
+
|
| 20 |
+
{isBlinking ? (
|
| 21 |
+
<g>
|
| 22 |
+
<line x1="30" y1="40" x2="40" y2="40" stroke="white" strokeWidth="3" />
|
| 23 |
+
<line x1="60" y1="40" x2="70" y2="40" stroke="white" strokeWidth="3" />
|
| 24 |
+
</g>
|
| 25 |
+
) : (
|
| 26 |
+
<g>
|
| 27 |
+
<circle cx="35" cy="40" r="5" fill="white" />
|
| 28 |
+
<circle cx="65" cy="40" r="5" fill="white" />
|
| 29 |
+
</g>
|
| 30 |
+
)}
|
| 31 |
+
|
| 32 |
+
<path
|
| 33 |
+
d={
|
| 34 |
+
state === 'happy'
|
| 35 |
+
? 'M 30 60 Q 50 80 70 60'
|
| 36 |
+
: state === 'thinking'
|
| 37 |
+
? 'M 30 65 Q 50 65 70 65'
|
| 38 |
+
: 'M 30 60 Q 50 70 70 60'
|
| 39 |
+
}
|
| 40 |
+
stroke="white"
|
| 41 |
+
fill="none"
|
| 42 |
+
strokeWidth="3"
|
| 43 |
+
className={speaking ? 'animate-bounce' : ''}
|
| 44 |
+
/>
|
| 45 |
+
</svg>
|
| 46 |
+
</div>
|
| 47 |
+
);
|
| 48 |
+
};
|
| 49 |
+
|
| 50 |
+
export default TutorAvatar;
|