Fix comments UX regressions and HTMX/Turnstile behavior
- standardize comment and reply UI layout - target replies with stable OOB container IDs - remove stale empty-state on approved HTMX comments - initialize Turnstile widgets after HTMX swaps - add regression tests for empty-state, OOB targets, and reply form rerender Refs #48
This commit is contained in:
@@ -1,40 +1,36 @@
|
||||
<div class="group">
|
||||
<!-- Top-level Comment -->
|
||||
<article id="comment-{{ comment.id }}" class="relative bg-brand-surfaceLight dark:bg-brand-surfaceDark border border-zinc-200 dark:border-zinc-800 p-6 sm:p-8 hover:border-brand-pink/30 transition-colors">
|
||||
<div class="flex items-start gap-4 mb-4">
|
||||
<div class="w-10 h-10 bg-gradient-to-tr from-brand-cyan to-brand-pink shrink-0 rounded-sm shadow-solid-dark/10 dark:shadow-solid-light/5"></div>
|
||||
<div class="flex-1 min-w-0">
|
||||
<div class="flex flex-wrap items-baseline gap-x-3 gap-y-1">
|
||||
<span class="font-display font-bold text-base text-zinc-900 dark:text-zinc-100">{{ comment.author_name }}</span>
|
||||
<time datetime="{{ comment.created_at|date:'c' }}" class="font-mono text-xs text-zinc-500 uppercase tracking-wider">{{ comment.created_at|date:"M j, Y" }}</time>
|
||||
</div>
|
||||
<div class="mt-3 prose prose-sm dark:prose-invert max-w-none text-zinc-700 dark:text-zinc-300 leading-relaxed">
|
||||
{{ comment.body|linebreaks }}
|
||||
</div>
|
||||
</div>
|
||||
<article
|
||||
id="comment-{{ comment.id }}"
|
||||
data-comment-item="true"
|
||||
class="rounded-lg border border-zinc-200 bg-brand-surfaceLight p-5 shadow-sm transition-colors hover:border-zinc-300 dark:border-zinc-800 dark:bg-brand-surfaceDark dark:hover:border-zinc-700 sm:p-6"
|
||||
>
|
||||
<header class="mb-3 flex flex-wrap items-center gap-x-3 gap-y-1">
|
||||
<span class="font-display text-base font-bold text-zinc-900 dark:text-zinc-100">{{ comment.author_name }}</span>
|
||||
<time datetime="{{ comment.created_at|date:'c' }}" class="font-mono text-[11px] uppercase tracking-wider text-zinc-500">
|
||||
{{ comment.created_at|date:"M j, Y" }}
|
||||
</time>
|
||||
</header>
|
||||
|
||||
<div class="prose prose-sm mt-2 max-w-none leading-relaxed text-zinc-700 dark:prose-invert dark:text-zinc-300">
|
||||
{{ comment.body|linebreaks }}
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between mt-6">
|
||||
<div class="mt-5 flex items-center justify-between gap-4 border-t border-zinc-100 pt-4 dark:border-zinc-800">
|
||||
{% include "comments/_reactions.html" with comment=comment counts=comment.reaction_counts user_reacted=comment.user_reacted %}
|
||||
|
||||
<details class="group/details">
|
||||
<summary class="list-none cursor-pointer flex items-center gap-2 font-mono text-xs font-bold uppercase tracking-widest text-zinc-500 hover:text-brand-pink transition-colors [&::-webkit-details-marker]:hidden">
|
||||
<svg class="w-4 h-4 transition-transform group-open/details:-translate-y-0.5 group-open/details:translate-x-0.5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6" />
|
||||
</svg>
|
||||
<span class="group-open/details:hidden">Reply</span>
|
||||
<span class="hidden group-open/details:inline text-brand-pink">Cancel Reply</span>
|
||||
</summary>
|
||||
|
||||
<div class="mt-8 pt-8 border-t border-zinc-100 dark:border-zinc-800 animate-in fade-in slide-in-from-top-2 duration-300">
|
||||
<details class="group/details">
|
||||
<summary class="list-none cursor-pointer font-mono text-xs font-bold uppercase tracking-wider text-zinc-500 transition-colors hover:text-brand-cyan [&::-webkit-details-marker]:hidden">
|
||||
<span class="group-open/details:hidden">Reply</span>
|
||||
<span class="hidden group-open/details:inline">Cancel reply</span>
|
||||
</summary>
|
||||
<div class="mt-4 rounded-md border border-zinc-200 bg-white p-4 dark:border-zinc-700 dark:bg-zinc-950">
|
||||
{% include "comments/_reply_form.html" with page=page comment=comment %}
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<!-- Nested Replies -->
|
||||
<div class="replies-container relative ml-6 sm:ml-12 mt-4 space-y-4 pl-6 sm:pl-8 border-l-2 border-zinc-100 dark:border-zinc-800">
|
||||
<div id="replies-for-{{ comment.id }}" class="replies-container mt-3 space-y-3 border-l-2 border-zinc-100 pl-4 sm:ml-8 sm:pl-6 dark:border-zinc-800">
|
||||
{% for reply in comment.replies.all %}
|
||||
{% include "comments/_reply.html" with reply=reply %}
|
||||
{% endfor %}
|
||||
|
||||
Reference in New Issue
Block a user