Redesign comments into glass bubble format
- Top-level comments render as glass-card bubbles with subtle border, backdrop blur, and hover highlight - Replies use a lighter, more compact bubble variant - Threaded replies connected by a vertical line on the left instead of raw margin indentation - Action buttons (upvote, downvote, reply, expand) styled as pill-shaped micro-buttons inside each bubble - Reply form nests inline within the parent bubble - Proper spacing and responsive padding at all nesting depths Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,118 +1,114 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="comment-thread" :style="{ marginLeft: depth > 0 ? `${Math.min(depth, 4) * 20}px` : '0' }">
|
<div class="comment-thread" :class="{ 'reply-thread': depth > 0 }">
|
||||||
<div class="comment-item" :class="{ 'comment-reply': depth > 0 }">
|
<!-- Bubble -->
|
||||||
<div class="flex gap-3">
|
<div class="comment-bubble" :class="bubbleClass">
|
||||||
<!-- Author Avatar (robohash fallback) -->
|
<!-- Author Row -->
|
||||||
|
<div class="flex items-center gap-2.5 mb-2">
|
||||||
<img
|
<img
|
||||||
:src="authorAvatar"
|
:src="authorAvatar"
|
||||||
:alt="authorName"
|
:alt="authorName"
|
||||||
class="w-8 h-8 rounded-full flex-shrink-0 object-cover"
|
class="w-7 h-7 rounded-full flex-shrink-0 object-cover ring-1 ring-white/10"
|
||||||
/>
|
/>
|
||||||
|
<span class="text-white text-sm font-semibold truncate">{{ authorName }}</span>
|
||||||
|
<span class="text-white/30 text-[11px] flex-shrink-0 ml-auto">{{ timeAgo }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="flex-1 min-w-0">
|
<!-- Comment Content -->
|
||||||
<!-- Author + Timestamp -->
|
<p class="text-white/80 text-[13px] leading-relaxed whitespace-pre-wrap pl-[38px]">{{ node.event.content }}</p>
|
||||||
<div class="flex items-center gap-2 mb-1">
|
|
||||||
<span class="text-white text-sm font-medium truncate">{{ authorName }}</span>
|
|
||||||
<span class="text-white/30 text-xs flex-shrink-0">{{ timeAgo }}</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Comment Content -->
|
<!-- Actions Row -->
|
||||||
<p class="text-white/70 text-sm leading-relaxed whitespace-pre-wrap">{{ node.event.content }}</p>
|
<div class="flex items-center gap-2 mt-2.5 pl-[38px]">
|
||||||
|
<!-- Upvote -->
|
||||||
|
<button
|
||||||
|
v-if="isLoggedIn"
|
||||||
|
@click="handleReact(true)"
|
||||||
|
:disabled="hasVoted"
|
||||||
|
class="bubble-action"
|
||||||
|
:class="{ 'bubble-action-active': userVote === '+' }"
|
||||||
|
:style="{ opacity: userVote === '+' ? 1 : hasVoted ? 0.35 : 1 }"
|
||||||
|
>
|
||||||
|
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 15l7-7 7 7" />
|
||||||
|
</svg>
|
||||||
|
<span v-if="reactionCounts.positive > 0">{{ reactionCounts.positive }}</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
<!-- Comment Actions: Reactions + Reply -->
|
<!-- Downvote -->
|
||||||
<div class="flex items-center gap-3 mt-2">
|
<button
|
||||||
<!-- Upvote -->
|
v-if="isLoggedIn"
|
||||||
<button
|
@click="handleReact(false)"
|
||||||
v-if="isLoggedIn"
|
:disabled="hasVoted"
|
||||||
@click="handleReact(true)"
|
class="bubble-action"
|
||||||
:disabled="hasVoted"
|
:class="{ 'bubble-action-active': userVote === '-' }"
|
||||||
class="comment-action-btn"
|
:style="{ opacity: userVote === '-' ? 1 : hasVoted ? 0.35 : 1 }"
|
||||||
:class="{ 'comment-action-active': userVote === '+' }"
|
>
|
||||||
:style="{ opacity: userVote === '+' ? 1 : hasVoted ? 0.4 : 1 }"
|
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
>
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
||||||
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
</svg>
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 15l7-7 7 7" />
|
<span v-if="reactionCounts.negative > 0">{{ reactionCounts.negative }}</span>
|
||||||
</svg>
|
</button>
|
||||||
<span v-if="reactionCounts.positive > 0">{{ reactionCounts.positive }}</span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<!-- Downvote -->
|
<!-- Reply -->
|
||||||
<button
|
<button
|
||||||
v-if="isLoggedIn"
|
v-if="isLoggedIn"
|
||||||
@click="handleReact(false)"
|
@click="showReplyForm = !showReplyForm"
|
||||||
:disabled="hasVoted"
|
class="bubble-action"
|
||||||
class="comment-action-btn"
|
:class="{ 'bubble-action-active': showReplyForm }"
|
||||||
:class="{ 'comment-action-active': userVote === '-' }"
|
>
|
||||||
:style="{ opacity: userVote === '-' ? 1 : hasVoted ? 0.4 : 1 }"
|
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
>
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6" />
|
||||||
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
</svg>
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
<span>Reply</span>
|
||||||
</svg>
|
</button>
|
||||||
<span v-if="reactionCounts.negative > 0">{{ reactionCounts.negative }}</span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<!-- Reply -->
|
<!-- Expand/Collapse Replies -->
|
||||||
<button
|
<button
|
||||||
v-if="isLoggedIn"
|
v-if="node.replies.length > 0"
|
||||||
@click="showReplyForm = !showReplyForm"
|
@click="showReplies = !showReplies"
|
||||||
class="comment-action-btn"
|
class="bubble-action ml-auto"
|
||||||
>
|
>
|
||||||
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
<svg class="w-3.5 h-3.5 transition-transform duration-200" :class="{ 'rotate-180': showReplies }" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6" />
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
||||||
</svg>
|
</svg>
|
||||||
<span>Reply</span>
|
<span>{{ showReplies ? 'Hide' : node.replies.length }} {{ node.replies.length === 1 ? 'reply' : 'replies' }}</span>
|
||||||
</button>
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Expand/Collapse Replies -->
|
<!-- Inline Reply Form -->
|
||||||
<button
|
<div v-if="showReplyForm" class="mt-3 pl-[38px]">
|
||||||
v-if="node.replies.length > 0"
|
<div class="flex gap-2.5">
|
||||||
@click="showReplies = !showReplies"
|
<img
|
||||||
class="comment-action-btn"
|
:src="currentUserAvatar"
|
||||||
>
|
class="w-6 h-6 rounded-full flex-shrink-0 object-cover ring-1 ring-white/10"
|
||||||
<svg class="w-3.5 h-3.5 transition-transform" :class="{ 'rotate-180': showReplies }" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
alt="You"
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
/>
|
||||||
</svg>
|
<div class="flex-1">
|
||||||
<span>{{ showReplies ? 'Hide' : `${node.replies.length}` }} {{ node.replies.length === 1 ? 'reply' : 'replies' }}</span>
|
<textarea
|
||||||
</button>
|
v-model="replyText"
|
||||||
</div>
|
placeholder="Write a reply..."
|
||||||
|
class="reply-textarea"
|
||||||
<!-- Reply Form -->
|
rows="2"
|
||||||
<div v-if="showReplyForm" class="mt-3">
|
@keydown.meta.enter="submitReply"
|
||||||
<div class="flex gap-2">
|
@keydown.ctrl.enter="submitReply"
|
||||||
<img
|
></textarea>
|
||||||
:src="currentUserAvatar"
|
<div class="flex items-center gap-2 justify-end mt-1.5">
|
||||||
class="w-6 h-6 rounded-full flex-shrink-0 object-cover"
|
<button @click="showReplyForm = false" class="cancel-btn">Cancel</button>
|
||||||
alt="You"
|
<button
|
||||||
/>
|
@click="submitReply"
|
||||||
<div class="flex-1">
|
:disabled="!replyText.trim() || isPostingReply"
|
||||||
<textarea
|
class="post-btn"
|
||||||
v-model="replyText"
|
:class="{ 'opacity-40 cursor-not-allowed': !replyText.trim() || isPostingReply }"
|
||||||
placeholder="Write a reply..."
|
>
|
||||||
class="comment-textarea text-sm"
|
{{ isPostingReply ? '...' : 'Reply' }}
|
||||||
rows="2"
|
</button>
|
||||||
@keydown.meta.enter="submitReply"
|
|
||||||
@keydown.ctrl.enter="submitReply"
|
|
||||||
></textarea>
|
|
||||||
<div class="flex items-center gap-2 justify-end mt-1.5">
|
|
||||||
<button @click="showReplyForm = false" class="cancel-btn">Cancel</button>
|
|
||||||
<button
|
|
||||||
@click="submitReply"
|
|
||||||
:disabled="!replyText.trim() || isPostingReply"
|
|
||||||
class="submit-comment-btn text-xs"
|
|
||||||
:class="{ 'opacity-40 cursor-not-allowed': !replyText.trim() || isPostingReply }"
|
|
||||||
>
|
|
||||||
{{ isPostingReply ? '...' : 'Reply' }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Nested Replies -->
|
<!-- Nested Replies (with connecting line) -->
|
||||||
<template v-if="showReplies && node.replies.length > 0">
|
<div v-if="showReplies && node.replies.length > 0" class="replies-container">
|
||||||
<CommentNode
|
<CommentNode
|
||||||
v-for="reply in node.replies"
|
v-for="reply in node.replies"
|
||||||
:key="reply.event.id"
|
:key="reply.event.id"
|
||||||
@@ -123,7 +119,7 @@
|
|||||||
:current-user-avatar="currentUserAvatar"
|
:current-user-avatar="currentUserAvatar"
|
||||||
@get-profile="(pubkey: string) => $emit('getProfile', pubkey)"
|
@get-profile="(pubkey: string) => $emit('getProfile', pubkey)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -162,6 +158,12 @@ const authorAvatar = computed(() => {
|
|||||||
return `https://robohash.org/${props.node.event.pubkey}.png`
|
return `https://robohash.org/${props.node.event.pubkey}.png`
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Dynamic bubble class based on nesting depth
|
||||||
|
const bubbleClass = computed(() => {
|
||||||
|
if (props.depth === 0) return 'bubble-root'
|
||||||
|
return 'bubble-reply'
|
||||||
|
})
|
||||||
|
|
||||||
// Time formatting
|
// Time formatting
|
||||||
const timeAgo = computed(() => {
|
const timeAgo = computed(() => {
|
||||||
const now = Math.floor(Date.now() / 1000)
|
const now = Math.floor(Date.now() / 1000)
|
||||||
@@ -216,73 +218,121 @@ async function submitReply() {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.comment-item {
|
/* ── Thread Layout ──────────────────────────────────── */
|
||||||
padding: 10px 0;
|
.comment-thread {
|
||||||
border-bottom: 1px solid rgba(255, 255, 255, 0.04);
|
margin-bottom: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment-item:last-child {
|
.reply-thread {
|
||||||
border-bottom: none;
|
margin-bottom: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment-reply {
|
/* Replies container with connecting left border */
|
||||||
border-left: 2px solid rgba(255, 255, 255, 0.08);
|
.replies-container {
|
||||||
padding-left: 12px;
|
position: relative;
|
||||||
margin-top: 4px;
|
margin-left: 20px;
|
||||||
|
padding-left: 16px;
|
||||||
|
border-left: 2px solid rgba(255, 255, 255, 0.06);
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment-action-btn {
|
@media (min-width: 768px) {
|
||||||
display: flex;
|
.replies-container {
|
||||||
|
margin-left: 24px;
|
||||||
|
padding-left: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Bubble Base ────────────────────────────────────── */
|
||||||
|
.comment-bubble {
|
||||||
|
padding: 14px 16px;
|
||||||
|
border-radius: 16px;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Top-level comment bubble — prominent glass card */
|
||||||
|
.bubble-root {
|
||||||
|
background: rgba(255, 255, 255, 0.04);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.06);
|
||||||
|
backdrop-filter: blur(8px);
|
||||||
|
-webkit-backdrop-filter: blur(8px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.bubble-root:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.06);
|
||||||
|
border-color: rgba(255, 255, 255, 0.09);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Reply bubble — subtler, more compact */
|
||||||
|
.bubble-reply {
|
||||||
|
background: rgba(255, 255, 255, 0.025);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.04);
|
||||||
|
border-radius: 14px;
|
||||||
|
padding: 12px 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bubble-reply:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.045);
|
||||||
|
border-color: rgba(255, 255, 255, 0.07);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Action Buttons ─────────────────────────────────── */
|
||||||
|
.bubble-action {
|
||||||
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
padding: 3px 8px;
|
padding: 4px 10px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: rgba(255, 255, 255, 0.45);
|
color: rgba(255, 255, 255, 0.4);
|
||||||
background: transparent;
|
background: rgba(255, 255, 255, 0.03);
|
||||||
border: none;
|
border: 1px solid transparent;
|
||||||
border-radius: 6px;
|
border-radius: 8px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: all 0.2s ease;
|
transition: all 0.2s ease;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment-action-btn:hover:not(:disabled) {
|
.bubble-action:hover:not(:disabled) {
|
||||||
color: rgba(255, 255, 255, 0.8);
|
color: rgba(255, 255, 255, 0.8);
|
||||||
background: rgba(255, 255, 255, 0.06);
|
background: rgba(255, 255, 255, 0.08);
|
||||||
|
border-color: rgba(255, 255, 255, 0.08);
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment-action-btn:disabled {
|
.bubble-action:disabled {
|
||||||
cursor: default;
|
cursor: default;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment-action-active {
|
.bubble-action-active {
|
||||||
color: rgba(255, 255, 255, 0.9);
|
color: rgba(255, 255, 255, 0.9);
|
||||||
|
background: rgba(255, 255, 255, 0.1);
|
||||||
|
border-color: rgba(255, 255, 255, 0.12);
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment-textarea {
|
/* ── Reply Form ─────────────────────────────────────── */
|
||||||
|
.reply-textarea {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background: rgba(255, 255, 255, 0.05);
|
background: rgba(255, 255, 255, 0.04);
|
||||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||||
border-radius: 10px;
|
border-radius: 12px;
|
||||||
padding: 10px 12px;
|
padding: 10px 12px;
|
||||||
color: white;
|
color: white;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
resize: none;
|
resize: none;
|
||||||
outline: none;
|
outline: none;
|
||||||
transition: border-color 0.2s ease;
|
transition: border-color 0.2s ease, background 0.2s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment-textarea::placeholder {
|
.reply-textarea::placeholder {
|
||||||
color: rgba(255, 255, 255, 0.25);
|
color: rgba(255, 255, 255, 0.25);
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment-textarea:focus {
|
.reply-textarea:focus {
|
||||||
border-color: rgba(255, 255, 255, 0.25);
|
border-color: rgba(255, 255, 255, 0.2);
|
||||||
|
background: rgba(255, 255, 255, 0.06);
|
||||||
}
|
}
|
||||||
|
|
||||||
.submit-comment-btn {
|
.post-btn {
|
||||||
padding: 5px 14px;
|
padding: 5px 16px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
@@ -293,7 +343,7 @@ async function submitReply() {
|
|||||||
transition: all 0.2s ease;
|
transition: all 0.2s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
.submit-comment-btn:hover:not(:disabled) {
|
.post-btn:hover:not(:disabled) {
|
||||||
background: rgba(255, 255, 255, 0.95);
|
background: rgba(255, 255, 255, 0.95);
|
||||||
transform: translateY(-1px);
|
transform: translateY(-1px);
|
||||||
}
|
}
|
||||||
@@ -304,14 +354,14 @@ async function submitReply() {
|
|||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
color: rgba(255, 255, 255, 0.5);
|
color: rgba(255, 255, 255, 0.45);
|
||||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: all 0.2s ease;
|
transition: all 0.2s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cancel-btn:hover {
|
.cancel-btn:hover {
|
||||||
color: rgba(255, 255, 255, 0.8);
|
color: rgba(255, 255, 255, 0.75);
|
||||||
border-color: rgba(255, 255, 255, 0.2);
|
border-color: rgba(255, 255, 255, 0.15);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -177,8 +177,8 @@
|
|||||||
<div class="text-white/40 text-sm">No comments yet. Be the first!</div>
|
<div class="text-white/40 text-sm">No comments yet. Be the first!</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Threaded comments -->
|
<!-- Threaded comments (bubble layout) -->
|
||||||
<div v-else class="space-y-1">
|
<div v-else class="space-y-2">
|
||||||
<template v-for="node in commentTree" :key="node.event.id">
|
<template v-for="node in commentTree" :key="node.event.id">
|
||||||
<CommentNode
|
<CommentNode
|
||||||
:node="node"
|
:node="node"
|
||||||
|
|||||||
Reference in New Issue
Block a user