Forum: thread cards with the start of the opening post, latest threads and pinned threads on the front page
- Every thread card shows the start of the opening post (two lines on a computer, three on a phone), its topic with the icon (a lock for members-only and restricted ones), pinned and the wish; the replies, the last activity and what is new on the right (in the bottom line on a phone). The same card in topics, search and followed threads. - The front page: "Legutóbbi szálak" below the topics, from every topic the viewer may read (not the archived ones), the latest activity first, 20 a page with a pager; pinned threads in "Kitűzve" above the topics. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -3,6 +3,7 @@ import Link from "next/link";
|
||||
import { INTENTS, type ThreadCard, ago, threadHref } from "@/lib/forum";
|
||||
|
||||
import { Avatar } from "./Avatar";
|
||||
import { TopicIcon } from "./TopicIcon";
|
||||
|
||||
export function IntentTag({ intent, long = false }: { intent: ThreadCard["intent"]; long?: boolean }) {
|
||||
if (!intent) return null;
|
||||
@@ -10,53 +11,80 @@ export function IntentTag({ intent, long = false }: { intent: ThreadCard["intent
|
||||
return <span className={`ft-intent ft-intent-${intent}`}>{text}</span>;
|
||||
}
|
||||
|
||||
function UnreadPill({ n }: { n: number | null }) {
|
||||
function UnreadPill({ n, onlyNew = false }: { n: number | null; onlyNew?: boolean }) {
|
||||
if (n === null) return null;
|
||||
if (n === 0) return <span className="ft-read">olvasva</span>;
|
||||
if (n === 0) return onlyNew ? null : <span className="ft-read">olvasva</span>;
|
||||
return <span className="ft-new">{n > 99 ? "99+" : n} új</span>;
|
||||
}
|
||||
|
||||
/** Threads in a list: title, topic, replies, the starter, what is new. */
|
||||
/**
|
||||
* Threads in a list. Each card: the topic (with a lock for members-only and
|
||||
* restricted ones), pinned and the wish, the title, the start of the opening
|
||||
* post (two lines on a computer, three on a phone), the starter; replies,
|
||||
* the last activity and what is new on the right on a computer, in the
|
||||
* bottom line on a phone.
|
||||
*/
|
||||
export function ThreadList({ threads, showTopic = true }: { threads: ThreadCard[]; showTopic?: boolean }) {
|
||||
return (
|
||||
<ul className="ft-list">
|
||||
{threads.map((t) => (
|
||||
<li key={t.id}>
|
||||
<Link href={threadHref(t)} className="ft-row">
|
||||
<span className="ft-main">
|
||||
<span className="ft-title">
|
||||
{t.pinned && <span className="ft-pin">Kitűzve</span>}
|
||||
{t.locked && <span className="ft-pin">Lezárva</span>}
|
||||
{t.title}
|
||||
</span>
|
||||
<span className="ft-meta">
|
||||
{t.author && <Avatar avatar={t.author.avatar} size={20} online={t.author.online} />}
|
||||
<span>
|
||||
{t.system ? "Sorsfonalak" : (t.author?.nickname ?? "Törölt tag")}
|
||||
{showTopic && ` · ${t.topic.name}`}
|
||||
{threads.map((t) => {
|
||||
const closed = t.topic.visibility !== undefined && t.topic.visibility !== "public";
|
||||
const tags = showTopic || t.pinned || t.locked || t.intent;
|
||||
return (
|
||||
<li key={t.id}>
|
||||
<Link href={threadHref(t)} className="ft-row">
|
||||
<span className="ft-main">
|
||||
{tags && (
|
||||
<span className="ft-tags">
|
||||
{showTopic && (
|
||||
<span className="ft-topic">
|
||||
<TopicIcon slug={t.topic.slug} />
|
||||
{t.topic.name}
|
||||
{closed && (
|
||||
<svg viewBox="0 0 24 24" className="ft-lock" role="img" aria-label="Nem nyilvános téma">
|
||||
<rect x="5" y="11" width="14" height="9" rx="2" />
|
||||
<path d="M8 11V8a4 4 0 0 1 8 0v3" />
|
||||
</svg>
|
||||
)}
|
||||
</span>
|
||||
)}
|
||||
{t.pinned && <span className="ft-pin">Kitűzve</span>}
|
||||
{t.locked && <span className="ft-pin">Lezárva</span>}
|
||||
<IntentTag intent={t.intent} />
|
||||
</span>
|
||||
)}
|
||||
<span className="ft-title">{t.title}</span>
|
||||
{t.excerpt && <span className="ft-excerpt">{t.excerpt}</span>}
|
||||
<span className="ft-meta">
|
||||
{t.author && <Avatar avatar={t.author.avatar} size={20} online={t.author.online} />}
|
||||
<span className="ft-who">{t.system ? "Sorsfonalak" : (t.author?.nickname ?? "Törölt tag")}</span>
|
||||
<span className="ft-m-narrow">
|
||||
{" "}
|
||||
· {t.reply_count} válasz ·{" "}
|
||||
<time suppressHydrationWarning dateTime={t.last_post_at}>
|
||||
{ago(t.last_post_at)}
|
||||
</time>
|
||||
</span>
|
||||
<span className="ft-m-narrow ft-m-new">
|
||||
<UnreadPill n={t.unread} onlyNew />
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
<span className="ft-col ft-col-replies">
|
||||
<strong>{t.reply_count}</strong> válasz
|
||||
{t.participants > 1 && <span className="hint">{t.participants} résztvevő</span>}
|
||||
</span>
|
||||
<span className="ft-col ft-col-last">
|
||||
<time suppressHydrationWarning dateTime={t.last_post_at}>
|
||||
{ago(t.last_post_at)}
|
||||
</time>
|
||||
</span>
|
||||
<UnreadPill n={t.unread} />
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
<span className="ft-side">
|
||||
<span>
|
||||
<strong>{t.reply_count}</strong> válasz
|
||||
</span>
|
||||
<span className="hint">
|
||||
utoljára{" "}
|
||||
<time suppressHydrationWarning dateTime={t.last_post_at}>
|
||||
{ago(t.last_post_at)}
|
||||
</time>
|
||||
</span>
|
||||
<UnreadPill n={t.unread} />
|
||||
</span>
|
||||
</Link>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user