From 620cffe99147e7e04e27c6975c99aaedfa2eb096 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Fri, 12 Apr 2024 14:58:43 +0200 Subject: add aspect class to poster in node page --- server/src/routes/ui/node.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'server/src') 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.)] { -- cgit v1.2.3-70-g09d2