89 lines
3.7 KiB
HTML
89 lines
3.7 KiB
HTML
@use crate::ActixLoader;
|
|
@use crate::comments::CommentView;
|
|
@use crate::extensions::{CommentExt, 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;
|
|
@use i18n_embed_fl::fl;
|
|
|
|
@(loader: &ActixLoader, view: &CommentView, nav_state: &NavState)
|
|
|
|
@if let Some(comment) = view.comments.comment(&view.cache) {
|
|
@:home(loader, &view.author().profile.name(), comment.body(), nav_state, {
|
|
@:button_js()
|
|
}, {
|
|
@:card(&Card::full_width().dark(nav_state.dark()), {
|
|
@:card_title({
|
|
@fl!(loader, "comment-heading")
|
|
})
|
|
@:card_body({
|
|
<div class="comment">
|
|
<div class="comment-body">
|
|
@:profile_box(loader, &view.author(), comment.published(), &view.parent(), &view.cache, nav_state.dark(), {
|
|
@if let Some(state) = view.comments.edit_link(&view.cache) {
|
|
<div>
|
|
@:link(&state, {
|
|
@fl!(loader, "edit-link")
|
|
})
|
|
</div>
|
|
}
|
|
}, {
|
|
<div class="comment-text">
|
|
@:bbcode({
|
|
@Html(comment.body())
|
|
})
|
|
</div>
|
|
})
|
|
</div>
|
|
</div>
|
|
})
|
|
@:card_body({
|
|
@if view.logged_in {
|
|
<form method="POST" action="@comment.reply_path()">
|
|
@:text_input(&view.input(loader).dark(nav_state.dark()))
|
|
<div class="button-section">
|
|
@:button_group(&[
|
|
Button::primary(&fl!(loader, "reply-button")),
|
|
Button::secondary(&fl!(loader, "back-to-submission-button")).href(&view.submission_path()),
|
|
Button::primary_outline(&fl!(loader, "report-button")).href(&comment.report_path()),
|
|
])
|
|
</div>
|
|
</form>
|
|
} else {
|
|
@:button_group(&[
|
|
Button::secondary(&fl!(loader, "back-to-submission-button")).href(&view.submission_path()),
|
|
])
|
|
}
|
|
})
|
|
})
|
|
|
|
@if view.comments.has_children() {
|
|
@:card(&Card::full_width().dark(nav_state.dark()), {
|
|
@:card_title({
|
|
@fl!(loader, "replies-section-heading")
|
|
})
|
|
@:card_body({
|
|
@:nested(nav_state.dark(), {
|
|
@:nested_children({
|
|
@for child in &view.comments.children {
|
|
@:nodes(loader, child, &view.cache, &view.comments, view.logged_in, nav_state.dark())
|
|
}
|
|
})
|
|
})
|
|
})
|
|
})
|
|
}
|
|
})
|
|
} else {
|
|
@:home(loader, &fl!(loader, "comment-missing-title"), &fl!(loader, "comment-missing-subtitle"), nav_state, {}, {
|
|
@fl!(loader, "comment-missing-subtitle")
|
|
})
|
|
}
|