"use client"; import Image from "next/image"; import { useEffect, useState, type CSSProperties } from "react"; import { cn, onIdle } from "@/lib/utils"; /** * Each face is hidden outright while it's turned away, switching as the flip * passes edge-on (114 ms into the spring below). backface-visibility alone isn't * enough: the theme switch's snapshot ignores it, which showed Bert. */ const face = (shown: boolean): CSSProperties => ({ visibility: shown ? "visible" : "hidden", transition: "visibility 0s linear 114ms", }); /** Tap the avatar to flip it over and meet Bert. */ export function AvatarFlip({ avatarUrl, dogUrl, }: { avatarUrl: string; dogUrl: string; }) { const [flipped, setFlipped] = useState(false); const [showDog, setShowDog] = useState(false); useEffect(() => { const meet = () => { setShowDog(true); setFlipped(true); }; const cancelIdle = onIdle(() => setShowDog(true), 5000); window.addEventListener("eric:bert", meet); return () => { window.removeEventListener("eric:bert", meet); cancelIdle(); }; }, []); return ( ); }