Skip to main content

yggdrasil/components/
mascot.rs

1//! 吉祥物像素贴图:橙发女孩的各种表情,只作装饰,对读屏隐藏。
2
3use leptos::prelude::*;
4
5/// 表情与 `public/images/mascot/*.webp` 一一对应(256×256,由原始 1024 图缩放)。
6#[derive(Clone, Copy, PartialEq, Eq)]
7pub enum Mascot {
8    Wave,
9    Panic,
10    Cry,
11    Hearts,
12    Sit,
13    Sleepy,
14    Doze,
15    Blissful,
16    Peace,
17    Curious,
18    Pout,
19}
20
21impl Mascot {
22    pub const fn src(self) -> &'static str {
23        match self {
24            Mascot::Wave => "/images/mascot/wave.webp",
25            Mascot::Panic => "/images/mascot/panic.webp",
26            Mascot::Cry => "/images/mascot/cry.webp",
27            Mascot::Hearts => "/images/mascot/hearts.webp",
28            Mascot::Sit => "/images/mascot/sit.webp",
29            Mascot::Sleepy => "/images/mascot/sleepy.webp",
30            Mascot::Doze => "/images/mascot/doze.webp",
31            Mascot::Blissful => "/images/mascot/blissful.webp",
32            Mascot::Peace => "/images/mascot/peace.webp",
33            Mascot::Curious => "/images/mascot/curious.webp",
34            Mascot::Pout => "/images/mascot/pout.webp",
35        }
36    }
37
38    /// 装饰性 `<img>`。`class` 需写全,含基础类 `mascot`(例:`"mascot home-hero-mascot"`)。
39    pub fn img(self, class: &'static str) -> impl IntoView {
40        view! {
41            <img class=class src=self.src() alt="" aria-hidden="true"
42                width="256" height="256" decoding="async" loading="lazy"/>
43        }
44    }
45}