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
+105 -67
View File
@@ -20,6 +20,10 @@
--f-orange-tint: rgba(240, 163, 94, 0.12);
--f-red-tint: rgba(242, 160, 160, 0.08);
--f-green-tint: rgba(159, 216, 176, 0.12);
--r-with_you: #e58aa6;
--r-thanks: #d9b46a;
--r-me_too: #7fb0e0;
--r-insight: #c3a6f0;
color: var(--ink);
}
.forum[data-theme="light"] {
@@ -49,6 +53,10 @@
--f-orange-tint: rgba(156, 82, 14, 0.09);
--f-red-tint: rgba(176, 58, 58, 0.07);
--f-green-tint: rgba(45, 122, 76, 0.1);
--r-with_you: #b4466a;
--r-thanks: #8a6a24;
--r-me_too: #2c66a0;
--r-insight: #6b4fa0;
color-scheme: light;
}
/* The light forum takes the whole page between the (dark) header and footer
@@ -117,11 +125,23 @@ body:has(.forum[data-theme="light"]) .site-footer { background: #0d1220; }
}
/* --- avatars and the author line --- */
.av { position: relative; display: inline-flex; flex: none; }
.av { position: relative; display: inline-flex; flex: none; --av-bg: #1c2540; --av-ink: #d9b46a; }
.av svg { display: block; }
/* The night-coloured avatars keep the bright gold in both themes. */
.av-glyph { fill: none; stroke: #d9b46a; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.av-glyph .av-fill { fill: #d9b46a; stroke: none; }
.av-lila { --av-bg: #2a2342; }
.av-tenger { --av-bg: #1d3038; }
.av-borostyan { --av-bg: #33291c; }
.av-rozsa { --av-bg: #3a2230; }
.av-erdo { --av-bg: #1f3326; }
/* Light theme: a pale tint and a darker glyph (a night circle read as a black blot). */
.forum[data-theme="light"] .av-ejkek { --av-bg: #e4e8f3; --av-ink: #2f3d6b; }
.forum[data-theme="light"] .av-lila { --av-bg: #ece6f5; --av-ink: #5b4691; }
.forum[data-theme="light"] .av-tenger { --av-bg: #e0eff0; --av-ink: #2a6670; }
.forum[data-theme="light"] .av-borostyan { --av-bg: #f5ead7; --av-ink: #8a6a24; }
.forum[data-theme="light"] .av-rozsa { --av-bg: #f6e3ea; --av-ink: #9b3f5f; }
.forum[data-theme="light"] .av-erdo { --av-bg: #e2efe4; --av-ink: #3d6b47; }
.av-bg { fill: var(--av-bg); }
.av-glyph { fill: none; stroke: var(--av-ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.av-glyph .av-fill { fill: var(--av-ink); stroke: none; }
.av-online {
position: absolute; right: -1px; bottom: -1px; width: 28%; height: 28%; min-width: 9px; min-height: 9px;
border-radius: 50%; background: var(--f-online); border: 2px solid var(--panel); box-sizing: border-box;
@@ -277,6 +297,8 @@ body:has(.forum[data-theme="light"]) .site-footer { background: #0d1220; }
.ftv-intent-advice { background: var(--f-orange-tint); }
.ftv-intent-advice strong { color: var(--square); }
.ftv-title { font-size: 30px; line-height: 1.12; }
.ftv-intent-line { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin-top: -4px; font-size: 14px; color: var(--muted); }
.ftv-intent-line .ft-intent { align-self: center; padding: 1px 10px; font-weight: 600; }
.ftv-count { display: flex; justify-content: space-between; align-items: baseline; padding-top: 6px; }
.ftv .ftv-count h2 { font-family: var(--font-body); font-size: 15px; color: var(--ink-2); }
.ftv-branch { display: flex; flex-direction: column; }
@@ -294,92 +316,106 @@ body:has(.forum[data-theme="light"]) .site-footer { background: #0d1220; }
.ftv-replyto { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink-2); }
.ftv-gate { padding: 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
/* --- posts: author on top on phones, the old forums' author column on wide screens --- */
.fp { display: flex; flex-direction: column; padding: 16px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 90px; }
.fp-content { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.fp-author, .fp-when { display: none; }
/* --- posts: a one-line head (avatar, name, rank, signs, time), the text, a
small action row; on wide screens the text lines up under the name --- */
.fp {
display: grid; grid-template-columns: auto minmax(0, 1fr);
grid-template-areas: "av head" "body body" "actions actions" "report report";
column-gap: 10px; row-gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 90px;
}
.fp-av { grid-area: av; display: inline-flex; align-self: center; }
.fp-av a { display: inline-flex; }
.fp-head { grid-area: head; display: flex; align-items: center; gap: 8px; min-width: 0; }
.fp-names { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 6px; flex: 1; min-width: 0; }
.fp-names .fa-name { font-size: 15px; }
.fp-signs { font-size: 13px; color: var(--muted); letter-spacing: 0.5px; }
.fp-time { flex: none; font-size: 13px; color: var(--muted); }
.fp-content { grid-area: body; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.fp-actions { grid-area: actions; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fp-report { grid-area: report; }
.fp-opening { padding-top: 10px; padding-bottom: 14px; }
.fp-opening .fp-names .fa-name { font-size: 16px; }
.ftv-children .fp:last-child { border-bottom: 0; }
.fp-opening { padding-top: 6px; padding-bottom: 20px; }
.fp-body { font-size: 17px; line-height: 1.6; overflow-wrap: anywhere; color: var(--ink); }
.fp-body p + p { margin-top: 10px; }
.fp-nested { padding: 8px 0; row-gap: 4px; }
.fp-nested .fp-body { font-size: 15px; }
.fp-body { font-size: 16px; line-height: 1.55; overflow-wrap: anywhere; color: var(--ink); }
.fp-body p + p { margin-top: 8px; }
.fp.fp-removed { display: flex; flex-direction: column; }
.fp-removed {
gap: 4px; margin: 12px 0; padding: 12px 14px; border: 1px dashed var(--line-2);
gap: 4px; margin: 10px 0; padding: 12px 14px; border: 1px dashed var(--line-2);
border-radius: 12px; color: var(--ink-2); font-size: 15px;
}
.fp-mod-note { font-size: 13px; color: var(--danger); }
.fp-collapsed {
align-self: flex-start; min-height: 44px; padding: 0; border: 0; background: none; color: var(--muted);
align-self: flex-start; min-height: 40px; padding: 0; border: 0; background: none; color: var(--muted);
font: inherit; font-size: 15px; text-decoration: underline; cursor: pointer;
}
.fp-helped { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ok); }
.fp-helped svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.fp-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fp-helped { display: inline-flex; align-items: center; gap: 4px; margin-right: 2px; font-size: 12px; font-weight: 500; color: var(--ok); }
.fp-helped svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.fp-spacer { flex: 1; }
.fp-link {
min-height: 44px; padding: 0 8px; border: 0; background: none; color: var(--gold);
font: 500 15px var(--font-body); cursor: pointer;
.fp-reply {
display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 0 8px; border: 0; border-radius: 8px;
background: none; color: var(--ink-2); font: 500 13px var(--font-body); cursor: pointer;
}
.fp-link:hover { color: var(--gold-hover); }
.fp-tools { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.fp-tools:empty { display: none; }
.fp-tool {
min-height: 36px; padding: 0 8px; border: 0; border-radius: 8px; background: none; color: var(--muted);
font: 400 14px var(--font-body); cursor: pointer;
.fp-reply:hover { color: var(--gold); background: var(--f-hover); }
.fp-reply svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.fp-more {
display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 0; border-radius: 8px;
background: none; color: var(--muted); cursor: pointer;
}
.fp-tool:hover { color: var(--ink); background: var(--f-hover); }
.fp-tool[aria-pressed="true"] { color: var(--ok); }
.fp-tool-mod { color: var(--danger); }
@media (min-width: 900px) {
.forum-inner .ftv { gap: 14px; }
.fp { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 0 24px; padding: 20px 0; }
.fp.fp-removed { display: flex; flex-direction: column; }
.fp-head { display: none; }
.fp-author { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; }
.fp-author-name { font-size: 16px; font-weight: 600; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; margin-top: 2px; }
.fp-author-name:hover { color: var(--gold); }
.fp-author-signs { display: flex; flex-direction: column; gap: 1px; font-size: 13px; color: var(--muted); margin-top: 2px; }
.fp-when { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.ftv-children { margin-left: 40px; padding-left: 20px; }
.ftv-children .fp { grid-template-columns: 120px minmax(0, 1fr); }
.fr-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.fp-more:hover, .fp-more[aria-expanded="true"] { color: var(--ink); background: var(--f-hover); }
.fp-more svg { width: 18px; height: 18px; fill: currentColor; }
@media (min-width: 760px) {
.fp { grid-template-columns: 44px minmax(0, 1fr); grid-template-areas: "av head" ". body" ". actions" ". report"; column-gap: 14px; }
.fp-av { justify-content: center; }
.fp-nested { grid-template-columns: 30px minmax(0, 1fr); column-gap: 10px; }
.ftv-incoming { bottom: 20px; }
}
/* --- reactions --- */
.fr-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.fr-big {
display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 12px; border-radius: 12px;
border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); font: 500 15px var(--font-body); cursor: pointer;
text-align: left;
}
.fr-big:hover:not(:disabled) { border-color: var(--f-border-hover); }
.fr-big[aria-pressed="true"] { border-color: var(--gold); background: var(--f-tint-strong); }
.fr-big:disabled { cursor: default; }
.fr-big-label { flex: 1; min-width: 0; }
.fr-count { color: var(--muted); }
.fr-big[aria-pressed="true"] .fr-count { color: var(--gold); font-weight: 600; }
/* --- reactions: the forum's own marks, an icon and a count --- */
.ri { fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ri-with_you { stroke: var(--r-with_you); }
.ri-thanks { stroke: var(--r-thanks); }
.ri-me_too { stroke: var(--r-me_too); }
.ri-insight { stroke: var(--r-insight); }
.ri-filled.ri-with_you { fill: color-mix(in srgb, var(--r-with_you) 28%, transparent); }
.ri-filled.ri-thanks { fill: color-mix(in srgb, var(--r-thanks) 28%, transparent); }
.ri-filled.ri-me_too { fill: color-mix(in srgb, var(--r-me_too) 24%, transparent); }
.ri-filled.ri-insight { fill: color-mix(in srgb, var(--r-insight) 28%, transparent); }
.ri-filled .ri-line { fill: none; }
.fr-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fr-chip {
min-height: 44px; min-width: 44px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2);
background: none; color: var(--ink); font: 500 14px var(--font-body); cursor: pointer;
display: inline-flex; align-items: center; gap: 5px; min-height: 32px; min-width: 32px; padding: 0 10px; box-sizing: border-box;
border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
font: 500 13px var(--font-body); cursor: pointer; justify-content: center;
}
.fp-nested .fr-chip { min-height: 30px; }
.fr-chip:disabled { cursor: default; }
.fr-chip:hover:not(:disabled) { border-color: var(--f-border-hover); }
.fr-chip[aria-pressed="true"] { border-color: var(--gold); background: var(--f-tint-strong); }
.fr-add { border-style: dashed; color: var(--muted); font-size: 18px; }
.fr-down { color: var(--muted); font-size: 18px; }
.fr-chip:hover:not(:disabled) { border-color: var(--line-2); }
.fr-chip[aria-pressed="true"]:has(.ri-with_you) { border-color: var(--r-with_you); background: color-mix(in srgb, var(--r-with_you) 9%, var(--panel)); }
.fr-chip[aria-pressed="true"]:has(.ri-thanks) { border-color: var(--r-thanks); background: color-mix(in srgb, var(--r-thanks) 9%, var(--panel)); }
.fr-chip[aria-pressed="true"]:has(.ri-me_too) { border-color: var(--r-me_too); background: color-mix(in srgb, var(--r-me_too) 9%, var(--panel)); }
.fr-chip[aria-pressed="true"]:has(.ri-insight) { border-color: var(--r-insight); background: color-mix(in srgb, var(--r-insight) 9%, var(--panel)); }
.fr-add { padding: 0; border-style: dashed; border-color: var(--line-2); background: none; color: var(--muted); }
.fr-add svg, .fr-down svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fr-down { padding: 0; border-color: transparent; background: none; color: var(--muted); }
.fr-down svg { width: 18px; height: 18px; }
.fr-down[aria-pressed="true"] { background: var(--f-hover); color: var(--ink); }
.fr-more { position: relative; }
.fr-pop {
position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 10; min-width: 210px; padding: 6px;
/* --- small menus (the + of reactions, the ⋯ of a post) --- */
.fpop-wrap { position: relative; display: inline-flex; }
.fpop {
position: absolute; left: 0; top: calc(100% + 6px); z-index: 20; min-width: 210px; padding: 6px;
display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px;
box-shadow: var(--f-shadow);
}
.fr-pop-item {
display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border: 0; border-radius: 8px;
background: none; color: var(--ink); font: 400 15px var(--font-body); text-align: left; cursor: pointer;
.fpop-right { left: auto; right: 0; }
.fpop-item {
display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 12px; border: 0; border-radius: 8px;
background: none; color: var(--ink); font: 400 15px var(--font-body); text-align: left; cursor: pointer; white-space: nowrap;
}
.fr-pop-item:hover { background: var(--f-hover); }
.fpop-item:hover, .fpop-item[aria-pressed="true"] { background: var(--f-hover); }
.fpop-danger { color: var(--danger); }
/* --- composer --- */
.fc { display: flex; flex-direction: column; gap: 8px; }
@@ -505,3 +541,5 @@ body:has(.forum[data-theme="light"]) .site-footer { background: #0d1220; }
.ftyping-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ftyping { 0%, 60%, 100% { opacity: 0.25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .ftyping-dots span { animation: none; opacity: 0.6; } }
.fp-link { min-height: 32px; padding: 0 8px; border: 0; background: none; color: var(--gold); font: 500 15px var(--font-body); cursor: pointer; }
.fp-link:hover { color: var(--gold-hover); }
@@ -17,6 +17,28 @@ export function signsText(signs: Record<string, string> | null | undefined): str
return parts.length ? parts.join(" · ") : null;
}
/**
* The short form next to a post: Sun, Moon and Ascendant as glyphs
* ("☉♓ ☽♋ ↑♍"), with the names in `title`. Every planet only on the profile.
*/
export function signGlyphs(signs: Record<string, string> | null | undefined): { text: string; title: string } | null {
if (!signs) return null;
const parts: string[] = [];
const names: string[] = [];
for (const [point, label] of [
["sun", "Nap"],
["moon", "Hold"],
["ascendant", "Aszcendens"],
] as const) {
const sign = signs[point];
if (!sign) continue;
const mark = point === "ascendant" ? "↑" : (POINTS[point]?.glyph ?? "");
parts.push(`${mark}${SIGNS[sign]?.glyph ?? ""}`);
names.push(`${label}: ${SIGNS[sign]?.hu ?? sign}`);
}
return parts.length ? { text: parts.join(" "), title: names.join(", ") } : null;
}
const ORDER = [
"sun",
"moon",
@@ -65,7 +87,8 @@ export function AuthorLine({
</div>
);
}
const shown = signs ? signsText(author.signs) : null;
const glyphs = signs ? signGlyphs(author.signs) : null;
const shown = glyphs?.text ?? null;
return (
<div className="fa-line">
<Link href={memberHref(author.nickname)} className="fa-avatar" tabIndex={-1} aria-hidden="true">
@@ -83,7 +106,11 @@ export function AuthorLine({
</span>
{(shown || time) && (
<span className="fa-sub">
{shown && <span className="sym">{shown}</span>}
{shown && (
<span className="sym" title={glyphs?.title}>
{shown}
</span>
)}
{shown && time && " · "}
{time && (
<time
@@ -1,18 +1,11 @@
// The starter avatars: a gold glyph on a night colour, `<glyph>-<colour>`
// (the forum service checks the same lists). With `online`, the green dot.
// The starter avatars, `<glyph>-<colour>` (the forum service checks the same
// lists): a gold glyph on a night colour in the dark theme, a darker glyph on
// a pale tint in the light one (forum.css: .av-<colour>). With `online`, the
// green dot.
export const AVATAR_GLYPHS = ["hold", "csillag", "nap", "hullam", "level", "lotusz", "kristaly", "toll"] as const;
export const AVATAR_COLOURS = ["ejkek", "lila", "tenger", "borostyan", "rozsa", "erdo"] as const;
const BACKGROUND: Record<string, string> = {
ejkek: "#1c2540",
lila: "#2a2342",
tenger: "#1d3038",
borostyan: "#33291c",
rozsa: "#3a2230",
erdo: "#1f3326",
};
export const GLYPH_NAMES: Record<string, string> = {
hold: "Hold",
csillag: "Csillag",
@@ -86,10 +79,11 @@ export function Avatar({
online?: boolean;
}) {
const [glyph, colour] = (avatar ?? "hold-ejkek").split("-");
const known = (AVATAR_COLOURS as readonly string[]).includes(colour) ? colour : "ejkek";
return (
<span className="av" style={{ width: size, height: size }}>
<span className={`av av-${known}`} style={{ width: size, height: size }}>
<svg viewBox="0 0 40 40" width={size} height={size} aria-hidden="true">
<circle cx="20" cy="20" r="20" fill={BACKGROUND[colour] ?? BACKGROUND.ejkek} />
<circle cx="20" cy="20" r="20" className="av-bg" />
<g className="av-glyph">
<Glyph name={glyph} />
</g>
@@ -0,0 +1,49 @@
// The forum's own reaction marks (no emoji): a heart, a lotus, two circles
// meeting, a star. Each has its colour (forum.css: .ri-<kind>); the viewer's
// own reaction is drawn filled.
import type { ReactionKind } from "@/lib/forum";
export function ReactionIcon({
kind,
size = 16,
filled = false,
}: {
kind: ReactionKind;
size?: number;
filled?: boolean;
}) {
return (
<svg
viewBox="0 0 24 24"
width={size}
height={size}
aria-hidden="true"
className={filled ? `ri ri-${kind} ri-filled` : `ri ri-${kind}`}
>
{kind === "with_you" && (
<path d="M12 20s-7.5-4.6-7.5-10.2A4.2 4.2 0 0 1 12 7.3a4.2 4.2 0 0 1 7.5 2.5C19.5 15.4 12 20 12 20z" />
)}
{kind === "thanks" && (
<>
<path d="M12 4.5c2.3 2.7 2.3 6.6 0 9.3c-2.3-2.7-2.3-6.6 0-9.3z" />
<path d="M12 13.8c-3.2-.5-5.9-2.6-6.8-6.1c3.2.2 5.6 2.4 6.8 6.1z" />
<path d="M12 13.8c3.2-.5 5.9-2.6 6.8-6.1c-3.2.2-5.6 2.4-6.8 6.1z" />
<path d="M5.5 17.5h13" className="ri-line" />
<path d="M8.5 20.2h7" className="ri-line" />
</>
)}
{kind === "me_too" && (
<>
<circle cx="9.3" cy="12" r="5.3" />
<circle cx="14.7" cy="12" r="5.3" />
</>
)}
{kind === "insight" && (
<>
<path d="M11 4l1.7 5.1 5.1 1.7-5.1 1.7L11 17.6l-1.7-5.1-5.1-1.7 5.1-1.7z" />
<path d="M18 15.5l.6 1.6 1.6.6-1.6.6-.6 1.6-.6-1.6-1.6-.6 1.6-.6z" />
</>
)}
</svg>
);
}
@@ -16,11 +16,10 @@ export function CrisisHelp() {
}
/**
* "Jelentés" on a post or a private message: what the problem is, an
* optional note, and a thank-you (with the helpline for a crisis report).
* The report form: what the problem is, an optional note, and a thank-you
* (with the helpline for a crisis report). `onClose`: the form was cancelled.
*/
export function ReportButton({ path, className = "fp-tool" }: { path: string; className?: string }) {
const [open, setOpen] = useState(false);
export function ReportForm({ path, onClose }: { path: string; onClose: () => void }) {
const [kind, setKind] = useState<ReportKind | "">("");
const [note, setNote] = useState("");
const [busy, setBusy] = useState(false);
@@ -45,25 +44,21 @@ export function ReportButton({ path, className = "fp-tool" }: { path: string; cl
if (done) {
return (
<div className="frep" role="status">
<p>Köszönjük, a moderátorok megnézik.</p>
<p>Köszönjük, a moderátorok megnézik. A döntésről e-mailben értesítünk.</p>
{done.crisis && <CrisisHelp />}
<button type="button" className="btn btn-ghost btn-sm frep-close" onClick={onClose}>
Bezárás
</button>
</div>
);
}
if (!open) {
return (
<button type="button" className={className} onClick={() => setOpen(true)}>
Jelentés
</button>
);
}
return (
<form className="frep" onSubmit={submit}>
<fieldset className="fnew-set">
<legend>Mi a gond?</legend>
{REPORT_KINDS.map((k) => (
<label key={k.kind} className="frep-kind">
<input type="radio" name="report-kind" checked={kind === k.kind} onChange={() => setKind(k.kind)} />
<input type="radio" name={`${path}-kind`} checked={kind === k.kind} onChange={() => setKind(k.kind)} />
<span>{k.label}</span>
</label>
))}
@@ -87,7 +82,8 @@ export function ReportButton({ path, className = "fp-tool" }: { path: string; cl
</p>
)}
<div className="fc-actions">
<button type="button" className="btn btn-ghost btn-sm" onClick={() => setOpen(false)}>
<span className="fc-spacer" />
<button type="button" className="btn btn-ghost btn-sm" onClick={onClose}>
Mégse
</button>
<button type="submit" className="btn btn-primary btn-sm" disabled={busy || !kind}>
@@ -97,3 +93,14 @@ export function ReportButton({ path, className = "fp-tool" }: { path: string; cl
</form>
);
}
/** "Jelentés" as a small button that opens the form in place (private messages). */
export function ReportButton({ path, className = "fp-reply" }: { path: string; className?: string }) {
const [open, setOpen] = useState(false);
if (open) return <ReportForm path={path} onClose={() => setOpen(false)} />;
return (
<button type="button" className={className} onClick={() => setOpen(true)}>
Jelentés
</button>
);
}
@@ -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}