diff options
author | metamuffin <metamuffin@disroot.org> | 2024-04-12 14:58:43 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-04-12 14:58:43 +0200 |
commit | 620cffe99147e7e04e27c6975c99aaedfa2eb096 (patch) | |
tree | 0abd7334bad7b655d7184f6a0e8c61a9454a2c03 | |
parent | 1179447d0934e6205af2e37a1d0a9eed514b5523 (diff) | |
download | jellything-620cffe99147e7e04e27c6975c99aaedfa2eb096.tar jellything-620cffe99147e7e04e27c6975c99aaedfa2eb096.tar.bz2 jellything-620cffe99147e7e04e27c6975c99aaedfa2eb096.tar.zst |
add aspect class to poster in node page
-rw-r--r-- | server/src/routes/ui/node.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/server/src/routes/ui/node.rs b/server/src/routes/ui/node.rs index 327add0..043bf10 100644 --- a/server/src/routes/ui/node.rs +++ b/server/src/routes/ui/node.rs @@ -121,7 +121,7 @@ pub async fn r_library_node_filter<'a>( markup::define! { NodeCard<'a>(id: &'a str, node: &'a NodePublic, udata: &'a NodeUserData) { - @let cls = format!("node card poster {}", match node.kind.unwrap_or_default() {NodeKind::Channel => "aspect-square", NodeKind::Video => "aspect-thumb", NodeKind::Collection => "aspect-land", _ => "aspect-port"}); + @let cls = format!("node card poster {}", aspect_class(node.kind.unwrap_or_default())); div[class=cls] { .poster { a[href=uri!(r_library_node(id))] { @@ -152,7 +152,8 @@ markup::define! { } .page.node { @if !matches!(node.kind.unwrap_or_default(), NodeKind::Collection) { - div.bigposter { img[src=uri!(r_item_assets(id, AssetRole::Poster, Some(2048))), loading="lazy"]; } + @let cls = format!("bigposter {}", aspect_class(node.kind.unwrap_or_default())); + div[class=cls] { img[src=uri!(r_item_assets(id, AssetRole::Poster, Some(2048))), loading="lazy"]; } } .title { h1 { @node.title } @@ -299,6 +300,15 @@ markup::define! { } } +pub fn aspect_class(kind: NodeKind) -> &'static str { + match kind { + NodeKind::Channel => "aspect-square", + NodeKind::Video => "aspect-thumb", + NodeKind::Collection => "aspect-land", + _ => "aspect-port", + } +} + pub fn format_duration(mut d: f64) -> String { let mut s = String::new(); for (unit, k) in [("h", 60. * 60.), ("m", 60.), ("s", 1.)] { |