aboutsummaryrefslogtreecommitdiff
path: root/ui/src/components/message.rs
blob: a271d4081b38cd97a863ec77125d25b74b0ba18c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
    This file is part of jellything (https://codeberg.org/metamuffin/jellything)
    which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
    Copyright (C) 2026 metamuffin <metamuffin.org>
*/
use crate::RenderInfo;
use jellycommon::{MESSAGE_KIND, MESSAGE_TEXT, jellyobject::Object};
use markup::define;

define! {
    Message<'a>(ri: &'a RenderInfo<'a>, message: Object<'a>) {
        @let _ = ri;
        @let text = message.get(MESSAGE_TEXT).unwrap_or_default();
        @match message.get(MESSAGE_KIND).unwrap_or("neutral") {
            "success" => { section.message { p.success { @text } } }
            "error" => { section.message { p.error { @text } } }
            "neutral" | _ => { section.message { p { @text } } }
        }
    }
}