Spaces:
Sleeping
Sleeping
Commit Β·
44f21c6
1
Parent(s): 4f95be4
add
Browse files
frontend/src/components/shared/FloatingActionWidget.tsx
CHANGED
|
@@ -34,6 +34,9 @@ import { useNavigation } from "@/context/NavigationContext";
|
|
| 34 |
import { useTaskPolling } from "@/hooks/useTaskPolling";
|
| 35 |
import { api } from "@/lib/api";
|
| 36 |
|
|
|
|
|
|
|
|
|
|
| 37 |
// Add custom glow animation styles
|
| 38 |
const glowStyle = `
|
| 39 |
@keyframes magical-glow {
|
|
@@ -439,57 +442,16 @@ export function FloatingActionWidget() {
|
|
| 439 |
};
|
| 440 |
}, [lastInteraction]);
|
| 441 |
|
| 442 |
-
// Random movement behavior (
|
| 443 |
useEffect(() => {
|
|
|
|
| 444 |
if (isDragging || isExpanded) return;
|
| 445 |
|
| 446 |
const randomMove = () => {
|
| 447 |
-
|
| 448 |
-
if (moveChance < 0.2) {
|
| 449 |
-
// 20% chance to move
|
| 450 |
-
const margin = 100;
|
| 451 |
-
const newX =
|
| 452 |
-
margin + Math.random() * (window.innerWidth - 300 - margin);
|
| 453 |
-
const newY =
|
| 454 |
-
margin + Math.random() * (window.innerHeight - 200 - margin);
|
| 455 |
-
|
| 456 |
-
setPosition({ x: newX, y: newY });
|
| 457 |
-
setIsAnimating(true);
|
| 458 |
-
|
| 459 |
-
// Show a playful message during movement
|
| 460 |
-
const playfulMessages = [
|
| 461 |
-
{
|
| 462 |
-
text: "πββοΈ Just stretching my legs!",
|
| 463 |
-
mood: "excited" as PetMood,
|
| 464 |
-
emoji: "πββοΈ",
|
| 465 |
-
},
|
| 466 |
-
{
|
| 467 |
-
text: "π Change of scenery!",
|
| 468 |
-
mood: "happy" as PetMood,
|
| 469 |
-
emoji: "π",
|
| 470 |
-
},
|
| 471 |
-
{
|
| 472 |
-
text: "π Exploring your workspace!",
|
| 473 |
-
mood: "curious" as PetMood,
|
| 474 |
-
emoji: "π",
|
| 475 |
-
},
|
| 476 |
-
];
|
| 477 |
-
const randomMsg =
|
| 478 |
-
playfulMessages[Math.floor(Math.random() * playfulMessages.length)];
|
| 479 |
-
if (!randomMsg) return;
|
| 480 |
-
setCurrentMessage(randomMsg);
|
| 481 |
-
setCurrentMood(randomMsg.mood);
|
| 482 |
-
setShowTooltip(true);
|
| 483 |
-
|
| 484 |
-
setTimeout(() => {
|
| 485 |
-
setIsAnimating(false);
|
| 486 |
-
setShowTooltip(false);
|
| 487 |
-
}, 2000);
|
| 488 |
-
}
|
| 489 |
};
|
| 490 |
|
| 491 |
-
|
| 492 |
-
const moveInterval = setInterval(randomMove, 45000);
|
| 493 |
return () => clearInterval(moveInterval);
|
| 494 |
}, [isDragging, isExpanded]);
|
| 495 |
|
|
@@ -877,8 +839,8 @@ export function FloatingActionWidget() {
|
|
| 877 |
className={`w-14 h-14 bg-primary hover:bg-primary/90 rounded-full shadow-lg flex flex-col items-center justify-center cursor-pointer transition-all duration-200 hover:scale-110 relative ${
|
| 878 |
showTooltip ? "shadow-primary/50 shadow-2xl" : ""
|
| 879 |
} ${isDragging ? "scale-110 shadow-2xl opacity-90" : ""} ${
|
| 880 |
-
|
| 881 |
-
} ${
|
| 882 |
isAtChartCenter
|
| 883 |
? "ring-4 ring-blue-400/50 ring-offset-4 shadow-xl shadow-blue-500/30 scale-110"
|
| 884 |
: ""
|
|
@@ -888,9 +850,8 @@ export function FloatingActionWidget() {
|
|
| 888 |
onMouseLeave={handleMouseLeave}
|
| 889 |
onClick={toggleExpanded}
|
| 890 |
style={{
|
| 891 |
-
animation
|
| 892 |
-
|
| 893 |
-
: undefined,
|
| 894 |
transition: isDragging ? "none" : "all 0.2s ease",
|
| 895 |
transform: `scale(${petScale})`,
|
| 896 |
}}
|
|
@@ -904,7 +865,7 @@ export function FloatingActionWidget() {
|
|
| 904 |
|
| 905 |
{/* Pet tooltip with mood-based messages - only show when collapsed */}
|
| 906 |
{showTooltip && !isExpanded && (
|
| 907 |
-
<div className="absolute -top-16 -right-4 w-48 bg-black/90 text-white text-xs px-3 py-2 rounded-lg shadow-lg
|
| 908 |
<div className="text-center">{currentMessage.text}</div>
|
| 909 |
<div className="absolute top-full right-6 w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent border-t-black/90"></div>
|
| 910 |
</div>
|
|
|
|
| 34 |
import { useTaskPolling } from "@/hooks/useTaskPolling";
|
| 35 |
import { api } from "@/lib/api";
|
| 36 |
|
| 37 |
+
// Disable jittery animations/motion for the floating widget in HF build
|
| 38 |
+
const DISABLE_FLOATING_WIDGET_JITTER = true;
|
| 39 |
+
|
| 40 |
// Add custom glow animation styles
|
| 41 |
const glowStyle = `
|
| 42 |
@keyframes magical-glow {
|
|
|
|
| 442 |
};
|
| 443 |
}, [lastInteraction]);
|
| 444 |
|
| 445 |
+
// Random movement behavior (disabled to prevent jitter)
|
| 446 |
useEffect(() => {
|
| 447 |
+
if (DISABLE_FLOATING_WIDGET_JITTER) return;
|
| 448 |
if (isDragging || isExpanded) return;
|
| 449 |
|
| 450 |
const randomMove = () => {
|
| 451 |
+
/* disabled */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 452 |
};
|
| 453 |
|
| 454 |
+
const moveInterval = setInterval(randomMove, 60000);
|
|
|
|
| 455 |
return () => clearInterval(moveInterval);
|
| 456 |
}, [isDragging, isExpanded]);
|
| 457 |
|
|
|
|
| 839 |
className={`w-14 h-14 bg-primary hover:bg-primary/90 rounded-full shadow-lg flex flex-col items-center justify-center cursor-pointer transition-all duration-200 hover:scale-110 relative ${
|
| 840 |
showTooltip ? "shadow-primary/50 shadow-2xl" : ""
|
| 841 |
} ${isDragging ? "scale-110 shadow-2xl opacity-90" : ""} ${
|
| 842 |
+
isExpanded ? "ring-2 ring-primary/50 ring-offset-2" : ""
|
| 843 |
+
} ${
|
| 844 |
isAtChartCenter
|
| 845 |
? "ring-4 ring-blue-400/50 ring-offset-4 shadow-xl shadow-blue-500/30 scale-110"
|
| 846 |
: ""
|
|
|
|
| 850 |
onMouseLeave={handleMouseLeave}
|
| 851 |
onClick={toggleExpanded}
|
| 852 |
style={{
|
| 853 |
+
// Disable glow animation to avoid jitter
|
| 854 |
+
animation: undefined,
|
|
|
|
| 855 |
transition: isDragging ? "none" : "all 0.2s ease",
|
| 856 |
transform: `scale(${petScale})`,
|
| 857 |
}}
|
|
|
|
| 865 |
|
| 866 |
{/* Pet tooltip with mood-based messages - only show when collapsed */}
|
| 867 |
{showTooltip && !isExpanded && (
|
| 868 |
+
<div className="absolute -top-16 -right-4 w-48 bg-black/90 text-white text-xs px-3 py-2 rounded-lg shadow-lg z-10">
|
| 869 |
<div className="text-center">{currentMessage.text}</div>
|
| 870 |
<div className="absolute top-full right-6 w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent border-t-black/90"></div>
|
| 871 |
</div>
|