51 lines
1.3 KiB
Rust
51 lines
1.3 KiB
Rust
use crate::types::*;
|
|
|
|
use yew::{html, Component, Context, Html, Properties};
|
|
|
|
pub struct CommentComponent {}
|
|
|
|
#[derive(Properties, PartialEq)]
|
|
pub struct CommentProps {
|
|
pub root_id: String, // TODO maybe opti
|
|
pub comment: FullComment,
|
|
}
|
|
|
|
pub enum Msg {
|
|
}
|
|
|
|
impl Component for CommentComponent {
|
|
type Message = Msg;
|
|
type Properties = CommentProps;
|
|
|
|
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>
|
|
}
|
|
}
|
|
}
|