@use crate::extensions::SubmissionExt; @use crate::nav::NavState; @use crate::submissions::ViewSubmissionState; @use crate::templates::button_js; @use crate::templates::layouts::home; @use crate::templates::comments::nodes; @use crate::templates::submissions::profile_box; @use hyaenidae_toolkit::{templates::button_group, Button}; @use hyaenidae_toolkit::{templates::{card, card_body, card_section, card_spacer, card_title}, Card}; @use hyaenidae_toolkit::templates::image; @use hyaenidae_toolkit::templates::nested; @use hyaenidae_toolkit::templates::text_input; @use hyaenidae_toolkit::{templates::{tile, tiles}, Tiles}; @(view: &ViewSubmissionState, nav_state: &NavState) @:home(&view.submission.title_text(), view.submission.description_text().unwrap_or(&format!("{} hosted on Hyaenidae", view.submission.title_text())), nav_state, { @:button_js() }, { @:card(&Card::full_width().dark(nav_state.dark()), { @:card_title({ @view.submission.title_text() }) @:card_section({ @if let Some(img) = view.image() {
@:image(&img)
} else {
Failed to display image
} }) @if view.tiles().len() > 1 { @:card_spacer() @:card_section({ @:tiles(&Tiles::new().small(true).scroll(true), { @for t in view.tiles() { @:tile(&t) } }) }) } @:card_body({
@:button_group(&view.nav)
}) @:card_body({ @:profile_box(&view.poster(), view.submission.published(), nav_state.dark(), { @if let Some(description) = view.submission.description_text() { @description } }) }) }) @if view.is_self { @:card(&Card::full_width().dark(nav_state.dark()), { @:card_title({ Edit Submission }) @:card_body({ @:button_group(&[ Button::primary("Edit").href(&view.submission.update_path()), ]) }) }) } @if view.profile.is_some() && view.submission.published().is_some() { @:card(&Card::full_width().dark(nav_state.dark()), {
@:card_title({ Comment }) @:card_body({ @:text_input(&view.comment_input) }) @:card_body({ @:button_group(&[ Button::primary("Submit"), ]) })
}) } @if view.comments.has_children() { @:card(&Card::full_width().dark(nav_state.dark()), { @:card_title({ Comments }) @:card_body({ @:nested(nav_state.dark(), { @:nodes(&view.comments, &view.cache, &view.parent(), view.profile.is_some(), nav_state.dark()) }) }) }) } })