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-orange-tint: rgba(240, 163, 94, 0.12);
--f-red-tint: rgba(242, 160, 160, 0.08); --f-red-tint: rgba(242, 160, 160, 0.08);
--f-green-tint: rgba(159, 216, 176, 0.12); --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); color: var(--ink);
} }
.forum[data-theme="light"] { .forum[data-theme="light"] {
@@ -49,6 +53,10 @@
--f-orange-tint: rgba(156, 82, 14, 0.09); --f-orange-tint: rgba(156, 82, 14, 0.09);
--f-red-tint: rgba(176, 58, 58, 0.07); --f-red-tint: rgba(176, 58, 58, 0.07);
--f-green-tint: rgba(45, 122, 76, 0.1); --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; color-scheme: light;
} }
/* The light forum takes the whole page between the (dark) header and footer /* 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 --- */ /* --- 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; } .av svg { display: block; }
/* The night-coloured avatars keep the bright gold in both themes. */ .av-lila { --av-bg: #2a2342; }
.av-glyph { fill: none; stroke: #d9b46a; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; } .av-tenger { --av-bg: #1d3038; }
.av-glyph .av-fill { fill: #d9b46a; stroke: none; } .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 { .av-online {
position: absolute; right: -1px; bottom: -1px; width: 28%; height: 28%; min-width: 9px; min-height: 9px; 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; 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 { background: var(--f-orange-tint); }
.ftv-intent-advice strong { color: var(--square); } .ftv-intent-advice strong { color: var(--square); }
.ftv-title { font-size: 30px; line-height: 1.12; } .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-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 .ftv-count h2 { font-family: var(--font-body); font-size: 15px; color: var(--ink-2); }
.ftv-branch { display: flex; flex-direction: column; } .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-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); } .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 --- */ /* --- posts: a one-line head (avatar, name, rank, signs, time), the text, a
.fp { display: flex; flex-direction: column; padding: 16px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 90px; } small action row; on wide screens the text lines up under the name --- */
.fp-content { display: flex; flex-direction: column; gap: 10px; min-width: 0; } .fp {
.fp-author, .fp-when { display: none; } 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; } .ftv-children .fp:last-child { border-bottom: 0; }
.fp-opening { padding-top: 6px; padding-bottom: 20px; } .fp-nested { padding: 8px 0; row-gap: 4px; }
.fp-body { font-size: 17px; line-height: 1.6; overflow-wrap: anywhere; color: var(--ink); } .fp-nested .fp-body { font-size: 15px; }
.fp-body p + p { margin-top: 10px; } .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 { .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; border-radius: 12px; color: var(--ink-2); font-size: 15px;
} }
.fp-mod-note { font-size: 13px; color: var(--danger); } .fp-mod-note { font-size: 13px; color: var(--danger); }
.fp-collapsed { .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; 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 { display: inline-flex; align-items: center; gap: 4px; margin-right: 2px; font-size: 12px; font-weight: 500; 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-helped svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.fp-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fp-spacer { flex: 1; } .fp-spacer { flex: 1; }
.fp-link { .fp-reply {
min-height: 44px; padding: 0 8px; border: 0; background: none; color: var(--gold); display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 0 8px; border: 0; border-radius: 8px;
font: 500 15px var(--font-body); cursor: pointer; background: none; color: var(--ink-2); font: 500 13px var(--font-body); cursor: pointer;
} }
.fp-link:hover { color: var(--gold-hover); } .fp-reply:hover { color: var(--gold); background: var(--f-hover); }
.fp-tools { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; } .fp-reply svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.fp-tools:empty { display: none; } .fp-more {
.fp-tool { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 0; border-radius: 8px;
min-height: 36px; padding: 0 8px; border: 0; border-radius: 8px; background: none; color: var(--muted); background: none; color: var(--muted); cursor: pointer;
font: 400 14px var(--font-body); cursor: pointer;
} }
.fp-tool:hover { color: var(--ink); background: var(--f-hover); } .fp-more:hover, .fp-more[aria-expanded="true"] { color: var(--ink); background: var(--f-hover); }
.fp-tool[aria-pressed="true"] { color: var(--ok); } .fp-more svg { width: 18px; height: 18px; fill: currentColor; }
.fp-tool-mod { color: var(--danger); } @media (min-width: 760px) {
@media (min-width: 900px) { .fp { grid-template-columns: 44px minmax(0, 1fr); grid-template-areas: "av head" ". body" ". actions" ". report"; column-gap: 14px; }
.forum-inner .ftv { gap: 14px; } .fp-av { justify-content: center; }
.fp { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 0 24px; padding: 20px 0; } .fp-nested { grid-template-columns: 30px minmax(0, 1fr); column-gap: 10px; }
.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)); }
.ftv-incoming { bottom: 20px; } .ftv-incoming { bottom: 20px; }
} }
/* --- reactions --- */ /* --- reactions: the forum's own marks, an icon and a count --- */
.fr-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } .ri { fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.fr-big { .ri-with_you { stroke: var(--r-with_you); }
display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 12px; border-radius: 12px; .ri-thanks { stroke: var(--r-thanks); }
border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); font: 500 15px var(--font-body); cursor: pointer; .ri-me_too { stroke: var(--r-me_too); }
text-align: left; .ri-insight { stroke: var(--r-insight); }
} .ri-filled.ri-with_you { fill: color-mix(in srgb, var(--r-with_you) 28%, transparent); }
.fr-big:hover:not(:disabled) { border-color: var(--f-border-hover); } .ri-filled.ri-thanks { fill: color-mix(in srgb, var(--r-thanks) 28%, transparent); }
.fr-big[aria-pressed="true"] { border-color: var(--gold); background: var(--f-tint-strong); } .ri-filled.ri-me_too { fill: color-mix(in srgb, var(--r-me_too) 24%, transparent); }
.fr-big:disabled { cursor: default; } .ri-filled.ri-insight { fill: color-mix(in srgb, var(--r-insight) 28%, transparent); }
.fr-big-label { flex: 1; min-width: 0; } .ri-filled .ri-line { fill: none; }
.fr-count { color: var(--muted); }
.fr-big[aria-pressed="true"] .fr-count { color: var(--gold); font-weight: 600; }
.fr-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; } .fr-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fr-chip { .fr-chip {
min-height: 44px; min-width: 44px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); display: inline-flex; align-items: center; gap: 5px; min-height: 32px; min-width: 32px; padding: 0 10px; box-sizing: border-box;
background: none; color: var(--ink); font: 500 14px var(--font-body); cursor: pointer; 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:disabled { cursor: default; }
.fr-chip:hover:not(:disabled) { border-color: var(--f-border-hover); } .fr-chip:hover:not(:disabled) { border-color: var(--line-2); }
.fr-chip[aria-pressed="true"] { border-color: var(--gold); background: var(--f-tint-strong); } .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-add { border-style: dashed; color: var(--muted); font-size: 18px; } .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-down { color: var(--muted); font-size: 18px; } .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-down[aria-pressed="true"] { background: var(--f-hover); color: var(--ink); }
.fr-more { position: relative; }
.fr-pop { /* --- small menus (the + of reactions, the ⋯ of a post) --- */
position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 10; min-width: 210px; padding: 6px; .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; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px;
box-shadow: var(--f-shadow); box-shadow: var(--f-shadow);
} }
.fr-pop-item { .fpop-right { left: auto; right: 0; }
display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border: 0; border-radius: 8px; .fpop-item {
background: none; color: var(--ink); font: 400 15px var(--font-body); text-align: left; cursor: pointer; 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 --- */ /* --- composer --- */
.fc { display: flex; flex-direction: column; gap: 8px; } .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; } .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); } } @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; } } @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; 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 = [ const ORDER = [
"sun", "sun",
"moon", "moon",
@@ -65,7 +87,8 @@ export function AuthorLine({
</div> </div>
); );
} }
const shown = signs ? signsText(author.signs) : null; const glyphs = signs ? signGlyphs(author.signs) : null;
const shown = glyphs?.text ?? null;
return ( return (
<div className="fa-line"> <div className="fa-line">
<Link href={memberHref(author.nickname)} className="fa-avatar" tabIndex={-1} aria-hidden="true"> <Link href={memberHref(author.nickname)} className="fa-avatar" tabIndex={-1} aria-hidden="true">
@@ -83,7 +106,11 @@ export function AuthorLine({
</span> </span>
{(shown || time) && ( {(shown || time) && (
<span className="fa-sub"> <span className="fa-sub">
{shown && <span className="sym">{shown}</span>} {shown && (
<span className="sym" title={glyphs?.title}>
{shown}
</span>
)}
{shown && time && " · "} {shown && time && " · "}
{time && ( {time && (
<time <time
@@ -1,18 +1,11 @@
// The starter avatars: a gold glyph on a night colour, `<glyph>-<colour>` // The starter avatars, `<glyph>-<colour>` (the forum service checks the same
// (the forum service checks the same lists). With `online`, the green dot. // 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_GLYPHS = ["hold", "csillag", "nap", "hullam", "level", "lotusz", "kristaly", "toll"] as const;
export const AVATAR_COLOURS = ["ejkek", "lila", "tenger", "borostyan", "rozsa", "erdo"] 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> = { export const GLYPH_NAMES: Record<string, string> = {
hold: "Hold", hold: "Hold",
csillag: "Csillag", csillag: "Csillag",
@@ -86,10 +79,11 @@ export function Avatar({
online?: boolean; online?: boolean;
}) { }) {
const [glyph, colour] = (avatar ?? "hold-ejkek").split("-"); const [glyph, colour] = (avatar ?? "hold-ejkek").split("-");
const known = (AVATAR_COLOURS as readonly string[]).includes(colour) ? colour : "ejkek";
return ( 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"> <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"> <g className="av-glyph">
<Glyph name={glyph} /> <Glyph name={glyph} />
</g> </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 * The report form: what the problem is, an optional note, and a thank-you
* optional note, and a thank-you (with the helpline for a crisis report). * (with the helpline for a crisis report). `onClose`: the form was cancelled.
*/ */
export function ReportButton({ path, className = "fp-tool" }: { path: string; className?: string }) { export function ReportForm({ path, onClose }: { path: string; onClose: () => void }) {
const [open, setOpen] = useState(false);
const [kind, setKind] = useState<ReportKind | "">(""); const [kind, setKind] = useState<ReportKind | "">("");
const [note, setNote] = useState(""); const [note, setNote] = useState("");
const [busy, setBusy] = useState(false); const [busy, setBusy] = useState(false);
@@ -45,16 +44,12 @@ export function ReportButton({ path, className = "fp-tool" }: { path: string; cl
if (done) { if (done) {
return ( return (
<div className="frep" role="status"> <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 />} {done.crisis && <CrisisHelp />}
</div> <button type="button" className="btn btn-ghost btn-sm frep-close" onClick={onClose}>
); Bezárás
}
if (!open) {
return (
<button type="button" className={className} onClick={() => setOpen(true)}>
Jelentés
</button> </button>
</div>
); );
} }
return ( return (
@@ -63,7 +58,7 @@ export function ReportButton({ path, className = "fp-tool" }: { path: string; cl
<legend>Mi a gond?</legend> <legend>Mi a gond?</legend>
{REPORT_KINDS.map((k) => ( {REPORT_KINDS.map((k) => (
<label key={k.kind} className="frep-kind"> <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> <span>{k.label}</span>
</label> </label>
))} ))}
@@ -87,7 +82,8 @@ export function ReportButton({ path, className = "fp-tool" }: { path: string; cl
</p> </p>
)} )}
<div className="fc-actions"> <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 Mégse
</button> </button>
<button type="submit" className="btn btn-primary btn-sm" disabled={busy || !kind}> <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> </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 { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { api, errorText } from "@/lib/api"; 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 { Avatar } from "./Avatar";
import { Composer } from "./Composer"; import { Composer } from "./Composer";
import { PostBody } from "./PostBody"; import { PostBody } from "./PostBody";
import type { LiveNotice } from "./ForumNav"; import type { LiveNotice } from "./ForumNav";
import { ReportButton } from "./ReportButton"; import { ReactionIcon } from "./ReactionIcon";
import { ReportForm } from "./ReportButton";
import { TypingLine, useTypingSender, useTypingWatch } from "./typing"; import { TypingLine, useTypingSender, useTypingWatch } from "./typing";
/** How often the open thread looks for new replies (while the page is in front). */ /** 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; 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({ function ReactionRow({
post, post,
enabled, enabled,
@@ -69,15 +49,20 @@ function ReactionRow({
type="button" type="button"
className="fr-chip" className="fr-chip"
aria-pressed={post.mine === r.kind} 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} disabled={!enabled}
onClick={() => onReact(post, r.kind)} 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> </button>
))} ))}
{enabled && ( {enabled && (
<span className="fr-more"> <Popover
open={open}
onClose={() => setOpen(false)}
button={
<button <button
type="button" type="button"
className="fr-chip fr-add" className="fr-chip fr-add"
@@ -85,27 +70,29 @@ function ReactionRow({
aria-expanded={open} aria-expanded={open}
onClick={() => setOpen((o) => !o)} onClick={() => setOpen((o) => !o)}
> >
+ <svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M12 6v12M6 12h12" />
</svg>
</button> </button>
{open && ( }
<span className="fr-pop" role="menu"> >
{REACTIONS.map((r) => ( {REACTIONS.map((r) => (
<button <button
key={r.kind} key={r.kind}
type="button" type="button"
role="menuitem" role="menuitem"
className="fr-pop-item" className="fpop-item"
aria-pressed={post.mine === r.kind}
onClick={() => { onClick={() => {
setOpen(false); setOpen(false);
onReact(post, r.kind); onReact(post, r.kind);
}} }}
> >
<span aria-hidden="true">{r.emoji}</span> {r.label} <ReactionIcon kind={r.kind} size={18} filled={post.mine === r.kind} />
{r.label}
</button> </button>
))} ))}
</span> </Popover>
)}
</span>
)} )}
{canDownvote && enabled && ( {canDownvote && enabled && (
<button <button
@@ -116,44 +103,54 @@ function ReactionRow({
title="Nem visz előre" title="Nem visz előre"
onClick={() => onReact(post, "down")} onClick={() => onReact(post, "down")}
> >
⌄ <svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M7 10l5 5 5-5" />
</svg>
</button> </button>
)} )}
</div> </div>
); );
} }
/** The author column of wide screens: avatar, nickname, rank, badges, signs one per line. */ /** A small menu under a button (closes on a click elsewhere or Escape). */
function AuthorPanel({ author, starter }: { author: ForumPost["author"]; starter: boolean }) { function Popover({
if (!author) { 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 ( return (
<aside className="fp-author"> <span className="fpop-wrap" ref={box}>
<Avatar avatar={null} size={56} /> {button}
<span className="fp-author-name muted">Törölt tag</span> {open && (
</aside> <span className={align === "right" ? "fpop fpop-right" : "fpop"} role="menu">
); {children}
}
const signs = signsText(author.signs);
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> </span>
)} )}
</aside> </span>
); );
} }
@@ -162,18 +159,25 @@ function PostCard({
page, page,
actions, actions,
isNew, isNew,
nested = false,
}: { }: {
post: ForumPost; post: ForumPost;
page: ThreadPage; page: ThreadPage;
actions: Actions; actions: Actions;
isNew: boolean; isNew: boolean;
nested?: boolean;
}) { }) {
const [editing, setEditing] = useState(false); const [editing, setEditing] = useState(false);
const [reporting, setReporting] = useState(false);
const [menu, setMenu] = useState(false);
const [showCollapsed, setShowCollapsed] = useState(false); const [showCollapsed, setShowCollapsed] = useState(false);
const { viewer, thread, access } = page; const { viewer, thread, access } = page;
const writer = viewer.member !== null && !viewer.member.banned; const writer = viewer.member !== null && !viewer.member.banned;
const starter = post.author !== null && post.author.nickname === thread.author?.nickname; const starter = post.author !== null && post.author.nickname === thread.author?.nickname;
const canReact = writer && !post.own && !post.deleted && !thread.locked; 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) { if (post.deleted && !viewer.moderator) {
return ( 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 ( return (
<article className={post.is_opening ? "fp fp-opening" : "fp"} id={`h${post.id}`}> <article className={classes} id={`h${post.id}`}>
{/* Wide screens: the old forums' author column. */} <span className="fp-av">
<AuthorPanel author={post.author} starter={starter && !post.is_opening} /> {author ? (
<div className="fp-content"> <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"> <div className="fp-head">
<AuthorLine <span className="fp-names">
author={post.author} {author ? (
size={post.is_opening ? 44 : 36} <Link href={memberHref(author.nickname)} className="fa-name">
time={post.created_at} {author.nickname}
edited={post.edited_at !== null} </Link>
badges={ ) : (
<> <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>} {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>} {isNew && <span className="fa-badge fa-badge-new">új</span>}
</> {glyphs && !nested && (
} <span className="fp-signs sym" title={glyphs.title}>
/> {glyphs.text}
</div> </span>
<p className="fp-when"> )}
<time suppressHydrationWarning dateTime={post.created_at}> </span>
{new Date(post.created_at).toLocaleString("hu-HU", { <time
timeZone: "Europe/Budapest", className="fp-time"
month: "long", suppressHydrationWarning
day: "numeric", dateTime={post.created_at}
hour: "2-digit", title={new Date(post.created_at).toLocaleString("hu-HU", { timeZone: "Europe/Budapest" })}
minute: "2-digit", >
})} {ago(post.created_at)}
</time>
{post.edited_at && " · szerkesztve"} {post.edited_at && " · szerkesztve"}
{isNew && <span className="fa-badge fa-badge-new">új</span>} </time>
</p> </div>
<div className="fp-content">
{post.deleted && ( {post.deleted && (
<p className="fp-mod-note"> <p className="fp-mod-note">
Eltávolítva{post.deleted.reason ? ` (ok: ${post.deleted.reason})` : " a szerző által"}. Csak a moderátorok 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.body !== null && <PostBody text={post.body} />
)} )}
</div>
{!editing && (!post.deleted || menuItems.length > 0) && (
<div className="fp-actions">
{post.helped && ( {post.helped && (
<p className="fp-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"> <svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M5 12.5l4.5 4.5L19 7.5" /> <path d="M5 12.5l4.5 4.5L19 7.5" />
</svg> </svg>
{thread.author?.nickname ?? "A szál indítója"} szerint ez segített Segített
</p> </span>
)} )}
{!post.deleted && !editing && ( {!post.deleted && (
<>
{post.is_opening ? (
<ReactionGrid post={post} enabled={canReact} onReact={actions.react} />
) : (
<div className="fp-actions">
<ReactionRow <ReactionRow
post={post} post={post}
enabled={canReact} enabled={canReact}
canDownvote={access?.can_downvote ?? false} canDownvote={access?.can_downvote ?? false}
onReact={actions.react} onReact={actions.react}
/> />
)}
<span className="fp-spacer" /> <span className="fp-spacer" />
{access?.can_reply && writer && ( {viewer.moderator && typeof post.down === "number" && post.down > 0 && (
<button type="button" className="fp-link" onClick={() => actions.replyTo(post)}> <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 Válasz
</button> </button>
)} )}
</div> {menuItems.length > 0 && (
)} <Popover
<div className="fp-tools"> open={menu}
{access?.is_thread_author && !post.is_opening && !post.own && writer && ( onClose={() => setMenu(false)}
align="right"
button={
<button <button
type="button" type="button"
className="fp-tool" className="fp-more"
onClick={() => actions.helped(post)} aria-label="Továbbiak"
aria-pressed={post.helped} 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> </button>
)} }
{post.own && writer && !thread.locked && ( >
<button type="button" className="fp-tool" onClick={() => setEditing(true)}> {menuItems.map((item) => (
Szerkesztés <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> </button>
)} ))}
{post.own && ( </Popover>
<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> </div>
</>
)} )}
{post.deleted && viewer.moderator && ( {reporting && (
<div className="fp-tools"> <div className="fp-report">
<button type="button" className="fp-tool" onClick={() => actions.restore(post)}> <ReportForm path={`/forum/posts/${post.id}/report`} onClose={() => setReporting(false)} />
Visszaállítás (admin)
</button>
</div> </div>
)} )}
</div>
</article> </article>
); );
} }
@@ -524,24 +562,19 @@ export function ThreadView({ initial }: { initial: ThreadPage }) {
</div> </div>
) : null} ) : 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"> <h1 className="ftv-title">
{thread.pinned && <span className="ft-pin">Kitűzve</span>} {thread.pinned && <span className="ft-pin">Kitűzve</span>}
{thread.locked && <span className="ft-pin">Lezárva</span>} {thread.locked && <span className="ft-pin">Lezárva</span>}
{thread.title} {thread.title}
</h1> </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} />} {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) => ( {childrenOf(top.id).map((child) => (
<PostCard <PostCard
key={child.id} key={child.id}
nested
post={child} post={child}
page={page} page={page}
actions={actions} actions={actions}