Cartoon pug (inline SVG) on Home: sleeps when nothing waits, perks up with a speech bubble and question count when agents ask. Motion only without prefers-reduced-motion. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
90 lines
4.3 KiB
TypeScript
90 lines
4.3 KiB
TypeScript
// PEP-70: Peppa's mascot — a cartoon pug next to the agents' questions. Pure SVG (no external
|
||
// images), fixed fawn/black colours that read on both themes; motion only without reduced-motion.
|
||
import { cn } from "@/lib/utils";
|
||
|
||
type Mood = "sleep" | "alert";
|
||
|
||
export function PugMascot({ mood, size = 72, className }: { mood: Mood; size?: number; className?: string }) {
|
||
const awake = mood === "alert";
|
||
return (
|
||
<svg
|
||
viewBox="0 0 120 120"
|
||
width={size}
|
||
height={size}
|
||
role="img"
|
||
aria-label={awake ? "Мопс Пеппы ждёт твоего ответа" : "Мопс Пеппы спит"}
|
||
className={cn("shrink-0 overflow-visible", awake ? "pug-alert" : "pug-sleep", className)}
|
||
>
|
||
<g className="pug-head" style={{ transformOrigin: "60px 70px" }}>
|
||
{/* head */}
|
||
<ellipse cx="60" cy="66" rx="45" ry="41" fill="#ebcb9e" stroke="#c9a06e" strokeWidth="2" />
|
||
{/* folded "button" ears flop over the head */}
|
||
<path d="M38 30 C26 22 10 26 9 42 C9 50 15 53 21 48 C26 43 31 39 40 36 Z" fill="#4a3a35" />
|
||
<path d="M82 30 C94 22 110 26 111 42 C111 50 105 53 99 48 C94 43 89 39 80 36 Z" fill="#4a3a35" />
|
||
{/* forehead wrinkles */}
|
||
<path d="M47 40 Q60 33 73 40" fill="none" stroke="#c49a68" strokeWidth="2.5" strokeLinecap="round" />
|
||
<path d="M51 47 Q60 42 69 47" fill="none" stroke="#c49a68" strokeWidth="2.5" strokeLinecap="round" />
|
||
{/* cheeks */}
|
||
<ellipse cx="25" cy="80" rx="7" ry="4" fill="#f4a3a8" opacity="0.7" />
|
||
<ellipse cx="95" cy="80" rx="7" ry="4" fill="#f4a3a8" opacity="0.7" />
|
||
{/* black mask */}
|
||
<ellipse cx="60" cy="83" rx="25" ry="19" fill="#4a3a35" />
|
||
{/* eyes */}
|
||
{awake ? (
|
||
<>
|
||
<circle cx="39" cy="62" r="12" fill="#2b2220" />
|
||
<circle cx="81" cy="62" r="12" fill="#2b2220" />
|
||
<circle cx="43.5" cy="57.5" r="4.5" fill="#fff" />
|
||
<circle cx="85.5" cy="57.5" r="4.5" fill="#fff" />
|
||
<circle cx="35.5" cy="66" r="2" fill="#fff" />
|
||
<circle cx="77.5" cy="66" r="2" fill="#fff" />
|
||
</>
|
||
) : (
|
||
<>
|
||
<path d="M28 63 Q39 70 50 63" fill="none" stroke="#2b2220" strokeWidth="3.5" strokeLinecap="round" />
|
||
<path d="M70 63 Q81 70 92 63" fill="none" stroke="#2b2220" strokeWidth="3.5" strokeLinecap="round" />
|
||
</>
|
||
)}
|
||
{/* nose */}
|
||
<ellipse cx="60" cy="75" rx="9" ry="5.5" fill="#1d1716" />
|
||
<ellipse cx="57" cy="73.5" rx="3" ry="1.5" fill="#fff" opacity="0.55" />
|
||
{/* mouth + tongue */}
|
||
<path d="M60 80 L60 85 M51 85 Q55.5 90 60 85 Q64.5 90 69 85" fill="none" stroke="#1d1716" strokeWidth="2.5" strokeLinecap="round" />
|
||
{awake && <path d="M55.5 88 Q60 101 64.5 88 Z" fill="#f28b9b" stroke="#d96a7c" strokeWidth="1.5" />}
|
||
</g>
|
||
{!awake && (
|
||
<g className="pug-zzz" fill="currentColor" fontFamily="inherit" fontWeight="700" opacity="0.55">
|
||
<text x="100" y="22" fontSize="14">z</text>
|
||
<text x="110" y="10" fontSize="10">z</text>
|
||
</g>
|
||
)}
|
||
</svg>
|
||
);
|
||
}
|
||
|
||
/** Mascot with a speech bubble: sleeps when nothing waits, perks up when agents ask. */
|
||
export function PugBanner({ count }: { count: number }) {
|
||
const awake = count > 0;
|
||
return (
|
||
<div className="flex items-center gap-3">
|
||
<PugMascot mood={awake ? "alert" : "sleep"} className="text-muted-foreground" />
|
||
<div className="relative rounded-2xl border bg-card px-4 py-2.5 text-sm shadow-xs before:absolute before:top-1/2 before:-left-[7px] before:size-3 before:-translate-y-1/2 before:rotate-45 before:border-b before:border-l before:bg-card">
|
||
{awake ? (
|
||
<>
|
||
<span className="font-medium">Гав! {count === 1 ? "Агент ждёт" : "Агенты ждут"} твоего ответа</span>
|
||
<span className="text-muted-foreground"> — {plural(count)} ниже.</span>
|
||
</>
|
||
) : (
|
||
<span className="text-muted-foreground">Тихо… Агентам от тебя ничего не нужно, мопс спит.</span>
|
||
)}
|
||
</div>
|
||
</div>
|
||
);
|
||
}
|
||
|
||
function plural(n: number) {
|
||
const m10 = n % 10, m100 = n % 100;
|
||
const w = m10 === 1 && m100 !== 11 ? "вопрос" : m10 >= 2 && m10 <= 4 && (m100 < 12 || m100 > 14) ? "вопроса" : "вопросов";
|
||
return `${n} ${w}`;
|
||
}
|