Add dedicated h5.css so group chat leads CTAs, orbit stays compact on phones, and composer/actions clear the bottom dock. Co-authored-by: Cursor <cursoragent@cursor.com>
612 lines
22 KiB
TypeScript
612 lines
22 KiB
TypeScript
"use client";
|
||
|
||
import { useEffect, useMemo, useState, type PointerEvent } from "react";
|
||
import Link from "next/link";
|
||
import SiteShell from "./SiteShell";
|
||
import JoinPayModal from "./JoinPayModal";
|
||
import AttractiveRoster from "./AttractiveRoster";
|
||
import ConnectionHero, { ConnectionWays } from "./ConnectionHero";
|
||
import FxBelt from "./FxBelt";
|
||
import SectionSpark from "./SectionSpark";
|
||
import CityDirectory from "./CityDirectory";
|
||
import SocialBrandLogo from "./SocialBrandLogo";
|
||
import SocialAvatar from "./SocialAvatar";
|
||
import {
|
||
ArrowUpRight,
|
||
BookOpen,
|
||
Heart,
|
||
Radio,
|
||
Sparkles,
|
||
} from "lucide-react";
|
||
import { TEAM_KIND_LABEL, SEED_EBOOKS, SEED_VIDEOS } from "@social/lib/seed";
|
||
import { resolveSocialCatalog } from "@social/lib/resolveCatalog";
|
||
import { socialPath } from "@social/lib/socialPath";
|
||
import { useRemoteConfig } from "~/lib/use-remote-config";
|
||
import { resolveSocialLandingCopy } from "@social/lib/landing";
|
||
import { MOCK_ROSTER } from "@social/lib/rosterMock";
|
||
|
||
const DEFAULT_PROMO =
|
||
"https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerEscapes.mp4";
|
||
|
||
const PATH = [
|
||
{ href: "#people", label: "想见的人", emoji: "👋" },
|
||
{ href: "#date", label: "认识一下", emoji: "💕" },
|
||
{ href: "#meetup", label: "聊得来", emoji: "📡" },
|
||
{ href: "#cities", label: "见一面", emoji: "🌆" },
|
||
{ href: "#team", label: "一起做事", emoji: "🚀" },
|
||
{ href: "/chat", label: "群聊", emoji: "💬", external: true },
|
||
] as const;
|
||
|
||
const ROLE_EMOJI: Record<string, string> = {
|
||
volunteer: "🙋",
|
||
parttime: "📝",
|
||
fulltime: "💼",
|
||
};
|
||
|
||
export default function HomeClient() {
|
||
const { config } = useRemoteConfig();
|
||
const [joinOpen, setJoinOpen] = useState(false);
|
||
const [activeSection, setActiveSection] = useState("people");
|
||
const promoUrl =
|
||
config.copy.socialPromoUrl?.trim() ||
|
||
(
|
||
config.modules?.social as { promoVideoUrl?: string } | undefined
|
||
)?.promoVideoUrl?.trim() ||
|
||
DEFAULT_PROMO;
|
||
const landingCopy = resolveSocialLandingCopy(config.copy);
|
||
const catalog = useMemo(
|
||
() => resolveSocialCatalog(config.copy.socialCatalogs),
|
||
[config.copy.socialCatalogs],
|
||
);
|
||
const meetups = catalog.meetups;
|
||
const gigs = catalog.gigs;
|
||
const datePreview = MOCK_ROSTER.filter((m) => m.online).slice(0, 3);
|
||
|
||
useEffect(() => {
|
||
const root = document.querySelector(".social-home");
|
||
if (!root) return;
|
||
const observer = new IntersectionObserver(
|
||
(entries) =>
|
||
entries.forEach((e) => {
|
||
if (e.isIntersecting) {
|
||
e.target.classList.add("visible");
|
||
observer.unobserve(e.target);
|
||
}
|
||
}),
|
||
{ threshold: 0.06, rootMargin: "0px 0px -24px 0px" },
|
||
);
|
||
const scan = () => {
|
||
root
|
||
.querySelectorAll(".reveal:not(.visible)")
|
||
.forEach((el) => observer.observe(el));
|
||
};
|
||
scan();
|
||
root.setAttribute("data-home-motion", "ready");
|
||
const t = window.setTimeout(scan, 400);
|
||
return () => {
|
||
window.clearTimeout(t);
|
||
observer.disconnect();
|
||
root.removeAttribute("data-home-motion");
|
||
};
|
||
}, []);
|
||
|
||
useEffect(() => {
|
||
const root = document.querySelector(".social-home");
|
||
if (!root) return;
|
||
const observer = new IntersectionObserver(
|
||
(entries) => {
|
||
entries.forEach((entry) => {
|
||
if (entry.isIntersecting) setActiveSection(entry.target.id);
|
||
});
|
||
},
|
||
{ rootMargin: "-25% 0px -55% 0px", threshold: 0 },
|
||
);
|
||
root
|
||
.querySelectorAll("section[id]:not(#hero)")
|
||
.forEach((section) => observer.observe(section));
|
||
return () => observer.disconnect();
|
||
}, []);
|
||
|
||
const onPanelPointerMove = (event: PointerEvent<HTMLDivElement>) => {
|
||
if (event.pointerType !== "mouse") return;
|
||
const panel = (event.target as Element).closest<HTMLElement>(
|
||
".social-panel",
|
||
);
|
||
if (!panel) return;
|
||
const rect = panel.getBoundingClientRect();
|
||
panel.style.setProperty("--spot-x", `${event.clientX - rect.left}px`);
|
||
panel.style.setProperty("--spot-y", `${event.clientY - rect.top}px`);
|
||
};
|
||
|
||
return (
|
||
<div
|
||
className="home-flow social-flow social-fx social-home"
|
||
onPointerMove={onPanelPointerMove}
|
||
>
|
||
<div className="social-fx-orbs" aria-hidden>
|
||
<i className="social-fx-orb o1" />
|
||
<i className="social-fx-orb o2" />
|
||
<i className="social-fx-orb o3" />
|
||
</div>
|
||
<SiteShell home onJoin={() => setJoinOpen(true)}>
|
||
<div className="connection-scroll-progress" aria-hidden="true" />
|
||
<main id="social-main">
|
||
<ConnectionHero
|
||
onJoin={() => setJoinOpen(true)}
|
||
promoUrl={promoUrl}
|
||
copy={landingCopy}
|
||
/>
|
||
<ConnectionWays copy={landingCopy} />
|
||
|
||
<nav className="social-path" aria-label="本页导航">
|
||
<div className="container">
|
||
<div className="social-path-track reveal">
|
||
{PATH.map((p) => {
|
||
const external = "external" in p && p.external;
|
||
const href = external ? socialPath(p.href) : p.href;
|
||
if (external) {
|
||
return (
|
||
<Link
|
||
key={p.href}
|
||
href={href}
|
||
className="social-path-link"
|
||
>
|
||
<span className="social-path-emoji" aria-hidden>
|
||
{p.emoji}
|
||
</span>
|
||
{p.label}
|
||
</Link>
|
||
);
|
||
}
|
||
return (
|
||
<a
|
||
key={p.href}
|
||
href={href}
|
||
className="social-path-link"
|
||
aria-current={
|
||
activeSection === p.href.slice(1)
|
||
? "location"
|
||
: undefined
|
||
}
|
||
>
|
||
<span className="social-path-emoji" aria-hidden>
|
||
{p.emoji}
|
||
</span>
|
||
{p.label}
|
||
</a>
|
||
);
|
||
})}
|
||
</div>
|
||
</div>
|
||
</nav>
|
||
|
||
<AttractiveRoster onJoin={() => setJoinOpen(true)} />
|
||
|
||
<section
|
||
className="section section-compact social-section-alt"
|
||
id="date"
|
||
aria-label="认识一下"
|
||
>
|
||
<div className="container">
|
||
<div className="social-date-hero reveal is-alive">
|
||
<div className="social-date-hero-copy">
|
||
<span className="section-tag">
|
||
<span>认识一下</span>
|
||
<span>左右滑</span>
|
||
</span>
|
||
<h2>
|
||
<span className="social-title-emoji" aria-hidden>
|
||
💕
|
||
</span>
|
||
一张一张认识新朋友
|
||
</h2>
|
||
<p>
|
||
像翻相册一样:不感兴趣就划走,想认识就留下。
|
||
记在你这边,之后再决定要不要打招呼。
|
||
</p>
|
||
<ul className="social-date-hero-steps">
|
||
<li>
|
||
<em>←</em> 划走
|
||
</li>
|
||
<li>
|
||
<em>→</em> 想认识
|
||
</li>
|
||
<li>
|
||
<em>♥</em> 稍后打招呼
|
||
</li>
|
||
</ul>
|
||
<div className="social-date-stage-acts">
|
||
<Link
|
||
className="btn btn-primary"
|
||
href={socialPath("/date")}
|
||
>
|
||
开始认识
|
||
<ArrowUpRight size={16} />
|
||
</Link>
|
||
<Link
|
||
className="btn btn-ghost"
|
||
href={socialPath("/people")}
|
||
>
|
||
先浏览大家
|
||
</Link>
|
||
</div>
|
||
</div>
|
||
<Link
|
||
href={socialPath("/date")}
|
||
className="social-date-hero-deck"
|
||
aria-label="开始认识"
|
||
>
|
||
{datePreview.map((m, i) => (
|
||
<div
|
||
key={m.id}
|
||
className={`social-date-hero-card social-date-hero-card-${i}`}
|
||
style={{
|
||
["--i" as string]: i,
|
||
backgroundImage: `linear-gradient(180deg, transparent 35%, #0a0a0ef2 88%), url(${m.avatar})`,
|
||
}}
|
||
>
|
||
{m.online ? (
|
||
<span className="social-date-hero-online">在线</span>
|
||
) : null}
|
||
<div className="social-date-hero-meta">
|
||
<strong>
|
||
{m.name}
|
||
<small>{m.title}</small>
|
||
</strong>
|
||
<em>{m.city.split("·")[0].trim()}</em>
|
||
<p>{m.lookingFor}</p>
|
||
<div className="social-date-card-tags">
|
||
{m.tags.slice(0, 2).map((t) => (
|
||
<span key={t}>{t}</span>
|
||
))}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
))}
|
||
<span className="social-date-hero-cta">
|
||
<Heart size={14} /> 点这里开始滑
|
||
</span>
|
||
</Link>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
<FxBelt />
|
||
|
||
<section
|
||
className="section section-compact social-section-alt"
|
||
id="meetup"
|
||
aria-label="开视频聊聊"
|
||
>
|
||
<div className="container">
|
||
<div className="section-header reveal">
|
||
<SectionSpark label="meetup" />
|
||
<span className="section-tag">
|
||
<span>聊天群组</span>
|
||
<span>语音 · 视频</span>
|
||
</span>
|
||
<h2>
|
||
<span className="social-title-emoji" aria-hidden>
|
||
📡
|
||
</span>
|
||
{landingCopy.socialOnlineTitle}
|
||
</h2>
|
||
<p>
|
||
先进聊天群组热热身,再开语音或视频见面。
|
||
「想参加」会先记在你这边。
|
||
</p>
|
||
</div>
|
||
<div className="social-panel-grid social-panel-grid-2">
|
||
{meetups.map((m, i) => (
|
||
<article
|
||
key={m.id}
|
||
className={`social-panel social-panel-fx reveal${i === 0 ? " is-accent" : ""}`}
|
||
style={{ ["--stagger" as string]: `${i * 80}ms` }}
|
||
>
|
||
<div
|
||
className="connection-meetup-art is-live"
|
||
aria-hidden="true"
|
||
>
|
||
<span className="connection-meetup-number">
|
||
0{i + 1}
|
||
</span>
|
||
<div className="connection-audio-bars">
|
||
{Array.from({ length: 14 }, (_, n) => (
|
||
<i
|
||
key={n}
|
||
style={{
|
||
height: `${12 + ((n * 17 + i * 13) % 48)}px`,
|
||
animationDelay: `${n * -0.15}s`,
|
||
}}
|
||
/>
|
||
))}
|
||
</div>
|
||
<div className="social-video-grid">
|
||
{MOCK_ROSTER.slice(i, i + 4).map((p) => (
|
||
<span key={p.id} className="social-video-tile">
|
||
<SocialAvatar src={p.avatar} size={36} lazy />
|
||
</span>
|
||
))}
|
||
</div>
|
||
<Radio size={22} strokeWidth={1.3} />
|
||
</div>
|
||
<div className="social-panel-meta">
|
||
<span>
|
||
{m.city === "Online" ? "群组 · 语音视频" : m.city}
|
||
</span>
|
||
<time>
|
||
{m.date} · {m.time}
|
||
</time>
|
||
</div>
|
||
<div className="social-meetup-faces" aria-hidden>
|
||
{MOCK_ROSTER.slice(i + 1, i + 5).map((p) => (
|
||
<SocialAvatar key={p.id} src={p.avatar} size={24} lazy />
|
||
))}
|
||
<em>+{6 + i} 想参加</em>
|
||
</div>
|
||
<h3>{m.title}</h3>
|
||
<p>群里打个招呼 → 开麦 / 开视频 → 认识新朋友</p>
|
||
<Link
|
||
className="btn btn-primary btn-sm"
|
||
href={socialPath(`/meetup/${m.id}`)}
|
||
>
|
||
进入聊聊
|
||
<ArrowUpRight size={14} />
|
||
</Link>
|
||
</article>
|
||
))}
|
||
</div>
|
||
<div className="social-section-actions reveal">
|
||
<Link href={socialPath("/meetup")} className="btn btn-ghost">
|
||
看看全部
|
||
</Link>
|
||
<Link href={socialPath("/chat")} className="btn btn-ghost">
|
||
文字群聊
|
||
</Link>
|
||
<button
|
||
type="button"
|
||
className="btn btn-ghost"
|
||
onClick={() => setJoinOpen(true)}
|
||
>
|
||
加入社区
|
||
</button>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
<FxBelt />
|
||
|
||
<section
|
||
className="section section-compact"
|
||
id="cities"
|
||
aria-label="同城见一面"
|
||
>
|
||
<div className="container">
|
||
<div className="section-header reveal">
|
||
<SectionSpark label="cities" />
|
||
<span className="section-tag">
|
||
<span>挑一座城</span>
|
||
<span>再出来见面</span>
|
||
</span>
|
||
<h2>
|
||
<span className="social-title-emoji" aria-hidden>
|
||
🌆
|
||
</span>
|
||
{landingCopy.socialOfflineTitle}
|
||
</h2>
|
||
<p>
|
||
认识了、聊过之后,出来见一面会更自然。
|
||
先挑一座城市,再找适合见面的咖啡馆。
|
||
</p>
|
||
</div>
|
||
<CityDirectory compact limit={8} />
|
||
<div className="social-section-actions reveal">
|
||
<Link
|
||
href={socialPath("/coffeechat")}
|
||
className="btn btn-primary"
|
||
>
|
||
看看咖啡馆
|
||
</Link>
|
||
<Link href={socialPath("/people")} className="btn btn-ghost">
|
||
找同城的人
|
||
</Link>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
<FxBelt />
|
||
|
||
<section
|
||
className="section section-compact social-section-alt"
|
||
id="team"
|
||
aria-label="一起做点事"
|
||
>
|
||
<div className="container">
|
||
<div className="section-header reveal">
|
||
<SectionSpark label="team" />
|
||
<span className="section-tag">
|
||
<span>找搭子</span>
|
||
<span>共创</span>
|
||
</span>
|
||
<h2>
|
||
<span className="social-title-emoji" aria-hidden>
|
||
🚀
|
||
</span>
|
||
{landingCopy.socialTeamTitle}
|
||
</h2>
|
||
<p>
|
||
有人在找帮手;也有人一起写小册、拍视频做共创。
|
||
点卡片看看详情,合适再表达兴趣。
|
||
</p>
|
||
</div>
|
||
|
||
<div className="social-together-tabs reveal" role="tablist">
|
||
<Link
|
||
href={socialPath("/team")}
|
||
className="is-on"
|
||
role="tab"
|
||
aria-selected="true"
|
||
>
|
||
找搭子
|
||
</Link>
|
||
<Link href={socialPath("/ebook")} role="tab" aria-selected="false">
|
||
共创
|
||
</Link>
|
||
</div>
|
||
|
||
<div className="social-panel-grid social-panel-grid-3">
|
||
{gigs.slice(0, 3).map((g, i) => (
|
||
<Link
|
||
key={g.id}
|
||
href={socialPath(`/team#${g.id}`)}
|
||
className="social-panel social-panel-fx connection-team reveal is-clickable"
|
||
style={{ ["--stagger" as string]: `${i * 60}ms` }}
|
||
>
|
||
<div className="social-panel-ico" aria-hidden>
|
||
{ROLE_EMOJI[g.kind || "parttime"] || "📝"}
|
||
</div>
|
||
<div className="social-panel-meta">
|
||
<span>{TEAM_KIND_LABEL[g.kind || "parttime"]}</span>
|
||
<span>{g.remote ? "线上也能做" : "可以见面做"}</span>
|
||
</div>
|
||
<h3>{g.title}</h3>
|
||
<p>{g.pay}</p>
|
||
<div className="social-panel-foot">
|
||
{(g.tags || []).slice(0, 3).map((t) => (
|
||
<span key={t}>{t}</span>
|
||
))}
|
||
</div>
|
||
</Link>
|
||
))}
|
||
</div>
|
||
|
||
<div className="social-ugc-row reveal">
|
||
{SEED_EBOOKS.slice(0, 2).map((book) => (
|
||
<Link
|
||
key={book.id}
|
||
href={socialPath("/ebook")}
|
||
className="social-ugc-card"
|
||
>
|
||
<span className="social-ugc-ico" aria-hidden>
|
||
<BookOpen size={20} />
|
||
</span>
|
||
<div>
|
||
<em>共创 · 小册</em>
|
||
<strong>{book.title}</strong>
|
||
<p>{book.blurb}</p>
|
||
</div>
|
||
<ArrowUpRight size={16} />
|
||
</Link>
|
||
))}
|
||
{SEED_VIDEOS.slice(0, 2).map((vid) => (
|
||
<Link
|
||
key={vid.id}
|
||
href={socialPath("/videos")}
|
||
className="social-ugc-card is-video"
|
||
>
|
||
<span className="social-ugc-ico" aria-hidden>
|
||
{vid.coverEmoji}
|
||
</span>
|
||
<div>
|
||
<em>共创 · 视频</em>
|
||
<strong>{vid.title}</strong>
|
||
<p>
|
||
{vid.city} · {vid.minutes} 分钟
|
||
</p>
|
||
</div>
|
||
<ArrowUpRight size={16} />
|
||
</Link>
|
||
))}
|
||
</div>
|
||
|
||
<div className="social-section-actions reveal">
|
||
<Link href={socialPath("/team")} className="btn btn-ghost">
|
||
更多机会
|
||
</Link>
|
||
<Link href={socialPath("/ebook")} className="btn btn-ghost">
|
||
逛共创
|
||
</Link>
|
||
<button
|
||
type="button"
|
||
className="btn btn-ghost"
|
||
onClick={() => setJoinOpen(true)}
|
||
>
|
||
加入社区
|
||
</button>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
<section
|
||
className="connection-invite container"
|
||
aria-label="加入社区"
|
||
>
|
||
<div className="connection-invite-orbit" aria-hidden="true">
|
||
<span />
|
||
<span />
|
||
<Sparkles size={52} strokeWidth={1} />
|
||
</div>
|
||
<div>
|
||
<span className="connection-eyebrow">加入社区</span>
|
||
<h2>{landingCopy.socialInviteTitle}</h2>
|
||
<p>{landingCopy.socialInviteLead}</p>
|
||
</div>
|
||
<button
|
||
type="button"
|
||
className="btn connection-join"
|
||
onClick={() => setJoinOpen(true)}
|
||
>
|
||
加入游民社区 <ArrowUpRight size={19} />
|
||
</button>
|
||
</section>
|
||
</main>
|
||
|
||
<footer className="footer">
|
||
<div className="container">
|
||
<div className="footer-grid footer-grid-rings">
|
||
<div className="footer-brand">
|
||
<SocialBrandLogo />
|
||
<p>认识同频的人 · 开视频聊聊 · 出来见一面 · 一起做点事</p>
|
||
</div>
|
||
<div className="footer-links">
|
||
<h4>认识人</h4>
|
||
<button
|
||
type="button"
|
||
className="social-footer-link"
|
||
onClick={() => setJoinOpen(true)}
|
||
>
|
||
加入社区
|
||
</button>
|
||
<Link href={socialPath("/people")}>想见的人</Link>
|
||
<Link href={socialPath("/date")}>认识一下</Link>
|
||
<Link href={socialPath("/meetup")}>开视频聊聊</Link>
|
||
<Link href={socialPath("/chat")}>大家聊天</Link>
|
||
</div>
|
||
<div className="footer-links">
|
||
<h4>见面 · 做事</h4>
|
||
<Link href={socialPath("/coffeechat")}>找城市见面</Link>
|
||
<Link href={socialPath("/team")}>找搭子做事</Link>
|
||
<Link href={socialPath("/ebook")}>共创</Link>
|
||
<Link href={socialPath("/feedback")}>说说想法</Link>
|
||
</div>
|
||
<div className="footer-links">
|
||
<h4>更多</h4>
|
||
<Link href="/">门户首页</Link>
|
||
<Link href="/community">旅居社群</Link>
|
||
<Link href="/book">数字游民小册</Link>
|
||
</div>
|
||
</div>
|
||
<div className="footer-bottom">
|
||
<p suppressHydrationWarning>
|
||
© {new Date().getFullYear()} nomadro · 游民社区
|
||
</p>
|
||
</div>
|
||
</div>
|
||
</footer>
|
||
</SiteShell>
|
||
|
||
<JoinPayModal open={joinOpen} onClose={() => setJoinOpen(false)} />
|
||
</div>
|
||
);
|
||
}
|