Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

feat: add playful hover animations to agent avatars on home canvas

Gusb7b47a427a41
diff --git a/src/web/src/app/globals.css b/src/web/src/app/globals.css
index 2e7db568a..451e65da9 100644
--- a/src/web/src/app/globals.css
+++ b/src/web/src/app/globals.css
@@ -1233,6 +1233,115 @@
background-color: oklch(0.4 0.04 80 / 0.3);
}
+/* ── Avatar hover animations ── */
+[data-avatar-shape],
+[data-avatar-eyes],
+[data-avatar-nose] {
+ transform-box: fill-box;
+ transform-origin: center;
+}
+
+@keyframes avatar-shape-bounce {
+ 0%, 100% { scale: 1; }
+ 50% { scale: 1.08; }
+}
+@keyframes avatar-head-tilt {
+ 0%, 100% { rotate: 0; }
+ 30% { rotate: -4deg; }
+ 70% { rotate: 4deg; }
+}
+@keyframes avatar-shake {
+ 0%, 100% { translate: 0; }
+ 15% { translate: -3px 0; }
+ 35% { translate: 3px 0; }
+ 55% { translate: -2px 0; }
+ 75% { translate: 2px 0; }
+}
+@keyframes avatar-wobble {
+ 0%, 100% { rotate: 0; }
+ 15% { rotate: -6deg; }
+ 35% { rotate: 5deg; }
+ 55% { rotate: -3deg; }
+ 75% { rotate: 2deg; }
+}
+@keyframes avatar-pulse {
+ 0%, 100% { scale: 1; }
+ 35% { scale: 1.05; }
+ 70% { scale: 0.97; }
+}
+@keyframes avatar-spin {
+ 0% { rotate: 0; }
+ 100% { rotate: 360deg; }
+}
+@keyframes avatar-jelly {
+ 0%, 100% { scale: 1 1; }
+ 30% { scale: 1.1 0.9; }
+ 65% { scale: 0.95 1.05; }
+}
+@keyframes avatar-float {
+ 0%, 100% { translate: 0 0; }
+ 35% { translate: 0 -4px; }
+ 70% { translate: 0 4px; }
+}
+@keyframes avatar-nod {
+ 0%, 100% { rotate: 0; }
+ 50% { rotate: 8deg; }
+}
+
+.avatar-anim-shape-bounce [data-avatar-shape] {
+ animation: avatar-shape-bounce 500ms ease-in-out infinite;
+}
+.avatar-anim-head-tilt [data-avatar-shape],
+.avatar-anim-head-tilt [data-avatar-eyes],
+.avatar-anim-head-tilt [data-avatar-nose] {
+ animation: avatar-head-tilt 600ms ease-in-out infinite;
+}
+.avatar-anim-shake {
+ animation: avatar-shake 400ms ease-in-out infinite;
+}
+.avatar-anim-wobble [data-avatar-shape],
+.avatar-anim-wobble [data-avatar-eyes],
+.avatar-anim-wobble [data-avatar-nose] {
+ animation: avatar-wobble 800ms ease-in-out infinite;
+}
+.avatar-anim-pulse {
+ animation: avatar-pulse 600ms ease-in-out infinite;
+}
+.avatar-anim-spin [data-avatar-shape] {
+ animation: avatar-spin 700ms ease-in-out infinite;
+}
+.avatar-anim-jelly [data-avatar-shape] {
+ animation: avatar-jelly 500ms ease-in-out infinite;
+}
+.avatar-anim-float {
+ animation: avatar-float 800ms ease-in-out infinite;
+}
+.avatar-anim-nod [data-avatar-shape],
+.avatar-anim-nod [data-avatar-eyes],
+.avatar-anim-nod [data-avatar-nose] {
+ animation: avatar-nod 500ms ease-in-out infinite;
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .avatar-anim-shape-bounce [data-avatar-shape],
+ .avatar-anim-head-tilt [data-avatar-shape],
+ .avatar-anim-head-tilt [data-avatar-eyes],
+ .avatar-anim-head-tilt [data-avatar-nose],
+ .avatar-anim-shake,
+ .avatar-anim-wobble [data-avatar-shape],
+ .avatar-anim-wobble [data-avatar-eyes],
+ .avatar-anim-wobble [data-avatar-nose],
+ .avatar-anim-pulse,
+ .avatar-anim-spin [data-avatar-shape],
+ .avatar-anim-jelly [data-avatar-shape],
+ .avatar-anim-float,
+ .avatar-anim-nod [data-avatar-shape],
+ .avatar-anim-nod [data-avatar-eyes],
+ .avatar-anim-nod [data-avatar-nose] {
+ animation: none !important;
+ }
+}
+
/* ── Mobile optimizations ── */
html, body {
overscroll-behavior: none;
diff --git a/src/web/src/components/agent-preview-card.tsx b/src/web/src/components/agent-preview-card.tsx
index 884ad9b21..9bff4b55d 100644
--- a/src/web/src/components/agent-preview-card.tsx
+++ b/src/web/src/components/agent-preview-card.tsx
@@ -4,7 +4,7 @@ import { useCallback, useState } from "react";
import type { Agent } from "@alook/shared";
import { Check, Copy } from "lucide-react";
import { toast } from "sonner";
-import { AvatarRenderer, parseAvatarUrl } from "@/components/avatar";
+import { AnimatedAvatar, AvatarRenderer, parseAvatarUrl } from "@/components/avatar";
import { AgentStatusBadge } from "@/components/agent-status-badge";
interface AgentPreviewCardProps {
@@ -12,6 +12,7 @@ interface AgentPreviewCardProps {
isOnline?: boolean;
activeTaskCount?: number;
variant?: "default" | "compact";
+ isHovered?: boolean;
}
export function AgentPreviewCard({
@@ -19,6 +20,7 @@ export function AgentPreviewCard({
isOnline,
activeTaskCount,
variant = "default",
+ isHovered,
}: AgentPreviewCardProps) {
const [copied, setCopied] = useState(false);
const email = agent.email_handle ? `${agent.email_handle}@alook.ai` : null;
@@ -42,7 +44,7 @@ export function AgentPreviewCard({
{(() => {
const avatarConfig = parseAvatarUrl(agent.avatar_url);
if (avatarConfig) {
- return <AvatarRenderer config={avatarConfig} size={32} className="shrink-0 rounded-xl" />;
+ return <AnimatedAvatar config={avatarConfig} size={32} className="shrink-0 rounded-xl" isHovered={isHovered ?? false} />;
}
return (
<div className="flex items-center justify-center size-8 rounded-xl bg-secondary text-secondary-foreground text-xs font-medium shrink-0">
diff --git a/src/web/src/components/avatar/animated-avatar.tsx b/src/web/src/components/avatar/animated-avatar.tsx
new file mode 100644
index 000000000..7d6f42703
--- /dev/null
+++ b/src/web/src/components/avatar/animated-avatar.tsx
@@ -0,0 +1,46 @@
+"use client";
+
+import { useEffect, useRef, useState } from "react";
+import { AvatarRenderer } from "./avatar-parts";
+import type { AvatarConfig } from "./avatar-parts";
+
+const ANIMATIONS = [
+ "avatar-anim-shape-bounce",
+ "avatar-anim-head-tilt",
+ "avatar-anim-shake",
+ "avatar-anim-wobble",
+ "avatar-anim-pulse",
+ "avatar-anim-spin",
+ "avatar-anim-jelly",
+ "avatar-anim-float",
+ "avatar-anim-nod",
+] as const;
+
+interface AnimatedAvatarProps {
+ config: AvatarConfig;
+ size?: number;
+ className?: string;
+ isHovered: boolean;
+}
+
+export function AnimatedAvatar({ config, size, className, isHovered }: AnimatedAvatarProps) {
+ const [animClass, setAnimClass] = useState<string | null>(null);
+ const lastPickRef = useRef(-1);
+
+ useEffect(() => {
+ if (isHovered) {
+ let idx = Math.floor(Math.random() * ANIMATIONS.length);
+ if (idx === lastPickRef.current) idx = (idx + 1) % ANIMATIONS.length;
+ lastPickRef.current = idx;
+ setAnimClass(ANIMATIONS[idx]!);
+ } else {
+ setAnimClass(null);
+ }
+ }, [isHovered]);
+
+ return (
+ <div className={animClass ?? undefined}>
+ <AvatarRenderer config={config} size={size} className={className} />
+ </div>
+ );
+}
diff --git a/src/web/src/components/avatar/avatar-parts.tsx b/src/web/src/components/avatar/avatar-parts.tsx
index 67e69dc21..5a8888dda 100644
--- a/src/web/src/components/avatar/avatar-parts.tsx
+++ b/src/web/src/components/avatar/avatar-parts.tsx
@@ -297,9 +297,9 @@ export function AvatarRenderer({ config, size = 200, className }: AvatarRenderer
style={{ display: "block" }}
>
<rect x="0" y="0" width="200" height="200" rx="56" fill={bgColor} />
- {sh.render()}
- {ey && <g transform={`translate(${cx}, ${eyeY})`}>{ey.render(eyeDx)}</g>}
- {no && <g transform={`translate(${cx}, ${cy + 5})`}>{no.render()}</g>}
+ <g data-avatar-shape="">{sh.render()}</g>
+ {ey && <g transform={`translate(${cx}, ${eyeY})`}><g data-avatar-eyes="">{ey.render(eyeDx)}</g></g>}
+ {no && <g transform={`translate(${cx}, ${cy + 5})`}><g data-avatar-nose="">{no.render()}</g></g>}
</svg>
);
}
diff --git a/src/web/src/components/avatar/index.ts b/src/web/src/components/avatar/index.ts
index 5dd0f633b..06b0993e8 100644
--- a/src/web/src/components/avatar/index.ts
+++ b/src/web/src/components/avatar/index.ts
@@ -7,5 +7,6 @@ export {
randomConfig,
} from "./avatar-parts";
+export { AnimatedAvatar } from "./animated-avatar";
export { AvatarGenerator } from "./avatar-generator";
export { AvatarPickerDialog } from "./avatar-picker-dialog";
diff --git a/src/web/src/components/canvas/agent-node.tsx b/src/web/src/components/canvas/agent-node.tsx
index 784fddc8d..0ffb497a3 100644
--- a/src/web/src/components/canvas/agent-node.tsx
+++ b/src/web/src/components/canvas/agent-node.tsx
@@ -1,6 +1,6 @@
"use client";
-import { memo } from "react";
+import { memo, useState } from "react";
import { Handle, Position, type NodeProps } from "@xyflow/react";
import type { Agent, AgentRuntime } from "@alook/shared";
import { AgentPreviewCard } from "@/components/agent-preview-card";
@@ -23,9 +23,12 @@ function AgentNodeInner({ data, selected, dragging }: NodeProps) {
const rt = runtimes.find((r: AgentRuntime) => r.id === agent.runtime_id);
const isOnline = rt?.status === "online";
+ const [isHovered, setIsHovered] = useState(false);
return (
<div
+ onMouseEnter={() => setIsHovered(true)}
+ onMouseLeave={() => setIsHovered(false)}
className={cn(
"bg-background rounded-xl ring-1 ring-foreground/8 shadow-sm transition-all duration-200 py-3 px-3.5 group",
selected && "ring-2 ring-primary/30 shadow-md",
@@ -49,6 +52,7 @@ function AgentNodeInner({ data, selected, dragging }: NodeProps) {
isOnline={isOnline}
activeTaskCount={activeTaskCount}
variant="compact"
+ isHovered={isHovered}
/>
</div>
);