Refactor: Vertical and more detailed Comments
This commit is contained in:
parent
f4ba90a130
commit
cfdd389e90
@ -3,12 +3,18 @@
|
|||||||
import Avatar from "./avatar.svelte";
|
import Avatar from "./avatar.svelte";
|
||||||
import Mention from "./mention.svelte";
|
import Mention from "./mention.svelte";
|
||||||
import Rating from "./rating.svelte";
|
import Rating from "./rating.svelte";
|
||||||
|
import Tablericon from "./tablericon.svelte";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {import("$types/base").CommentTreeNode}
|
* @type {import("$types/base").CommentTreeNode}
|
||||||
*/
|
*/
|
||||||
export let commentNode;
|
export let commentNode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {import("$types/base").CommentTreeNode | null}
|
||||||
|
*/
|
||||||
|
export let replyTo = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {(function(import("$types/base").Comment): string[]) | undefined}
|
* @type {(function(import("$types/base").Comment): string[]) | undefined}
|
||||||
*/
|
*/
|
||||||
@ -54,32 +60,60 @@
|
|||||||
.date {
|
.date {
|
||||||
color: var(--white-dim);
|
color: var(--white-dim);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.comment {
|
||||||
|
display: flex;
|
||||||
|
flex-flow: column nowrap;
|
||||||
|
width: 100%;
|
||||||
|
gap: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.replyBar {
|
||||||
|
display: flex;
|
||||||
|
flex-flow: row nowrap;
|
||||||
|
gap: 4px;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
font-size: 0.85em;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div class="message">
|
<div class="message">
|
||||||
<Avatar size={48}></Avatar>
|
<Avatar size={48}></Avatar>
|
||||||
<div class="content">
|
<div class="comment">
|
||||||
<div class="topBar">
|
<div class="content">
|
||||||
<div class="nameField">
|
<div class="topBar">
|
||||||
<Mention user={comment.author}></Mention>
|
<div class="nameField">
|
||||||
{#each tags as tag}
|
<Mention user={comment.author}></Mention>
|
||||||
<span class="tag typeContent">{tag}</span>
|
{#each tags as tag}
|
||||||
{/each}
|
<span class="tag typeContent">{tag}</span>
|
||||||
|
{/each}
|
||||||
|
|
||||||
|
{#if replyTo}
|
||||||
|
<span class="replyBar">
|
||||||
|
<Tablericon name="square-rounded-arrow-right" size={16} color="white"></Tablericon>
|
||||||
|
reply
|
||||||
|
<Mention user={replyTo.parent.author}></Mention>
|
||||||
|
</span>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<span class="date">{moment(comment.commentDate).fromNow()}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span class="date">{moment(comment.commentDate).fromNow()}</span>
|
<p>{comment.content}</p>
|
||||||
</div>
|
|
||||||
|
<div class="actionBar">
|
||||||
<p>{comment.content}</p>
|
<Rating rating={comment.rating}></Rating>
|
||||||
|
</div>
|
||||||
<div class="actionBar">
|
|
||||||
<Rating rating={comment.rating}></Rating>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{#if commentNode.children.length}
|
||||||
<div class="replyTree">
|
<div class="replyTree">
|
||||||
{#each commentNode.children as reply}
|
{#each commentNode.children as reply}
|
||||||
<svelte:self commentNode={reply} getTags={getTags}></svelte:self>
|
<svelte:self commentNode={reply} getTags={getTags} replyTo={commentNode}></svelte:self>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -45,7 +45,7 @@
|
|||||||
.commentList {
|
.commentList {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-flow: column nowrap;
|
flex-flow: column nowrap;
|
||||||
gap: 16px;
|
gap: 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comments {
|
.comments {
|
||||||
@ -91,7 +91,7 @@
|
|||||||
{#each commentTree as reply}
|
{#each commentTree as reply}
|
||||||
<Comment commentNode={reply} getTags={(comment) => {
|
<Comment commentNode={reply} getTags={(comment) => {
|
||||||
if (comment.author?.id == post.author?.id) {
|
if (comment.author?.id == post.author?.id) {
|
||||||
return ["OP"];
|
return ["OP 🖋️"];
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
}}></Comment>
|
}}></Comment>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user