Forum: a lighter new thread form

The topic is a row of small labels with the topic icons (its description
and who sees it below), the wish a three-way switch (Meghallgatásra,
Véleményekre, Beszélgetésre; two in a listening topic) with its meaning
below, and the title and the text are one writing surface with the send
button at its foot.

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 17:09:10 +00:00
co-authored by Claude Opus 5.5
parent 67cb3c6b8c
commit c07c7b68bf
4 changed files with 195 additions and 85 deletions
+52
View File
@@ -734,3 +734,55 @@ a.fh-online-item:hover { color: var(--gold); }
@media (min-width: 640px) {
.fshare-drawn { flex-direction: row; align-items: center; gap: 18px; }
}
/* --- new thread: topic labels, a wish switch, one writing surface --- */
.fnew .fnew-set legend { font-size: 15px; font-weight: 600; color: var(--ink); margin-bottom: 10px; }
.fnew-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.fnew-chip {
display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 14px 0 12px;
border: 1px solid var(--line-2); border-radius: 999px; background: var(--panel); color: var(--ink-2);
font-size: 15px; cursor: pointer; transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.fnew-chip:hover { border-color: var(--f-border-hover); color: var(--ink); }
.fnew-chip .topic-icon {
width: 18px; height: 18px; flex: none; fill: none; stroke: var(--gold); stroke-width: 1.8;
stroke-linecap: round; stroke-linejoin: round;
}
.fnew-chip:has(input:checked) { border-color: var(--gold); background: var(--f-tint-strong); color: var(--ink); font-weight: 600; }
.fnew-chip:has(input:focus-visible), .fnew-switch-opt:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }
.fnew-note { margin: 8px 2px 0; font-size: 14px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.fnew-audience { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); }
.fnew-audience svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.fnew-switch { display: grid; gap: 4px; padding: 4px; border-radius: 14px; background: var(--f-tint); border: 1px solid var(--line); }
.fnew-switch-opt {
display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 0 8px;
border-radius: 10px; color: var(--ink-2); font-size: 15px; text-align: center; cursor: pointer;
transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.fnew-switch-opt svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.fnew-switch-opt:hover { color: var(--ink); }
.fnew-switch-opt:has(input:checked) { background: var(--panel); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(27, 34, 54, 0.1); }
.fnew-switch-opt:has(input:checked) svg { color: var(--gold); }
@media (max-width: 479px) {
.fnew-switch-opt { flex-direction: column; gap: 3px; min-height: 58px; font-size: 13px; }
}
.fnew-paper {
display: flex; flex-direction: column; border: 1px solid var(--line-2); border-radius: 16px; background: var(--panel);
overflow: hidden; transition: border-color 0.15s, box-shadow 0.15s;
}
.fnew-paper:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3px var(--f-tint-strong); }
.fnew-title {
border: 0; border-bottom: 1px solid var(--line); background: none; padding: 16px 18px 12px; color: var(--ink);
font: 600 21px/1.3 var(--font-display); outline: none;
}
.fnew-body {
border: 0; background: none; padding: 14px 18px; min-height: 200px; resize: vertical; color: var(--ink);
font: 400 16px/1.6 var(--font-body); outline: none;
}
.fnew-title::placeholder, .fnew-body::placeholder { color: var(--muted); }
.fnew-foot {
display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
padding: 10px 12px 10px 18px; border-top: 1px solid var(--line); background: var(--f-tint);
}
+1 -34
View File
@@ -4,6 +4,7 @@ import { notFound } from "next/navigation";
import { Avatar } from "@/components/forum/Avatar";
import { RankBadge } from "@/components/forum/Badges";
import { JoinTopic } from "@/components/forum/JoinTopic";
import { TopicIcon } from "@/components/forum/TopicIcon";
import { ThreadList, WaitingCard } from "@/components/forum/ThreadList";
import { MoonPhaseIcon } from "@/components/MoonChip";
import { MOON_PHASES, SIGNS } from "@/lib/astro";
@@ -15,40 +16,6 @@ import type { SkyNow } from "@/lib/types";
export const metadata = { title: { absolute: "Fórum · Sorsfonalak" } };
function TopicIcon({ slug }: { slug: string }) {
return (
<svg viewBox="0 0 24 24" aria-hidden="true" className="topic-icon">
{slug === "ami-a-szivemen-van" && (
<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" />
)}
{slug === "belso-utak" && (
<>
<path d="M12 12a1.2 1.2 0 1 0 1.2-1.2" />
<path d="M13.2 10.8A3.4 3.4 0 1 0 15.4 14" />
<path d="M15.4 14A5.6 5.6 0 1 1 12 6.4" />
<path d="M12 6.4a7.8 7.8 0 1 1-7.6 9.4" />
</>
)}
{slug === "egbolt-es-kepletek" && (
<>
<circle cx="12" cy="12" r="8.5" />
<path d="M12 7.5l1.2 3.3 3.3 1.2-3.3 1.2L12 16.5l-1.2-3.3L7.5 12l3.3-1.2z" />
</>
)}
{slug === "torzsasztal" && (
<>
<path d="M4.5 10h11v4.5a5 5 0 0 1-5 5h-1a5 5 0 0 1-5-5z" />
<path d="M15.5 11.5h1.3a2.4 2.4 0 0 1 0 4.8h-1.6" />
<path d="M8.5 3.5c0 1.4 1 1.6 1 3M12 3.5c0 1.4 1 1.6 1 3" />
</>
)}
{!["ami-a-szivemen-van", "belso-utak", "egbolt-es-kepletek", "torzsasztal"].includes(slug) && (
<circle cx="12" cy="12" r="8.5" />
)}
</svg>
);
}
/** "Mai égbolt": the Moon today, the same for everyone; never empty. */
function SkyCard({ sky }: { sky: SkyNow }) {
const moon = sky.moon;
@@ -4,13 +4,57 @@ import Link from "next/link";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { ShareCard } from "@/components/forum/ShareCard";
import { TopicIcon } from "@/components/forum/TopicIcon";
import { api, errorText } from "@/lib/api";
import { convertEmoticons, withEmoji } from "@/lib/emoticons";
import { ShareCard } from "@/components/forum/ShareCard";
import { type ForumTopic, type ShareCardData, threadHref } from "@/lib/forum";
type Intent = "listen" | "advice" | "";
const INTENT_CHOICES: { value: Intent; label: string; hint: string; icon: React.ReactNode }[] = [
{
value: "listen",
label: "Meghallgatásra",
hint: "Nem kérek tanácsot, csak jólesne, ha valaki meghallgatna.",
icon: <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" />,
},
{
value: "advice",
label: "Véleményekre",
hint: "Kíváncsi vagyok, ti mit gondoltok, mit tennétek a helyemben.",
icon: (
<>
<path d="M4 5.5h11a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2H9l-4 3v-3H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2z" />
<path d="M8.5 9a1.6 1.6 0 1 1 2.2 1.5c-.5.2-.7.5-.7 1" />
</>
),
},
{
value: "",
label: "Beszélgetésre",
hint: "Egy téma, egy gondolat, egy élmény, amiről jó lenne beszélgetni.",
icon: (
<>
<path d="M3 6.5h10a1.8 1.8 0 0 1 1.8 1.8v4.4a1.8 1.8 0 0 1-1.8 1.8H8l-3.5 2.6v-2.6H3a1.8 1.8 0 0 1-1.8-1.8V8.3A1.8 1.8 0 0 1 3 6.5z" />
<path d="M17 9.5h2.2A1.8 1.8 0 0 1 21 11.3v4.4a1.8 1.8 0 0 1-1.8 1.8h-.7v2.4L15 17.5h-2.5" />
</>
),
},
];
/** Who sees a topic, in a few words (members-only and restricted topics). */
function audience(topic: ForumTopic | undefined): string | null {
if (topic?.visibility === "members") return "csak belépett tagok látják";
if (topic?.visibility === "restricted") return "csak a zárt kör tagjai látják";
return null;
}
/**
* Starting a thread: the topic as a row of small labels, what the writer
* wishes for as a switch (each with its one-line meaning below), then one
* writing surface for the title and the text, with the send button at its foot.
*/
export function NewThreadForm({
topics,
initialTopic,
@@ -24,17 +68,22 @@ export function NewThreadForm({
const router = useRouter();
const [share, setShare] = useState(initialShare ?? null);
const [topic, setTopic] = useState(initialTopic);
const listening = topics.find((t) => t.slug === topic)?.listening ?? false;
const chosen = topics.find((t) => t.slug === topic);
const listening = chosen?.listening ?? false;
const [intent, setIntent] = useState<Intent>(listening ? "listen" : "");
const [title, setTitle] = useState("");
const [body, setBody] = useState("");
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
// A listening topic: hearing or opinions, no small talk.
const choices = INTENT_CHOICES.filter((c) => !listening || c.value !== "");
const intentHint = choices.find((c) => c.value === intent)?.hint;
const seenBy = audience(chosen);
function pickTopic(slug: string) {
setTopic(slug);
const t = topics.find((x) => x.slug === slug);
if (t?.listening) setIntent("listen");
if (t?.listening && intent === "") setIntent("listen");
}
async function submit(e: React.FormEvent) {
@@ -70,74 +119,82 @@ export function NewThreadForm({
</span>
</div>
)}
<fieldset className="fnew-set">
<legend>Téma</legend>
<div className="fnew-topics">
<legend>Melyik témába?</legend>
<div className="fnew-chips">
{topics.map((t) => (
<label key={t.slug} className="fnew-topic">
<label key={t.slug} className="fnew-chip">
<input
type="radio"
name="topic"
value={t.slug}
checked={topic === t.slug}
onChange={() => pickTopic(t.slug)}
className="sr-only"
/>
<span>
<strong>{t.name}</strong>
<span className="hint">{t.description}</span>
</span>
<TopicIcon slug={t.slug} />
<span>{t.name}</span>
</label>
))}
</div>
{chosen && (
<p className="fnew-note">
{chosen.description}
{seenBy && (
<span className="fnew-audience">
<svg viewBox="0 0 24 24" aria-hidden="true">
<rect x="5" y="11" width="14" height="9" rx="2" />
<path d="M8 11V8a4 4 0 0 1 8 0v3" />
</svg>
{seenBy}
</span>
)}
</p>
)}
</fieldset>
<fieldset className="fnew-set">
<legend>Mit szeretnél?</legend>
<div className="fnew-intents">
<label className="fnew-intent">
<input type="radio" name="intent" checked={intent === "listen"} onChange={() => setIntent("listen")} />
<span>
<strong>Csak meghallgatást kérek</strong>
<span className="hint">Nem kérek tanácsot, jólesne, ha valaki meghallgatna.</span>
</span>
</label>
<label className="fnew-intent">
<input type="radio" name="intent" checked={intent === "advice"} onChange={() => setIntent("advice")} />
<span>
<strong>Tanácsot, véleményt kérek</strong>
<span className="hint">Kíváncsi vagyok, ti mit gondoltok, mit tennétek.</span>
</span>
</label>
{!listening && (
<label className="fnew-intent">
<input type="radio" name="intent" checked={intent === ""} onChange={() => setIntent("")} />
<span>
<strong>Csak beszélgetnék</strong>
<span className="hint">Egy téma, egy gondolat, egy élmény.</span>
</span>
<legend>Mire vágysz?</legend>
<div className="fnew-switch" style={{ gridTemplateColumns: `repeat(${choices.length}, minmax(0, 1fr))` }}>
{choices.map((c) => (
<label key={c.value || "chat"} className="fnew-switch-opt">
<input
type="radio"
name="intent"
checked={intent === c.value}
onChange={() => setIntent(c.value)}
className="sr-only"
/>
<svg viewBox="0 0 24 24" aria-hidden="true">
{c.icon}
</svg>
<span>{c.label}</span>
</label>
)}
))}
</div>
{intentHint && <p className="fnew-note">{intentHint}</p>}
</fieldset>
<div className="field">
<label htmlFor="fnew-title">Cím</label>
<div className="fnew-paper">
<label htmlFor="fnew-title" className="sr-only">
Cím
</label>
<input
id="fnew-title"
className="inp"
className="fnew-title"
value={title}
onChange={(e) => withEmoji(e, setTitle)}
maxLength={120}
required
placeholder="Miről szeretnél beszélgetni?"
placeholder="Adj címet a szálnak…"
/>
</div>
<div className="field">
<label htmlFor="fnew-body">Az első hozzászólás</label>
<label htmlFor="fnew-body" className="sr-only">
Az első hozzászólás
</label>
<textarea
id="fnew-body"
className="fc-text"
className="fnew-body"
rows={8}
value={body}
onChange={(e) => withEmoji(e, setBody)}
@@ -145,21 +202,21 @@ export function NewThreadForm({
required
placeholder={intent === "listen" ? "Írd le, ami benned van…" : "Írd le a gondolataidat…"}
/>
<div className="fnew-foot">
<span className="hint">
Kérjük, tartsd be a <Link href="/aszf#forum">házirendet</Link>.
</span>
<button type="submit" className="btn btn-primary" disabled={busy || !title.trim() || !body.trim() || !topic}>
{busy ? "Küldés…" : "Szál indítása"}
</button>
</div>
</div>
<p className="hint">
Írás előtt érdemes elolvasni a <Link href="/aszf#forum">fórum házirendjét</Link>: tisztelettel, kéretlen tanács
és hirdetés nélkül.
</p>
{error && (
<p className="msg msg-error" role="alert">
{error}
</p>
)}
<button type="submit" className="btn btn-primary" disabled={busy || !title.trim() || !body.trim() || !topic}>
{busy ? "Küldés…" : "Szál indítása"}
</button>
</form>
);
}
@@ -0,0 +1,34 @@
/** A topic's line icon (a circle for topics without one of their own). */
export function TopicIcon({ slug }: { slug: string }) {
return (
<svg viewBox="0 0 24 24" aria-hidden="true" className="topic-icon">
{slug === "ami-a-szivemen-van" && (
<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" />
)}
{slug === "belso-utak" && (
<>
<path d="M12 12a1.2 1.2 0 1 0 1.2-1.2" />
<path d="M13.2 10.8A3.4 3.4 0 1 0 15.4 14" />
<path d="M15.4 14A5.6 5.6 0 1 1 12 6.4" />
<path d="M12 6.4a7.8 7.8 0 1 1-7.6 9.4" />
</>
)}
{slug === "egbolt-es-kepletek" && (
<>
<circle cx="12" cy="12" r="8.5" />
<path d="M12 7.5l1.2 3.3 3.3 1.2-3.3 1.2L12 16.5l-1.2-3.3L7.5 12l3.3-1.2z" />
</>
)}
{slug === "torzsasztal" && (
<>
<path d="M4.5 10h11v4.5a5 5 0 0 1-5 5h-1a5 5 0 0 1-5-5z" />
<path d="M15.5 11.5h1.3a2.4 2.4 0 0 1 0 4.8h-1.6" />
<path d="M8.5 3.5c0 1.4 1 1.6 1 3M12 3.5c0 1.4 1 1.6 1 3" />
</>
)}
{!["ami-a-szivemen-van", "belso-utak", "egbolt-es-kepletek", "torzsasztal"].includes(slug) && (
<circle cx="12" cy="12" r="8.5" />
)}
</svg>
);
}