nomadro/src/modules/social/components/PeopleClient.tsx
Eric bbe2514e96 Restore immersive /social motion FX and expand the glass community workspace.
Keep Codex layout polish, but force emoji/orbit/constellation animations when immersive is on even under OS reduced-motion.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-01 18:38:04 +08:00

195 lines
6.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use client";
import { useMemo, useState } from "react";
import Link from "next/link";
import { useSearchParams } from "next/navigation";
import { ArrowUpRight, MapPin, MessageCircle, Sparkles } from "lucide-react";
import SiteShell from "./SiteShell";
import SocialAvatar from "./SocialAvatar";
import {
BookmarkButton,
EmptyState,
PageIntro,
SearchField,
ShareButton,
SocialDialog,
} from "./SocialUI";
import { MOCK_ROSTER, type SocialRosterMember } from "@social/lib/rosterMock";
import { socialPath } from "@social/lib/socialPath";
import { useLocalState } from "@social/lib/useLocalState";
export default function PeopleClient() {
const params = useSearchParams();
const [query, setQuery] = useState(params.get("city") || "");
const [filter, setFilter] = useState("all");
const [active, setActive] = useState<SocialRosterMember | null>(null);
const [saved] = useLocalState<string[]>("saved-people", []);
const list = useMemo(
() =>
MOCK_ROSTER.filter((person) => {
const haystack =
`${person.name} ${person.city} ${person.title} ${person.tags.join(" ")} ${person.lookingFor}`.toLowerCase();
return (
haystack.includes(query.toLowerCase().trim()) &&
(filter !== "saved" || saved.includes(person.id)) &&
(filter !== "online" || person.online)
);
}),
[query, filter, saved],
);
return (
<SiteShell title="发现同类">
<PageIntro
eyebrow="PEOPLE WITHOUT BORDERS"
title="你的下一位朋友,"
accent="可能就在下一座城。"
description="按城市、技能或兴趣发现同类。先看看彼此的热爱,再让一句你好有一个自然的开始。"
/>
<div className="social-toolbar">
<SearchField
value={query}
onChange={setQuery}
label="搜索游民"
placeholder="城市、名字、技能、兴趣…"
/>
<div className="social-filters" aria-label="成员筛选">
{[
{ id: "all", title: "所有游民" },
{ id: "online", title: "演示在线" },
{ id: "saved", title: "我收藏的人" },
].map((f) => (
<button
key={f.id}
className={filter === f.id ? "active" : ""}
aria-pressed={filter === f.id}
onClick={() => setFilter(f.id)}
>
{f.title}
</button>
))}
</div>
</div>
<div className="social-section-label">
相遇,不必靠运气{" "}
<span>{list.length} 位成员展示 · 演示资料与在线状态</span>
</div>
<div className="social-member-grid">
{list.map((person) => (
<article key={person.id} className="social-member-card">
<div className="social-member-head">
<SocialAvatar src={person.avatar} size={51} lazy />
<div>
<h2>{person.name}</h2>
<p>{person.title}</p>
</div>
</div>
<div className="social-member-city">
<MapPin size={13} />
{person.city}
</div>
<p>{person.lookingFor}</p>
<div className="social-tags">
{person.tags.map((tag) => (
<span key={tag}>{tag}</span>
))}
</div>
<div className="social-card-actions">
<BookmarkButton
id={person.id}
collection="saved-people"
label="想认识"
/>
<button
type="button"
className="social-save"
onClick={() => setActive(person)}
>
查看名片 <ArrowUpRight size={14} />
</button>
</div>
</article>
))}
{!list.length && (
<EmptyState
title="同频的人,值得再找找"
description="试试「设计」「清迈」「出海」,或者清空筛选看看其他成员。"
>
<button
className="social-btn"
onClick={() => {
setQuery("");
setFilter("all");
}}
>
重置筛选
</button>
</EmptyState>
)}
</div>
<section className="social-panel social-discover-cta">
<Sparkles size={24} />
<div>
<h2>让别人也能认识你。</h2>
<p className="social-muted">
用一张游民名片,介绍你的城市、技能与好奇心。
</p>
</div>
<Link className="social-btn primary" href={socialPath("/roster")}>
创建我的名片 <ArrowUpRight size={15} />
</Link>
</section>
{active && (
<SocialDialog
title={`${active.name} 的游民名片`}
onClose={() => setActive(null)}
>
<div className="social-member-profile">
<SocialAvatar src={active.avatar} size={74} />
<div>
<strong>{active.name}</strong>
<p>{active.title}</p>
<span className="social-member-city">
<MapPin size={12} />
{active.city}
</span>
</div>
</div>
<div className="social-tags">
{active.tags.map((tag) => (
<span key={tag}>{tag}</span>
))}
</div>
<p>{active.bio}</p>
<p>
<strong>想认识:</strong>
{active.lookingFor}
</p>
<div className="social-status">
这是演示成员资料。可以带着一个破冰话题进入公开频道,认识真正参与聊天的人。
</div>
<div className="social-actions">
<Link
className="social-btn primary"
href={socialPath(
`/chat/general?intro=${encodeURIComponent(`大家好,我对${active.tags[0]}很感兴趣,有同样兴趣的朋友吗?`)}`,
)}
>
<MessageCircle size={15} />
去公开频道聊聊
</Link>
<BookmarkButton
id={active.id}
collection="saved-people"
label="想认识"
/>
<ShareButton
path={`/social/people?city=${encodeURIComponent(active.city.split("·")[0].trim())}`}
title={`在 ${active.city} 发现同类`}
/>
</div>
</SocialDialog>
)}
</SiteShell>
);
}