"use client"; import { useEffect, useRef, useState, type ReactNode } from "react"; import { ArrowUpRight, Check, Copy, Search, X } from "lucide-react"; import { useLocalState } from "@social/lib/useLocalState"; import { useSocialConfig } from "./SocialExperience"; import { usePathname } from "next/navigation"; export function PageIntro({ eyebrow, title, accent, description, children, }: { eyebrow: string; title: string; accent: string; description: string; children?: ReactNode; }) { const config = useSocialConfig(); const key = usePathname().split("/")[2] || "home"; const copy = config.copy.socialPages?.[key]; eyebrow = typeof copy?.eyebrow === "string" && copy.eyebrow.trim() ? copy.eyebrow : eyebrow; title = typeof copy?.title === "string" && copy.title.trim() ? copy.title : title; accent = typeof copy?.accent === "string" && copy.accent.trim() ? copy.accent : accent; description = typeof copy?.description === "string" && copy.description.trim() ? copy.description : description; return (
{eyebrow}

{title}
{accent}

{description}

{children}
); } export function SearchField({ value, onChange, placeholder, label = "搜索", }: { value: string; onChange: (v: string) => void; placeholder: string; label?: string; }) { return ( ); } export function BookmarkButton({ id, collection = "saved-items", label = "收藏", }: { id: string; collection?: string; label?: string; }) { const [items, setItems] = useLocalState(collection, []); const selected = Array.isArray(items) && items.includes(id); return ( ); } export function ShareButton({ path, title }: { path: string; title: string }) { const [state, setState] = useState(""); const timer = useRef | null>(null); useEffect( () => () => { if (timer.current) clearTimeout(timer.current); }, [], ); return ( ); } export function EmptyState({ title = "暂时没有找到", description = "换个关键词,或试试其他筛选。", children, }: { title?: string; description?: string; children?: ReactNode; }) { return (
✦

{title}

{description}

{children}
); } export function SocialDialog({ title, onClose, children, }: { title: string; onClose: () => void; children: ReactNode; }) { const ref = useRef(null); useEffect(() => { const dialog = ref.current; const opener = document.activeElement as HTMLElement; const overflow = document.body.style.overflow; dialog?.showModal(); document.body.style.overflow = "hidden"; return () => { dialog?.close(); document.body.style.overflow = overflow; opener?.focus(); }; }, []); return ( { event.preventDefault(); onClose(); }} onClick={(event) => { if (event.target === event.currentTarget) onClose(); }} >
MAKE A CONNECTION

{title}

{children}
); }