aboutsummaryrefslogtreecommitdiff
path: root/ui/src/components/node_list.rs
blob: d1d16fbeaffec31a29773750a9c4af47434f630c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
    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,
    components::node_card::{NodeCard, NodeCardWide},
};
use jellycommon::{jellyobject::Object, *};
use jellyui_locale::tr;

markup::define! {
    NodeList<'a>(ri: &'a RenderInfo<'a>, nl: Object<'a>) {
        @let ds = nl.get(NODELIST_DISPLAYSTYLE).unwrap_or(NLSTYLE_GRID);
        @if let Some(title) = nl.get(NODELIST_TITLE) {
            h2 { @tr(ri.lang, title) }
        }
        @if ds == NLSTYLE_GRID {
            ul.nl.grid { @for nku in nl.iter(NODELIST_ITEM) {
                li { @NodeCard { ri, nku } }
            }}
        }
        @if ds == NLSTYLE_INLINE {
            ul.nl.inline { @for nku in nl.iter(NODELIST_ITEM) {
                li { @NodeCard { ri, nku } }
            }}
        }
        @if ds == NLSTYLE_LIST {
            ol.nl.list { @for nku in nl.iter(NODELIST_ITEM) {
                li { @NodeCardWide { ri, nku } }
            }}
        }
    }
}