Forum design: own reaction marks, compact posts, avatars for the light theme

As on the approved canvas: reactions are the forum's own line marks
(heart, lotus, two circles, star) with a count, the viewer's own filled;
the big 2x2 boxes under the opening post are gone and the names live in
the + menu and tooltips. A post's head is one line (avatar, name, rank,
Sun/Moon/Ascendant as glyphs, time), on wide screens the text lines up
under the name instead of the tall author column. "Válasz" is a small
button; edit, delete, report and moderation sit in a ⋯ menu. The
listening wish is a thin line under the title. In the light theme the
avatars get a pale tint and a darker glyph (the night circle read as a
black blot).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-26 12:20:17 +00:00
co-authored by Claude Opus 5.5
parent 7c3c9e5565
commit 0a2308c491
6 changed files with 436 additions and 287 deletions
@@ -4,14 +4,15 @@ import Link from "next/link";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { api, errorText } from "@/lib/api";
import { type ForumPost, INTENTS, REACTIONS, type ReactionKind, type ThreadPage, memberHref } from "@/lib/forum";
import { type ForumPost, INTENTS, REACTIONS, type ReactionKind, type ThreadPage, ago, memberHref } from "@/lib/forum";
import { AuthorLine, signsText } from "./AuthorLine";
import { signGlyphs } from "./AuthorLine";
import { Avatar } from "./Avatar";
import { Composer } from "./Composer";
import { PostBody } from "./PostBody";
import type { LiveNotice } from "./ForumNav";
import { ReportButton } from "./ReportButton";
import { ReactionIcon } from "./ReactionIcon";
import { ReportForm } from "./ReportButton";
import { TypingLine, useTypingSender, useTypingWatch } from "./typing";
/** How often the open thread looks for new replies (while the page is in front). */
@@ -27,27 +28,6 @@ type Actions = {
helped: (post: ForumPost) => void;
};
function ReactionGrid({ post, enabled, onReact }: { post: ForumPost; enabled: boolean; onReact: Actions["react"] }) {
return (
<div className="fr-grid" role="group" aria-label="Reakciók">
{REACTIONS.map((r) => (
<button
key={r.kind}
type="button"
className="fr-big"
aria-pressed={post.mine === r.kind}
disabled={!enabled}
onClick={() => onReact(post, r.kind)}
>
<span aria-hidden="true">{r.emoji}</span>
<span className="fr-big-label">{r.label}</span>
<span className="fr-count">{post.reactions[r.kind]}</span>
</button>
))}
</div>
);
}
function ReactionRow({
post,
enabled,
@@ -69,43 +49,50 @@ function ReactionRow({
type="button"
className="fr-chip"
aria-pressed={post.mine === r.kind}
aria-label={`${r.label}, ${post.reactions[r.kind]}`}
aria-label={`${r.label}, ${post.reactions[r.kind]}${post.mine === r.kind ? ", a tiéd" : ""}`}
title={r.label}
disabled={!enabled}
onClick={() => onReact(post, r.kind)}
>
{r.emoji} {post.reactions[r.kind]}
<ReactionIcon kind={r.kind} filled={post.mine === r.kind} />
{post.reactions[r.kind]}
</button>
))}
{enabled && (
<span className="fr-more">
<button
type="button"
className="fr-chip fr-add"
aria-label="Reakció hozzáadása"
aria-expanded={open}
onClick={() => setOpen((o) => !o)}
>
+
</button>
{open && (
<span className="fr-pop" role="menu">
{REACTIONS.map((r) => (
<button
key={r.kind}
type="button"
role="menuitem"
className="fr-pop-item"
onClick={() => {
setOpen(false);
onReact(post, r.kind);
}}
>
<span aria-hidden="true">{r.emoji}</span> {r.label}
</button>
))}
</span>
)}
</span>
<Popover
open={open}
onClose={() => setOpen(false)}
button={
<button
type="button"
className="fr-chip fr-add"
aria-label="Reakció hozzáadása"
aria-expanded={open}
onClick={() => setOpen((o) => !o)}
>
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M12 6v12M6 12h12" />
</svg>
</button>
}
>
{REACTIONS.map((r) => (
<button
key={r.kind}
type="button"
role="menuitem"
className="fpop-item"
aria-pressed={post.mine === r.kind}
onClick={() => {
setOpen(false);
onReact(post, r.kind);
}}
>
<ReactionIcon kind={r.kind} size={18} filled={post.mine === r.kind} />
{r.label}
</button>
))}
</Popover>
)}
{canDownvote && enabled && (
<button
@@ -116,44 +103,54 @@ function ReactionRow({
title="Nem visz előre"
onClick={() => onReact(post, "down")}
>
⌄
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M7 10l5 5 5-5" />
</svg>
</button>
)}
</div>
);
}
/** The author column of wide screens: avatar, nickname, rank, badges, signs one per line. */
function AuthorPanel({ author, starter }: { author: ForumPost["author"]; starter: boolean }) {
if (!author) {
return (
<aside className="fp-author">
<Avatar avatar={null} size={56} />
<span className="fp-author-name muted">Törölt tag</span>
</aside>
);
}
const signs = signsText(author.signs);
/** A small menu under a button (closes on a click elsewhere or Escape). */
function Popover({
open,
onClose,
button,
children,
align = "left",
}: {
open: boolean;
onClose: () => void;
button: React.ReactNode;
children: React.ReactNode;
align?: "left" | "right";
}) {
const box = useRef<HTMLSpanElement>(null);
useEffect(() => {
if (!open) return;
const outside = (e: MouseEvent) => {
if (box.current && !box.current.contains(e.target as Node)) onClose();
};
const escape = (e: KeyboardEvent) => {
if (e.key === "Escape") onClose();
};
document.addEventListener("mousedown", outside);
document.addEventListener("keydown", escape);
return () => {
document.removeEventListener("mousedown", outside);
document.removeEventListener("keydown", escape);
};
}, [open, onClose]);
return (
<aside className="fp-author">
<Link href={memberHref(author.nickname)} tabIndex={-1} aria-hidden="true">
<Avatar avatar={author.avatar} size={56} online={author.online} />
</Link>
<Link href={memberHref(author.nickname)} className="fp-author-name">
{author.nickname}
</Link>
{author.online && <span className="sr-only">(online)</span>}
<span className="fa-rank">{author.rank_name}</span>
{author.moderator && <span className="fa-badge fa-badge-mod">Moderátor</span>}
{starter && <span className="fa-badge fa-badge-starter">Szálindító</span>}
{signs && (
<span className="fp-author-signs sym">
{signs.split(" · ").map((line) => (
<span key={line}>{line}</span>
))}
<span className="fpop-wrap" ref={box}>
{button}
{open && (
<span className={align === "right" ? "fpop fpop-right" : "fpop"} role="menu">
{children}
</span>
)}
</aside>
</span>
);
}
@@ -162,18 +159,25 @@ function PostCard({
page,
actions,
isNew,
nested = false,
}: {
post: ForumPost;
page: ThreadPage;
actions: Actions;
isNew: boolean;
nested?: boolean;
}) {
const [editing, setEditing] = useState(false);
const [reporting, setReporting] = useState(false);
const [menu, setMenu] = useState(false);
const [showCollapsed, setShowCollapsed] = useState(false);
const { viewer, thread, access } = page;
const writer = viewer.member !== null && !viewer.member.banned;
const starter = post.author !== null && post.author.nickname === thread.author?.nickname;
const canReact = writer && !post.own && !post.deleted && !thread.locked;
const author = post.author;
const glyphs = signGlyphs(author?.signs);
const size = post.is_opening ? 40 : nested ? 26 : 32;
if (post.deleted && !viewer.moderator) {
return (
@@ -188,38 +192,63 @@ function PostCard({
);
}
const menuItems: { label: string; run: () => void; danger?: boolean }[] = [];
if (!post.deleted) {
if (access?.is_thread_author && !post.is_opening && !post.own && writer) {
menuItems.push({ label: post.helped ? "Mégsem segített" : "Ez segített", run: () => actions.helped(post) });
}
if (post.own && writer && !thread.locked) menuItems.push({ label: "Szerkesztés", run: () => setEditing(true) });
if (post.own) menuItems.push({ label: "Törlés", run: () => actions.remove(post), danger: true });
if (viewer.logged_in && !post.own) menuItems.push({ label: "Jelentés", run: () => setReporting(true) });
if (viewer.moderator && !post.own)
menuItems.push({ label: "Eltávolítás", run: () => actions.remove(post), danger: true });
} else if (viewer.moderator) {
menuItems.push({ label: "Visszaállítás (admin)", run: () => actions.restore(post) });
}
const classes = ["fp", post.is_opening && "fp-opening", nested && "fp-nested"].filter(Boolean).join(" ");
return (
<article className={post.is_opening ? "fp fp-opening" : "fp"} id={`h${post.id}`}>
{/* Wide screens: the old forums' author column. */}
<AuthorPanel author={post.author} starter={starter && !post.is_opening} />
<div className="fp-content">
<div className="fp-head">
<AuthorLine
author={post.author}
size={post.is_opening ? 44 : 36}
time={post.created_at}
edited={post.edited_at !== null}
badges={
<>
{starter && !post.is_opening && <span className="fa-badge fa-badge-starter">Szálindító</span>}
{isNew && <span className="fa-badge fa-badge-new">új</span>}
</>
}
/>
</div>
<p className="fp-when">
<time suppressHydrationWarning dateTime={post.created_at}>
{new Date(post.created_at).toLocaleString("hu-HU", {
timeZone: "Europe/Budapest",
month: "long",
day: "numeric",
hour: "2-digit",
minute: "2-digit",
})}
</time>
{post.edited_at && " · szerkesztve"}
<article className={classes} id={`h${post.id}`}>
<span className="fp-av">
{author ? (
<Link href={memberHref(author.nickname)} tabIndex={-1} aria-hidden="true">
<Avatar avatar={author.avatar} size={size} online={author.online} />
</Link>
) : (
<Avatar avatar={null} size={size} />
)}
</span>
<div className="fp-head">
<span className="fp-names">
{author ? (
<Link href={memberHref(author.nickname)} className="fa-name">
{author.nickname}
</Link>
) : (
<span className="fa-name muted">Törölt tag</span>
)}
{author?.online && <span className="sr-only">(online)</span>}
{author && <span className="fa-rank">{author.rank_name}</span>}
{author?.moderator && <span className="fa-badge fa-badge-mod">Moderátor</span>}
{starter && !post.is_opening && <span className="fa-badge fa-badge-starter">Szálindító</span>}
{isNew && <span className="fa-badge fa-badge-new">új</span>}
</p>
{glyphs && !nested && (
<span className="fp-signs sym" title={glyphs.title}>
{glyphs.text}
</span>
)}
</span>
<time
className="fp-time"
suppressHydrationWarning
dateTime={post.created_at}
title={new Date(post.created_at).toLocaleString("hu-HU", { timeZone: "Europe/Budapest" })}
>
{ago(post.created_at)}
{post.edited_at && " · szerkesztve"}
</time>
</div>
<div className="fp-content">
{post.deleted && (
<p className="fp-mod-note">
Eltávolítva{post.deleted.reason ? ` (ok: ${post.deleted.reason})` : " a szerző által"}. Csak a moderátorok
@@ -248,75 +277,84 @@ function PostCard({
) : (
post.body !== null && <PostBody text={post.body} />
)}
{post.helped && (
<p className="fp-helped">
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M5 12.5l4.5 4.5L19 7.5" />
</svg>
{thread.author?.nickname ?? "A szál indítója"} szerint ez segített
</p>
)}
{!post.deleted && !editing && (
<>
{post.is_opening ? (
<ReactionGrid post={post} enabled={canReact} onReact={actions.react} />
) : (
<div className="fp-actions">
<ReactionRow
post={post}
enabled={canReact}
canDownvote={access?.can_downvote ?? false}
onReact={actions.react}
/>
<span className="fp-spacer" />
{access?.can_reply && writer && (
<button type="button" className="fp-link" onClick={() => actions.replyTo(post)}>
Válasz
</button>
)}
</div>
)}
<div className="fp-tools">
{access?.is_thread_author && !post.is_opening && !post.own && writer && (
</div>
{!editing && (!post.deleted || menuItems.length > 0) && (
<div className="fp-actions">
{post.helped && (
<span className="fp-helped" title={`${thread.author?.nickname ?? "A szál indítója"} szerint ez segített`}>
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M5 12.5l4.5 4.5L19 7.5" />
</svg>
Segített
</span>
)}
{!post.deleted && (
<ReactionRow
post={post}
enabled={canReact}
canDownvote={access?.can_downvote ?? false}
onReact={actions.react}
/>
)}
<span className="fp-spacer" />
{viewer.moderator && typeof post.down === "number" && post.down > 0 && (
<span className="hint" title="Nem visz előre jelzések (csak moderátoroknak)">
⌄ {post.down}
</span>
)}
{!post.deleted && access?.can_reply && writer && !post.is_opening && (
<button type="button" className="fp-reply" onClick={() => actions.replyTo(post)}>
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M9 14L4 9l5-5" />
<path d="M4 9h10a6 6 0 0 1 6 6v4" />
</svg>
Válasz
</button>
)}
{menuItems.length > 0 && (
<Popover
open={menu}
onClose={() => setMenu(false)}
align="right"
button={
<button
type="button"
className="fp-tool"
onClick={() => actions.helped(post)}
aria-pressed={post.helped}
className="fp-more"
aria-label="Továbbiak"
aria-expanded={menu}
onClick={() => setMenu((m) => !m)}
>
{post.helped ? "Segített ✓" : "Ez segített"}
<svg viewBox="0 0 24 24" aria-hidden="true">
<circle cx="5.5" cy="12" r="1.6" />
<circle cx="12" cy="12" r="1.6" />
<circle cx="18.5" cy="12" r="1.6" />
</svg>
</button>
)}
{post.own && writer && !thread.locked && (
<button type="button" className="fp-tool" onClick={() => setEditing(true)}>
Szerkesztés
}
>
{menuItems.map((item) => (
<button
key={item.label}
type="button"
role="menuitem"
className={item.danger ? "fpop-item fpop-danger" : "fpop-item"}
onClick={() => {
setMenu(false);
item.run();
}}
>
{item.label}
</button>
)}
{post.own && (
<button type="button" className="fp-tool" onClick={() => actions.remove(post)}>
Törlés
</button>
)}
{viewer.logged_in && !post.own && <ReportButton path={`/forum/posts/${post.id}/report`} />}
{viewer.moderator && !post.own && (
<button type="button" className="fp-tool fp-tool-mod" onClick={() => actions.remove(post)}>
Eltávolítás
</button>
)}
{viewer.moderator && typeof post.down === "number" && post.down > 0 && (
<span className="hint">⌄ {post.down}</span>
)}
</div>
</>
)}
{post.deleted && viewer.moderator && (
<div className="fp-tools">
<button type="button" className="fp-tool" onClick={() => actions.restore(post)}>
Visszaállítás (admin)
</button>
</div>
)}
</div>
))}
</Popover>
)}
</div>
)}
{reporting && (
<div className="fp-report">
<ReportForm path={`/forum/posts/${post.id}/report`} onClose={() => setReporting(false)} />
</div>
)}
</article>
);
}
@@ -524,24 +562,19 @@ export function ThreadView({ initial }: { initial: ThreadPage }) {
</div>
) : null}
{intent && thread.intent === "listen" && (
<div className="ftv-intent">
<strong>{intent.label}</strong>
<span>{starter} most nem kér tanácsot. Elég, ha jelen vagy, és leírod, ha veled is történt hasonló.</span>
</div>
)}
{intent && thread.intent === "advice" && (
<div className="ftv-intent ftv-intent-advice">
<strong>{intent.label}</strong>
<span>{starter} kíváncsi a véleményetekre és a tapasztalataitokra.</span>
</div>
)}
<h1 className="ftv-title">
{thread.pinned && <span className="ft-pin">Kitűzve</span>}
{thread.locked && <span className="ft-pin">Lezárva</span>}
{thread.title}
</h1>
{intent && (
<p className="ftv-intent-line">
<span className={`ft-intent ft-intent-${thread.intent}`}>{intent.label}</span>
{thread.intent === "listen"
? "tanács helyett elég, ha jelen vagy, és leírod, ha veled is történt hasonló"
: `${starter} kíváncsi a véleményetekre és a tapasztalataitokra`}
</p>
)}
{opening && <PostCard post={opening} page={page} actions={actions} isNew={false} />}
@@ -570,6 +603,7 @@ export function ThreadView({ initial }: { initial: ThreadPage }) {
{childrenOf(top.id).map((child) => (
<PostCard
key={child.id}
nested
post={child}
page={page}
actions={actions}