@use crate::comments::CommentView; @use crate::extensions::ProfileExt; @use crate::nav::NavState; @use crate::templates::button_js; @use crate::templates::layouts::home; @use crate::templates::comments::{nodes, profile_box}; @use hyaenidae_toolkit::templates::bbcode; @use hyaenidae_toolkit::{templates::button_group, Button}; @use hyaenidae_toolkit::{templates::{card, card_title, card_body}, Card}; @use hyaenidae_toolkit::templates::link; @use hyaenidae_toolkit::templates::{nested, nested_children}; @use hyaenidae_toolkit::templates::text_input; @(view: &CommentView, nav_state: &NavState) @if let Some(comment) = view.comments.comment(&view.cache) { @:home(&view.author().profile.name(), comment.body(), nav_state, { @:button_js() }, { @:card(&Card::full_width().dark(nav_state.dark()), { @:card_title({ Comment }) @:card_body({
@:profile_box(&view.author(), comment.published(), &view.parent(), &view.cache, nav_state.dark(), { @if let Some(state) = view.comments.edit_link(&view.cache) {
@:link(&state, { edit })
} }, {
@:bbcode({ @Html(comment.body()) })
})
}) @:card_body({ @if view.logged_in {
@:text_input(&view.input)
@:button_group(&[ Button::primary("Reply"), Button::secondary("Back to Submission").href(&view.submission_path()), Button::primary_outline("Report").href(&crate::comments::report_path(comment)), ])
} else { @:button_group(&[ Button::secondary("Back to Submission").href(&view.submission_path()), ]) } }) }) @if view.comments.has_children() { @:card(&Card::full_width().dark(nav_state.dark()), { @:card_title({ Replies }) @:card_body({ @:nested(nav_state.dark(), { @:nested_children({ @for child in &view.comments.children { @:nodes(child, &view.cache, &view.comments, view.logged_in, nav_state.dark()) } }) }) }) }) } }) } else { @:home("Comment Gone", "Not sure where that comment went!", nav_state, {}, { Not sure where that comment went! }) }