48 lines
1.3 KiB
Rust
48 lines
1.3 KiB
Rust
use crate::types::*;
|
|
|
|
use yew::{html, Component, Context, Html, Properties};
|
|
|
|
pub struct NewCommentFormComponent {}
|
|
|
|
#[derive(Properties, PartialEq)]
|
|
pub struct NewCommentFormProps {
|
|
pub root_id: String, // TODO maybe opti
|
|
pub topic: String,
|
|
}
|
|
|
|
impl Component for NewCommentFormComponent {
|
|
type Message = ();
|
|
type Properties = NewCommentFormProps;
|
|
|
|
fn create(_ctx: &Context<Self>) -> Self {
|
|
Self {}
|
|
}
|
|
|
|
fn update(&mut self, _ctx: &Context<Self>, msg: Self::Message) -> bool {
|
|
false
|
|
}
|
|
|
|
fn view(&self, ctx: &Context<Self>) -> Html {
|
|
let props = ctx.props();
|
|
let comment_id = props.comment.id.to_base64();
|
|
let elem_id = format!("{}-{}", props.root_id, comment_id);
|
|
html! {
|
|
<div class={ format!("comment comment-{}", comment_id) } id={ elem_id.clone() }>
|
|
<p class="comment-meta">
|
|
<a class="comment-post_time" aria-label="Permalink" title="Permalink" href={ format!("#{elem_id}") }>{ props.comment.post_time }</a>
|
|
<span class="comment-author"></span>
|
|
{
|
|
if let Some(email) = &props.comment.email {
|
|
html! { <span class="comment-email">{ email }</span> }
|
|
} else {
|
|
html! {}
|
|
}
|
|
}
|
|
<a class="comment-edition comment-edition-remove" href="#">{ "Remove" }</a>
|
|
</p>
|
|
<p class="comment-text">{ &props.comment.text }</p>
|
|
</div>
|
|
}
|
|
}
|
|
}
|