nomadro/src/modules/social/components/HomeClient.tsx
Eric e177b50d2e ARCHIVE test12 Codex social overhaul — NEVER DEPLOY to .com/.cn.
Freeze experimental social/admin UX on test12 for reference only; see docs/archive/test12-NEVER-DEPLOY.md.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-05 19:22:12 +08:00

113 lines
17 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 { useRouter } from "next/navigation";
import { ArrowDown, ArrowRight, ArrowUpRight, BookOpen, Check, Coffee, Compass, Globe2, HeartHandshake, MapPin, MessageCircle, Radio, Search, Sparkles, Users, Waves } from "lucide-react";
import SiteShell from "./SiteShell";
import SocialAvatar from "./SocialAvatar";
import HomeActionRail from "./HomeActionRail";
import { SocialFooter } from "./SocialNavigation";
import { useSocialConfig } from "./SocialExperience";
import { useSocialI18n } from "@social/lib/useSocialI18n";
import { useDiscoveryRoster } from "@social/lib/discoveryRoster";
import { resolveSocialCatalog } from "@social/lib/resolveCatalog";
import { resolveSocialLandingCopy } from "@social/lib/landing";
import { experiencePage, homeSectionVisible, navigationVisible, safeCommunityHref } from "@social/lib/experience";
import { SOCIAL_CITIES } from "@social/lib/cities";
import { socialPath } from "@social/lib/socialPath";
import { openSocialJoinModal } from "@social/lib/joinModal";
import { setRosterLike, useRosterLikes } from "@social/lib/useRosterLikes";
export default function HomeClient() {
const config = useSocialConfig();
const { t, tx, locale } = useSocialI18n();
const router = useRouter();
const roster = useDiscoveryRoster();
const likes = useRosterLikes();
const [query, setQuery] = useState("");
const [city, setCity] = useState("");
const landing = resolveSocialLandingCopy(config.copy, locale);
const copy = experiencePage(config, locale, "home");
const catalog = useMemo(() => resolveSocialCatalog(config.copy.socialCatalogs), [config.copy.socialCatalogs]);
const announcement = config.copy.socialExperience?.announcement;
const announceText = announcement?.[locale];
const visible = (key: string) => homeSectionVisible(config, key);
const cities = useMemo(() => {
const ids = config.copy.socialExperience?.featuredCityIds;
return (ids?.length ? ids.map(id => SOCIAL_CITIES.find(c => c.id === id)).filter(c => c != null) : SOCIAL_CITIES.filter(c => ["chiangmai", "dali", "bali", "lisbon"].includes(c.id))).slice(0, 4);
}, [config.copy.socialExperience?.featuredCityIds]);
const people = roster.filter(p => !city || p.city.includes(city)).slice(0, 4);
const openJoin = () => openSocialJoinModal({ reason: "cta" });
const sectionHead = (number: string, eyebrow: string, title: string, description: string, href: string, label: string) => <div className="community-section-head"><div><p className="community-kicker"><span>{number}</span>{eyebrow}</p><h2>{title}</h2><p>{description}</p></div><Link className="community-text-link" href={socialPath(href)}>{label}<ArrowUpRight size={17} /></Link></div>;
return <div className="social-home social-flow community-home">
<SiteShell home>
<main id="social-main">
{announcement?.enabled && announceText && <a className="community-announcement" href={safeCommunityHref(announcement.href)}><Sparkles size={14} /><span>{announceText}</span><ArrowRight size={14} /></a>}
<section className="community-hero" aria-labelledby="community-home-title">
<div className="container community-hero-layout">
<div className="community-hero-copy">
<p className="community-kicker"><span className="community-signal" />{copy.eyebrow || landing.socialEyebrow}</p>
<h1 id="community-home-title">{copy.title || tx("世界很大,", "A big world.")}<br /><span>{copy.accent || tx("同频的人不远。", "Your kind of people.")}</span></h1>
<p className="community-hero-lead">{copy.description || tx("换一座城市,不必重新孤独。从一句你好、一杯咖啡开始,找到一起探索、一起创造的人。", "A new city doesn’t have to mean starting over alone. Find your people through a hello, a coffee, or something you build together.")}</p>
<form className="community-hero-search" role="search" onSubmit={event => { event.preventDefault(); router.push(socialPath(`/people${query.trim() ? `?q=${encodeURIComponent(query.trim())}` : ""}`)); }}><Search size={19} /><input type="search" aria-label={tx("搜索城市、兴趣或朋友", "Search cities, interests or people")} placeholder={tx("你在哪座城?想认识什么样的人?", "A city, an interest, your kind of people…")} value={query} onChange={event => setQuery(event.target.value)} /><button type="submit" aria-label={tx("发现同频", "Find your people")}><ArrowRight size={20} /></button></form>
<div className="community-hero-actions"><Link className="social-btn primary" href={socialPath("/people")}>{tx("认识同频的人", "Find your people")}<ArrowUpRight size={17} /></Link><Link className="community-text-link" href={socialPath("/chat")}><MessageCircle size={17} />{tx("先打个招呼", "Just say hello")}</Link></div>
<div className="community-hero-note"><span className="community-mini-avatars">{roster.slice(0, 4).map(person => <SocialAvatar key={person.id} src={person.avatar} faceOk={person.faceOk} size={28} />)}</span><span>{tx("自由职业者、远程工作者和路上的你", "For freelancers, remote workers and the curious")}</span></div>
</div>
<div className="community-world" aria-label={tx("从线上问候,到真实相遇", "From a hello online to a real connection")}>
<div className="community-world-grid" aria-hidden />
<div className="community-world-orbit orbit-one" aria-hidden /><div className="community-world-orbit orbit-two" aria-hidden /><div className="community-world-orbit orbit-three" aria-hidden />
<div className="community-world-center"><Globe2 size={82} strokeWidth={.65} /><span>same wavelength.</span><small>DIFFERENT COORDINATES</small></div>
{roster.slice(0, 3).map((person, index) => <Link key={person.id} href={socialPath(`/people/${person.id}`)} className={`community-world-person person-${index}`}><SocialAvatar src={person.avatar} size={44} faceOk={person.faceOk} /><span><strong>{person.name}{person.example && <span className="people-card-example">{tx("示例", "Example")}</span>}</strong><small><MapPin size={11} />{person.city.split("·")[0].trim()}</small></span><ArrowUpRight size={14} /></Link>)}
<Link className="community-world-coffee" href={socialPath("/coffeechat")}><span><Coffee size={22} /></span><div><strong>{tx("下一杯咖啡,和新朋友。", "Your next coffee. A new friend.")}</strong><small>{tx("给真实的相遇留点时间", "Make a little room for connection")}</small></div><ArrowUpRight size={16} /></Link>
<div className="community-world-caption"><span><Waves size={14} />{tx("连接,不受坐标限制", "Connection goes beyond coordinates")}</span><span>01 — 03</span></div>
</div>
</div>
<div className="container community-hero-foot"><a href="#discover"><ArrowDown size={14} />{tx("找到你的打开方式", "Find your way in")}</a><span>{tx("认识人 / 见一面 / 一起做事", "MEET PEOPLE / MEET IN PERSON / BUILD TOGETHER")}</span></div>
</section>
{visible("discover") && <div id="discover"><HomeActionRail /></div>}
{visible("people") && navigationVisible(config, "/people") && <section className="container community-section" id="people">
{sectionHead("01", tx("认识人", "FIND YOUR PEOPLE"), tx("下一句你好,从这里开始。", "Your next hello starts here."), tx("先看看介绍,发现共同兴趣。认识一个人,可以慢慢来。", "A shared interest, a familiar city. Good conversations begin with a little curiosity."), "/people", tx("认识更多朋友", "Explore people"))}
<div className="community-city-filters" role="group" aria-label={tx("按城市看朋友", "Find people by city")}>{["", ...Array.from(new Set(roster.map(p => p.city.split("·")[0].trim()))).slice(0, 5)].map(name => <button key={name} type="button" aria-pressed={city === name} onClick={() => setCity(name)}>{name ? tx(name) : tx("所有城市", "Everywhere")}</button>)}</div>
<div className="community-people-grid">{people.map(person => <article className="community-person-card" key={person.id}><div className="community-person-top"><SocialAvatar src={person.avatar} faceOk={person.faceOk} size={56} lazy /><button type="button" className="community-follow" aria-pressed={Boolean(likes[person.id])} aria-label={likes[person.id] ? tx(`取消关注 ${person.name}`, `Unfollow ${person.name}`) : tx(`关注 ${person.name}`, `Follow ${person.name}`)} onClick={() => setRosterLike(person.id, !likes[person.id])}>{likes[person.id] ? <Check size={17} /> : <Users size={17} />}</button></div><Link href={socialPath(`/people/${person.id}`)}><h3>{person.name}{person.example && <span className="people-card-example">{tx("示例", "Example")}</span>}</h3><p className="community-person-title">{tx(person.title)}</p><span className="community-person-city"><MapPin size={12} />{tx(person.city)}</span><p className="community-person-want">{tx(person.lookingFor)}</p><span className="community-person-tags">{person.tags.slice(0, 2).map(tag => <span key={tag}>{tx(tag)}</span>)}</span><span className="community-person-link">{tx("看看介绍", "Get to know them")}<ArrowUpRight size={15} /></span></Link></article>)}</div>
<p className="community-data-note">{tx("标注「示例」的资料用于体验浏览;真实成员以公开资料为准。关注保存在当前设备。", "Profiles marked “Example” let you explore the experience. Real members appear with their published details. Follows stay on this device.")} <Link href={socialPath("/roster")}>{tx("写下我的介绍", "Add your introduction")}<ArrowUpRight size={12} /></Link></p>
</section>}
{visible("cities") && navigationVisible(config, "/places") && <section className="community-cities-section" id="cities"><div className="container community-section">
{sectionHead("02", tx("见一面", "TAKE IT OFFLINE"), tx("让陌生的城市,变熟悉。", "New city. Familiar feeling."), tx("找一家好咖啡馆,约一段有空的时间,把线上认识变成真实相遇。", "Discover a city, find your coffee spot, and make time to meet someone new."), "/places", tx("探索所有城市", "Explore cities"))}
<div className="community-city-grid">{cities.map(item => <Link key={item.id} className="community-city-card" href={socialPath(`/places/${item.id}`)}><div className="community-city-image" style={item.cover ? { backgroundImage: `url(${item.cover})` } : undefined}><span>{item.emoji} {tx(item.country)}</span><ArrowUpRight size={19} /></div><div><h3>{tx(item.name)}</h3><p>{tx(item.vibe)}</p></div></Link>)}</div>
<div className="community-coffee-band"><span className="community-band-icon"><Coffee size={27} strokeWidth={1.5} /></span><div><h3>{tx("一杯咖啡的时间,刚刚好。", "A coffee’s worth of time. A world of possibility.")}</h3><p>{tx("看看主理人的话题和可预约时间,找到聊得来的那个人。", "Find a host, pick a topic, and choose a time that works for you.")}</p></div><Link className="social-btn" href={socialPath("/coffeechat")}>{tx("约杯咖啡", "Find a coffee chat")}<ArrowUpRight size={16} /></Link></div>
</div></section>}
{visible("meetup") && navigationVisible(config, "/meetup") && <section className="container community-section" id="meetup">
{sectionHead("03", tx("聊得来", "BETTER CONVERSATIONS"), tx("隔着屏幕,也能聊得很近。", "Different places. Same conversation."), tx("文字、声音或视频,选择让你舒服的方式。", "A message, a voice, a face. Connect in a way that feels like you."), "/meetup", tx("探索语音厅", "Explore lounges"))}
<div className="community-conversation-grid"><Link className="community-chat-feature" href={socialPath("/chat")}><span className="community-feature-mark"><MessageCircle size={25} /></span><p className="community-kicker">OPEN CONVERSATION</p><h3>{tx("在路上,也有个地方聊聊。", "A place to talk, wherever you are.")}</h3><p>{tx("聊城市、聊近况、问个小问题。从公开聊天开始认识彼此。", "Talk cities, share a little of your day, ask a question. Start in the community chat.")}</p><span className="community-feature-link">{tx("进入聊天群", "Join the conversation")}<ArrowUpRight size={17} /></span><div className="community-chat-bubbles" aria-hidden><span>{tx("大家最近在哪座城?", "Where’s everyone these days?")}</span><span>{tx("下一站,想去看看海。", "Somewhere by the sea next.")} 🌊</span></div></Link>
<div className="community-lounge-list">{catalog.meetups.slice(0, 3).map((event, index) => <Link key={event.id} href={socialPath(`/meetup/${event.id}`)}><span className="community-lounge-icon"><Radio size={21} /></span><div><small>{tx("语音 · 视频", "VOICE · VIDEO")} / 0{index + 1}</small><h3>{tx(event.title)}</h3><p>{event.city === "Online" ? tx("线上相聚", "Meet online") : tx(event.city)} · {event.date || tx("时间待确认", "Schedule to follow")}</p></div><ArrowUpRight size={18} /></Link>)}<p className="community-data-note">{tx("进入后可自行选择麦克风与摄像头。", "Choose your microphone and camera settings when you join.")}</p></div>
</div>
</section>}
{visible("collaborate") && <section className="container community-section" id="team">
{sectionHead("04", tx("一起做事", "MAKE SOMETHING TOGETHER"), tx("有些想法,适合一起实现。", "Some ideas are better together."), tx("从互换一项技能,到一起完成一个项目。把同频变成同行。", "Exchange a skill. Find a collaborator. Turn a shared spark into something real."), "/team", tx("发现共创机会", "Find collaborators"))}
<div className="community-build-grid">{[
{ href: "/skills", Icon: HeartHandshake, title: tx("你擅长的,刚好是我需要的。", "Your strength. Someone’s next step."), text: tx("技能交换", "Skill exchange"), description: tx("提供你的擅长,也找到愿意分享的人。", "Share what you do well. Learn from someone new."), tone: "mint" },
{ href: "/work", Icon: Sparkles, title: tx("把「有空一起」变成进行中。", "Make “someday” a work in progress."), text: tx("远程协作", "Work together"), description: tx("用看板梳理任务,用文档记录共同的想法。", "Find momentum with boards and shared notes."), tone: "coral" },
{ href: "/ebook", Icon: BookOpen, title: tx("走过的路,也能照亮别人。", "A story worth passing on."), text: tx("社区共创", "Community creations"), description: tx("读一份经验小册,分享一个属于你的故事。", "Explore guides, share stories and create together."), tone: "amber" },
].filter(item => navigationVisible(config, item.href)).map(item => <Link key={item.href} className={`community-build-card ${item.tone}`} href={socialPath(item.href)}><item.Icon size={29} strokeWidth={1.4} /><span>{item.text}</span><h3>{item.title}</h3><p>{item.description}</p><ArrowUpRight size={20} /></Link>)}</div>
</section>}
{visible("faq") && <section className="container community-faq" id="faq"><div><p className="community-kicker">A LITTLE GOOD TO KNOW</p><h2>{tx("来之前,你可能想知道。", "A few things you might be wondering.")}</h2><Link className="community-text-link" href={socialPath("/feedback")}>{tx("还有问题?聊聊想法", "Something else on your mind?")}<ArrowUpRight size={16} /></Link></div><div>{[
[tx("还不是数字游民,也可以加入吗?", "Can I join if I’m not a digital nomad?"), tx("当然。正在远程工作、自由职业、计划出发,或只是对这种生活好奇,都可以先浏览社区,找到感兴趣的话题和朋友。", "Absolutely. Whether you work remotely, freelance, are planning a change, or are simply curious, explore the community and find a conversation that interests you.")],
[tx("第一次来,怎么开始认识人?", "Where should I start?"), tx("先写一段介绍,再按城市和兴趣看看大家。可以在公开聊天群打招呼,也可以选择一个咖啡聊主理人,查看时间后再预约。", "Add a short introduction, then browse people by city or interest. Say hello in the community chat, or explore coffee hosts and their available times.")],
[tx("我的位置和联系方式会公开吗?", "Will my location and contact details be public?"), tx("地图以城市为单位展示,不需要公开精确位置。发布介绍前请检查内容,只分享你愿意公开的信息。线下见面优先选择公共场所。", "The map works at city level. You don’t need to share an exact location. Review your introduction before publishing and only share what you’re comfortable making public. Choose public places for a first meeting.")],
].map(([question, answer]) => <details key={question}><summary>{question}<span aria-hidden>+</span></summary><p>{answer}</p></details>)}</div></section>}
<section className="container community-invite"><div><span className="community-kicker">YOUR NEXT CHAPTER</span><h2>{landing.socialInviteTitle}</h2><p>{landing.socialInviteLead}</p></div><button className="social-btn primary" type="button" onClick={openJoin}>{t.joinCommunity}<ArrowUpRight size={18} /></button><Compass className="community-invite-compass" size={190} strokeWidth={.5} aria-hidden /></section>
</main>
<SocialFooter />
</SiteShell>
</div>;
}