Polish social discovery: intent guide on home, richer people filters/cards, and travel status semantics.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
b06a14b6aa
commit
ab2535971d
120
scripts/check-social-discovery.py
Normal file
120
scripts/check-social-discovery.py
Normal file
@ -0,0 +1,120 @@
|
||||
"""Focused discovery regression. Run with the portal on localhost:3000.
|
||||
|
||||
Uses mocked discovery data; does not publish profiles or send messages.
|
||||
"""
|
||||
import asyncio
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
from playwright.async_api import async_playwright, expect
|
||||
|
||||
BASE = os.environ.get('SOCIAL_BASE_URL', 'http://localhost:3000')
|
||||
OUTPUT = Path('artifacts/social-discovery')
|
||||
|
||||
|
||||
async def main():
|
||||
OUTPUT.mkdir(parents=True, exist_ok=True)
|
||||
async with async_playwright() as p:
|
||||
browser = await p.chromium.launch()
|
||||
context = await browser.new_context(locale='en-US', timezone_id='America/New_York', reduced_motion='reduce')
|
||||
# The Windows host has Chinese fonts installed. Make font-based audience
|
||||
# detection deterministic for this international-browser scenario only.
|
||||
await context.add_init_script('''
|
||||
const measure = CanvasRenderingContext2D.prototype.measureText;
|
||||
CanvasRenderingContext2D.prototype.measureText = function(text) {
|
||||
if (text === 'mmmmmmmmmmlli中文测试') return { width: 100 };
|
||||
return measure.call(this, text);
|
||||
};
|
||||
''')
|
||||
await context.route('**/favicon.ico?*', lambda route: route.abort())
|
||||
async def mock(route):
|
||||
if '/roster/discovery' in route.request.url:
|
||||
await route.fulfill(json={'items': [
|
||||
{'guestId': 'test-here', 'name': 'Here Offline', 'city': 'Test City', 'status': 'here', 'online': False, 'tags': ['Testing']},
|
||||
{'guestId': 'test-soon', 'name': 'Soon Online', 'city': 'Test City', 'status': 'arriving', 'online': True, 'tags': ['Testing']},
|
||||
]})
|
||||
elif '/realtime/' in route.request.url:
|
||||
await route.fulfill(json={'enabled': False})
|
||||
else:
|
||||
await route.fulfill(json={'items': []})
|
||||
await context.route('**/api/social/v1/**', mock)
|
||||
page = await context.new_page()
|
||||
errors = []
|
||||
page.on('pageerror', lambda error: errors.append(str(error)))
|
||||
async def go(path):
|
||||
response = await page.goto(BASE + '/social' + path)
|
||||
assert response.status == 200
|
||||
await expect(page.locator('.people-connection-card').first).to_be_visible()
|
||||
|
||||
await go('/people')
|
||||
cards = page.locator('.people-connection-card')
|
||||
await expect(cards.filter(has_text='Here Offline')).to_have_count(1)
|
||||
card = cards.filter(has_text='Here Offline')
|
||||
await card.get_by_role('button', name='Follow Here Offline', exact=True).click()
|
||||
await expect(card.get_by_role('button', name='Unfollow Here Offline')).to_have_attribute('aria-pressed', 'true')
|
||||
await page.locator('.social-filters button').last.click()
|
||||
await expect(cards).to_have_count(1)
|
||||
await page.reload()
|
||||
await page.locator('.social-filters button').last.click()
|
||||
await expect(cards).to_have_count(1)
|
||||
await cards.get_by_role('button', name='Unfollow Here Offline').click()
|
||||
await expect(cards).to_have_count(0)
|
||||
await expect(page.get_by_role('button', name='Explore everyone')).to_be_visible()
|
||||
await page.get_by_role('button', name='Explore everyone').click()
|
||||
# City and the existing text query can be combined without overwriting one another.
|
||||
await page.locator('.people-toolbar-top select').select_option('Test City')
|
||||
await page.get_by_role('searchbox').fill('Offline')
|
||||
await expect(cards).to_have_count(1)
|
||||
await page.get_by_role('button', name='Remove Test City').click()
|
||||
await expect(page.get_by_role('searchbox')).to_have_value('Offline')
|
||||
await page.get_by_role('button', name='Clear search').click()
|
||||
await page.get_by_role('button', name='Refine', exact=True).click()
|
||||
await page.locator('#people-refinements select').last.select_option('here')
|
||||
await expect(cards).to_have_count(1)
|
||||
await expect(cards).to_contain_text('Here Offline')
|
||||
await page.locator('#people-refinements select').last.select_option('soon')
|
||||
await expect(cards).to_have_count(1)
|
||||
await expect(cards).to_contain_text('Soon Online')
|
||||
await page.get_by_role('button', name='Reset filters').click()
|
||||
await page.get_by_role('button', name='Testing', exact=True).first.click()
|
||||
await expect(cards).to_have_count(2)
|
||||
await page.get_by_role('button', name='Remove Testing').click()
|
||||
await page.locator('.people-results-bar select').select_option('name')
|
||||
names = await cards.locator('h2').all_text_contents()
|
||||
assert names.index('Here Offline') < names.index('Soon Online')
|
||||
layouts = []
|
||||
for width in [320, 390, 768, 1440]:
|
||||
await page.set_viewport_size({'width': width, 'height': 900})
|
||||
await page.screenshot(path=str(OUTPUT / f'people-{width}.png'), full_page=True)
|
||||
overflow = await page.evaluate('document.documentElement.scrollWidth - innerWidth')
|
||||
assert overflow <= 1, (width, overflow)
|
||||
layouts.append({'page': 'people', 'width': width, 'overflow': overflow})
|
||||
await page.goto(BASE + '/social')
|
||||
await page.get_by_role('button', name='Coffee & conversation', exact=True).click()
|
||||
await expect(page.locator('#social-intent-panel > .intent-panel-actions > a').first).to_have_attribute('href', '/social/coffeechat')
|
||||
await page.locator('.intent-options').get_by_role('button', name='Build together', exact=True).click()
|
||||
await expect(page.locator('#social-intent-panel > .intent-panel-actions > a').first).to_have_attribute('href', '/social/skills')
|
||||
for width in [320, 390, 768, 1440]:
|
||||
await page.set_viewport_size({'width': width, 'height': 900})
|
||||
await page.locator('.social-intent-guide').scroll_into_view_if_needed()
|
||||
await page.screenshot(path=str(OUTPUT / f'home-{width}.png'))
|
||||
overflow = await page.evaluate('document.documentElement.scrollWidth - innerWidth')
|
||||
assert overflow <= 1, (width, overflow)
|
||||
layouts.append({'page': 'home', 'width': width, 'overflow': overflow})
|
||||
await context.close()
|
||||
zh = await browser.new_context(locale='zh-CN', timezone_id='Asia/Shanghai', viewport={'width': 390, 'height': 844})
|
||||
await zh.route('**/api/social/v1/**', mock)
|
||||
page = await zh.new_page()
|
||||
page.on('pageerror', lambda error: errors.append(str(error)))
|
||||
await go('/people')
|
||||
await expect(page.get_by_role('button', name='更多筛选', exact=True)).to_be_visible()
|
||||
assert '???' not in await page.locator('.people-toolbar').inner_text()
|
||||
await page.screenshot(path=str(OUTPUT / 'people-zh.png'))
|
||||
assert not errors, errors
|
||||
report = {'interactions': 'passed', 'locales': ['en', 'zh'], 'layouts': layouts, 'pageErrors': errors}
|
||||
(OUTPUT / 'report.json').write_text(json.dumps(report, indent=2), encoding='utf-8')
|
||||
print(json.dumps(report))
|
||||
await browser.close()
|
||||
|
||||
|
||||
asyncio.run(main())
|
||||
@ -93,18 +93,18 @@ async def check_interactions():
|
||||
await go('/people/m01')
|
||||
await page.get_by_role('button', name='关注一下',exact=True).click()
|
||||
await page.get_by_role('link', name='回去看看大家',exact=True).click()
|
||||
await page.get_by_role('button',name='我关注的',exact=True).click()
|
||||
await expect(page.locator('.social-discovery-grid > a')).to_have_count(1)
|
||||
await expect(page.locator('.social-discovery-grid')).to_contain_text('林悦')
|
||||
await page.locator('.social-filters button').last.click()
|
||||
await expect(page.locator('.people-connection-card')).to_have_count(1)
|
||||
await expect(page.locator('.people-card-grid')).to_contain_text('林悦')
|
||||
await check('profile follow appears in discovery filter',follow)
|
||||
|
||||
async def filters():
|
||||
await page.get_by_role('button',name='重置筛选',exact=True).click()
|
||||
await page.get_by_role('searchbox').fill('不会匹配的内容')
|
||||
await expect(page.locator('.social-empty')).to_be_visible()
|
||||
await page.get_by_role('button',name='重新看看',exact=True).click()
|
||||
await expect(page.locator('.social-discovery-grid > a')).to_have_count(12)
|
||||
assert await page.locator('.social-discovery-grid .reveal:not(.visible)').count()==0
|
||||
await page.get_by_role('button',name='看看全部朋友',exact=True).click()
|
||||
await expect(page.locator('.people-connection-card')).to_have_count(12)
|
||||
assert await page.locator('.people-card-grid .reveal:not(.visible)').count()==0
|
||||
await page.get_by_role('searchbox').fill('清迈')
|
||||
await page.get_by_role('button',name='清空搜索').click()
|
||||
await expect(page.get_by_role('searchbox')).to_be_focused()
|
||||
@ -191,9 +191,9 @@ async def check_interactions():
|
||||
await page.get_by_role('button',name='保存介绍',exact=True).click()
|
||||
await expect(page.get_by_role('status').filter(has_text='介绍已保存')).to_have_count(1)
|
||||
await go('/people')
|
||||
await expect(page.locator('.social-discovery-grid')).to_contain_text('UI smoke profile')
|
||||
await expect(page.locator('.people-card-grid')).to_contain_text('UI smoke profile')
|
||||
await page.reload()
|
||||
await expect(page.locator('.social-discovery-grid > a')).to_have_count(13)
|
||||
await expect(page.locator('.people-connection-card')).to_have_count(13)
|
||||
await go('/date')
|
||||
assert await page.locator('.social-date-card.is-top').inner_text() != 'UI smoke profile'
|
||||
await check('edited profile survives discovery reload without render loop',profile)
|
||||
|
||||
@ -13,6 +13,7 @@ import "@social/app/depth.css";
|
||||
import "@social/app/vivid.css";
|
||||
import "@social/app/h5.css";
|
||||
import "@social/app/blog.css";
|
||||
import "@social/app/discovery.css";
|
||||
import SocialExperience from "@social/components/SocialExperience";
|
||||
|
||||
export const metadata = {
|
||||
|
||||
@ -68,3 +68,12 @@ curl http://127.0.0.1:8080/api/social/v1/health
|
||||
```
|
||||
|
||||
部署说明见 [`deploy/social/README.md`](../../../deploy/social/README.md)。前端先本地验收,未经允许不上线。
|
||||
|
||||
## 社区发现体验(2026-11-04)
|
||||
|
||||
- 首页 `HomeActionRail` 按认识朋友、咖啡聊、同城探索、技能共创四种意图展示下一步;不新增搜索。
|
||||
- `/social/people` 使用独立城市与现有搜索、动态职业/兴趣/语言选项、可移除条件、排序和卡片直接关注。关注沿用本设备存储,与详情页及滑卡共用。
|
||||
- 行程仅依据明确的 `status`:`here` 表示当前在此,`arriving` / `soon` 表示即将到达;不再通过在线状态推测行程。没有该字段的示例不参与行程匹配。
|
||||
- 运营文案继续走 `copy.socialPages`:`discovery` 配置首页引导标题;`discovery-people`、`discovery-coffee`、`discovery-city`、`discovery-create` 配置对应说明;`peopleConnections` 配置找人页引导。使用已有 `eyebrow/title/description` 字段;`socialHiddenSections: ["discovery"]` 可隐藏首页引导。缺省使用包内中英文文案。
|
||||
- 社区语言首次渲染与服务器保持一致,待受众识别完成后更新,避免英文浏览器水合失败。
|
||||
- 验证:启动门户后运行 `python scripts/check-social-discovery.py`;覆盖关注持久化、组合筛选、真实行程语义、首页意图入口、中英文和 320/390/768/1440px 布局。截图与报告位于 `artifacts/social-discovery/`。
|
||||
|
||||
87
src/modules/social/app/discovery.css
Normal file
87
src/modules/social/app/discovery.css
Normal file
@ -0,0 +1,87 @@
|
||||
/* Intent-led discovery and connection cards. Scoped to the social shell. */
|
||||
.social-skin .social-page-head .social-actions { min-width: 0; max-width: 100%; }
|
||||
.social-skin .social-page-head .social-demo-badge { white-space: normal; overflow-wrap: anywhere; line-height: 1.6; max-width: 100%; }
|
||||
.social-skin .social-intent-guide { margin-top: 26px; margin-bottom: 40px; }
|
||||
.social-skin .intent-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
|
||||
.social-skin .people-eyebrow { font-size: 10px; letter-spacing: .14em; font-weight: 700; color: var(--accent-3, #4ecdc4); }
|
||||
.social-skin .intent-heading h2 { margin: 0; font-size: clamp(19px, 2.4vw, 26px); letter-spacing: -.035em; }
|
||||
.social-skin .intent-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
|
||||
.social-skin .intent-options button { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 10px; border: 1px solid color-mix(in srgb, var(--text-primary) 12%, transparent); border-radius: 14px; background: var(--bg-glass); color: var(--text-secondary); font: inherit; font-size: 13px; cursor: pointer; transition: background .2s, border-color .2s; }
|
||||
.social-skin .intent-options button[aria-pressed="true"] { color: var(--text-primary); border-color: var(--accent-3, #4ecdc4); background: color-mix(in srgb, var(--accent-3, #4ecdc4) 12%, var(--bg-primary)); }
|
||||
.social-skin .intent-panel { position: relative; display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; align-items: center; gap: 24px; padding: 30px; border: 1px solid color-mix(in srgb, var(--accent-3, #4ecdc4) 25%, transparent); border-radius: 22px; background: linear-gradient(115deg, color-mix(in srgb, var(--accent-3, #4ecdc4) 8%, transparent), transparent 65%), var(--bg-card); }
|
||||
.social-skin .intent-art { position: relative; display: grid; place-items: center; width: 100px; height: 100px; border: 1px dashed color-mix(in srgb, var(--accent-3, #4ecdc4) 40%, transparent); border-radius: 50%; color: var(--accent-3, #4ecdc4); }
|
||||
.social-skin .intent-art span { position: absolute; inset: 12px; border: 1px solid color-mix(in srgb, var(--accent-3, #4ecdc4) 20%, transparent); border-radius: 50%; }
|
||||
.social-skin .intent-art i { position: absolute; width: 9px; height: 9px; right: 7px; top: 13px; border-radius: 50%; background: var(--accent-3, #4ecdc4); box-shadow: 0 0 18px color-mix(in srgb, var(--accent-3, #4ecdc4) 45%, transparent); }
|
||||
.social-skin .intent-step { margin: 0 0 9px; color: var(--accent-3, #4ecdc4); font-size: 11px; }
|
||||
.social-skin .intent-panel-copy h3 { margin: 0 0 10px; font-size: clamp(18px, 2vw, 24px); letter-spacing: -.03em; line-height: 1.35; }
|
||||
.social-skin .intent-panel-copy > p:last-child { margin: 0; max-width: 540px; color: var(--text-secondary); font-size: 13px; line-height: 1.8; }
|
||||
.social-skin .intent-panel-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; }
|
||||
.social-skin .intent-panel-actions > a:last-child { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: 12px; min-height: 44px; }
|
||||
.social-skin .people-discovery-banner { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin: 20px 0; padding: 28px; border: 1px solid color-mix(in srgb, var(--accent-3, #4ecdc4) 25%, transparent); border-radius: 20px; background: linear-gradient(110deg, color-mix(in srgb, var(--accent-3, #4ecdc4) 9%, transparent), transparent), var(--bg-card); }
|
||||
.social-skin .people-discovery-banner h2 { margin: 8px 0; font-size: clamp(20px, 2.4vw, 28px); line-height: 1.4; letter-spacing: -.035em; }
|
||||
.social-skin .people-discovery-banner p { margin: 0; font-size: 13px; color: var(--text-secondary); line-height: 1.8; }
|
||||
.social-skin .people-discovery-banner > a { flex-shrink: 0; }
|
||||
.social-skin .people-toolbar { display: flex; flex-direction: column; align-items: stretch; gap: 16px; padding: 20px; border-radius: 18px; }
|
||||
.social-skin .people-toolbar-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(130px, 200px) auto; align-items: end; gap: 12px; }
|
||||
.social-skin .people-toolbar .social-search { width: 100%; min-width: 0; min-height: 46px; margin: 0; }
|
||||
.social-skin .people-select { display: flex; flex-direction: column; gap: 6px; min-width: 0; color: var(--text-secondary); font-size: 11px; }
|
||||
.social-skin .people-select select { width: 100%; min-width: 0; min-height: 44px; padding: 9px 30px 9px 12px; color: var(--text-primary); border: 1px solid color-mix(in srgb, var(--text-primary) 14%, transparent); border-radius: 10px; background: var(--bg-secondary); font: inherit; font-size: 12px; text-overflow: ellipsis; }
|
||||
.social-skin .people-refine { min-height: 46px; justify-content: center; }
|
||||
.social-skin .people-refinements { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding-top: 16px; border-top: 1px solid color-mix(in srgb, var(--text-primary) 10%, transparent); }
|
||||
.social-skin .people-refinements[hidden] { display: none; }
|
||||
.social-skin .people-refinements > p { grid-column: 1 / -1; margin: 0; font-size: 11px; color: var(--text-secondary); line-height: 1.6; }
|
||||
.social-skin .people-filter-chips { display: flex; gap: 8px; flex-wrap: wrap; }
|
||||
.social-skin .people-filter-chips button { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 10px; color: var(--accent-3, #4ecdc4); background: color-mix(in srgb, var(--accent-3, #4ecdc4) 9%, transparent); border: 1px solid color-mix(in srgb, var(--accent-3, #4ecdc4) 25%, transparent); border-radius: 8px; font: inherit; font-size: 12px; cursor: pointer; }
|
||||
.social-skin .people-results-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 18px 0; }
|
||||
.social-skin .people-results-bar .social-result-summary { margin: 0; flex: 1; }
|
||||
.social-skin .people-live-notice { color: var(--accent-3, #4ecdc4); font-size: 12px; }
|
||||
.social-skin .people-live-notice:empty { margin: 0; }
|
||||
.social-skin .people-card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding-bottom: 24px; }
|
||||
.social-skin .people-connection-card { display: flex; flex-direction: column; min-width: 0; padding: 22px; border: 1px solid color-mix(in srgb, var(--text-primary) 12%, transparent); border-radius: 20px; background: var(--bg-card); transition: transform .2s, border-color .2s; }
|
||||
@media (hover: hover) { .social-skin .people-connection-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent-3, #4ecdc4) 50%, transparent); } }
|
||||
.social-skin .people-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
|
||||
.social-skin .people-card-heading img { border-radius: 18px; object-fit: cover; flex-shrink: 0; }
|
||||
.social-skin .people-presence { font-size: 10px; color: var(--text-secondary); display: flex; gap: 6px; align-items: center; }
|
||||
.social-skin .people-presence.is-online { color: var(--accent-3, #4ecdc4); }
|
||||
.social-skin .people-presence.is-online::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
|
||||
.social-skin .people-profile-link { color: inherit; text-decoration: none; }
|
||||
.social-skin .people-profile-link h2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 21px; margin: 0 0 6px; overflow-wrap: anywhere; }
|
||||
.social-skin .people-profile-link h2 svg { color: var(--text-secondary); flex-shrink: 0; }
|
||||
.social-skin .people-card-role { font-size: 13px; color: var(--text-secondary); margin: 0 0 10px; }
|
||||
.social-skin .people-card-city { display: flex; align-items: center; gap: 5px; margin: 0 0 16px; font-size: 11px; color: var(--text-secondary); }
|
||||
.social-skin .people-card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
|
||||
.social-skin .people-card-tags button { min-height: 36px; max-width: 100%; padding: 6px 9px; border-radius: 8px; border: 1px solid transparent; background: var(--bg-glass); color: var(--text-secondary); font: inherit; font-size: 11px; cursor: pointer; overflow-wrap: anywhere; }
|
||||
.social-skin .people-card-tags button[aria-pressed="true"] { border-color: var(--accent-3, #4ecdc4); color: var(--accent-3, #4ecdc4); }
|
||||
.social-skin .people-card-looking { flex: 1; margin: 16px 0 20px; font-size: 13px; line-height: 1.8; color: var(--text-primary); overflow-wrap: anywhere; }
|
||||
.social-skin .people-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid color-mix(in srgb, var(--text-primary) 10%, transparent); padding-top: 14px; }
|
||||
.social-skin .people-card-footer > a { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; color: var(--text-secondary); font-size: 11px; }
|
||||
.social-skin .people-follow { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 9px 12px; border: 1px solid color-mix(in srgb, var(--text-primary) 16%, transparent); background: transparent; color: var(--text-primary); font: inherit; font-size: 12px; border-radius: 10px; cursor: pointer; }
|
||||
.social-skin .people-follow.is-following { color: var(--accent-1, #ff6b6b); border-color: color-mix(in srgb, var(--accent-1, #ff6b6b) 40%, transparent); background: color-mix(in srgb, var(--accent-1, #ff6b6b) 8%, transparent); }
|
||||
.social-skin :is(.intent-options, .intent-panel-actions, .people-toolbar, .people-card-grid, .people-results-bar) :is(a, button, select, input):focus-visible { outline: 2px solid var(--accent-3, #4ecdc4); outline-offset: 4px; }
|
||||
@media (max-width: 1050px) {
|
||||
.social-skin .people-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
.social-skin .intent-panel { grid-template-columns: 80px minmax(0, 1fr); gap: 20px; }
|
||||
.social-skin .intent-art { width: 76px; height: 76px; }
|
||||
.social-skin .intent-panel-actions { grid-column: 2; flex-direction: row; justify-content: flex-start; flex-wrap: wrap; }
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.social-skin .intent-heading { display: block; }
|
||||
.social-skin .intent-heading h2 { margin-top: 9px; }
|
||||
.social-skin .intent-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
.social-skin .intent-options button { min-height: 48px; font-size: 12px; }
|
||||
.social-skin .intent-panel { grid-template-columns: 1fr; padding: 22px; gap: 14px; }
|
||||
.social-skin .intent-art { display: none; }
|
||||
.social-skin .intent-panel-actions { grid-column: 1; align-items: flex-start; gap: 8px 16px; }
|
||||
.social-skin .people-discovery-banner { align-items: flex-start; flex-direction: column; padding: 22px; gap: 16px; }
|
||||
.social-skin .people-toolbar { padding: 16px; }
|
||||
.social-skin .people-toolbar-top { grid-template-columns: minmax(0, 1fr) auto; }
|
||||
.social-skin .people-toolbar-top .social-search { grid-column: 1 / -1; }
|
||||
.social-skin .people-refinements { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
.social-skin .people-card-grid { grid-template-columns: 1fr; gap: 12px; }
|
||||
.social-skin .people-connection-card { padding: 20px; }
|
||||
.social-skin .people-filter-chips button, .social-skin .people-card-tags button { min-height: 44px; }
|
||||
.social-skin .people-results-bar { flex-wrap: wrap; }
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.social-skin :is(.people-connection-card, .intent-options button) { transition: none; transform: none; }
|
||||
}
|
||||
@ -1,104 +1,52 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import Link from "next/link";
|
||||
import {
|
||||
ArrowLeftRight,
|
||||
Coffee,
|
||||
Heart,
|
||||
Map,
|
||||
Users,
|
||||
} from "lucide-react";
|
||||
import { ArrowUpRight, Coffee, Compass, Heart, Users } from "lucide-react";
|
||||
import { socialPath } from "@social/lib/socialPath";
|
||||
import { socialTx } from "@social/lib/socialTx";
|
||||
import { useHomeLivenessGate } from "./HomeStatusStrip";
|
||||
|
||||
type Action = {
|
||||
id: string;
|
||||
href: string;
|
||||
gated?: boolean;
|
||||
icon: typeof Users;
|
||||
title: string;
|
||||
sub: string;
|
||||
className: string;
|
||||
};
|
||||
import { useSocialI18n } from "@social/lib/useSocialI18n";
|
||||
import { useSocialConfig } from "./SocialExperience";
|
||||
|
||||
export default function HomeActionRail() {
|
||||
const { liveOk, verifyHref } = useHomeLivenessGate();
|
||||
|
||||
const actions: Action[] = [
|
||||
{
|
||||
id: "people",
|
||||
href: "#people",
|
||||
icon: Users,
|
||||
title: socialTx("想见的人"),
|
||||
sub: socialTx("先逛逛同频"),
|
||||
className: "mint",
|
||||
},
|
||||
{
|
||||
id: "date",
|
||||
href: socialPath("/date"),
|
||||
gated: true,
|
||||
icon: Heart,
|
||||
title: socialTx("左右滑"),
|
||||
sub: socialTx("一张一张认识"),
|
||||
className: "coral",
|
||||
},
|
||||
{
|
||||
id: "coffee",
|
||||
href: socialPath("/coffeechat"),
|
||||
gated: true,
|
||||
icon: Coffee,
|
||||
title: socialTx("咖啡聊"),
|
||||
sub: socialTx("约一杯见面"),
|
||||
className: "amber",
|
||||
},
|
||||
{
|
||||
id: "skills",
|
||||
href: socialPath("/skills"),
|
||||
icon: ArrowLeftRight,
|
||||
title: socialTx("技能板"),
|
||||
sub: socialTx("互换互助"),
|
||||
className: "mint",
|
||||
},
|
||||
{
|
||||
id: "map",
|
||||
href: socialPath("/map"),
|
||||
gated: true,
|
||||
icon: Map,
|
||||
title: socialTx("地图"),
|
||||
sub: socialTx("同城足迹"),
|
||||
className: "yellow",
|
||||
},
|
||||
const { tx } = useSocialI18n();
|
||||
const config = useSocialConfig();
|
||||
const [intent, setIntent] = useState("people");
|
||||
const copy = config.copy.socialPages?.discovery;
|
||||
if (config.copy.socialHiddenSections?.includes("discovery")) return null;
|
||||
const journeys = [
|
||||
{ id: "people", icon: Users, label: tx("认识朋友", "Meet people"),
|
||||
title: tx("先找到同频,再聊得投机。", "Find your people. Let conversation follow."),
|
||||
description: tx("从兴趣、城市和一段自我介绍开始,慢慢认识值得连接的人。", "Start with shared interests, a city, and a little introduction. Connect at your own pace."),
|
||||
href: "/people", cta: tx("看看大家", "Meet the community"), secondary: "/date", secondaryLabel: tx("一张一张认识", "Discover one at a time"), step: tx("发现 → 关注 → 了解彼此", "Discover → Follow → Get to know each other") },
|
||||
{ id: "coffee", icon: Coffee, label: tx("约杯咖啡", "Coffee & conversation"),
|
||||
title: tx("留一点时间,认真聊一聊。", "Make time for a real conversation."),
|
||||
description: tx("浏览咖啡聊主理人的介绍与可预约时间,找到适合自己的话题。", "Explore hosts and available times. Find a conversation that feels right for you."),
|
||||
href: "/coffeechat", cta: tx("探索咖啡聊", "Explore coffee chats"), secondary: "/meetup", secondaryLabel: tx("先参加群聊", "Explore group meetups"), step: tx("选话题 → 看时间 → 预约见面", "Find a topic → Pick a time → Book a chat") },
|
||||
{ id: "city", icon: Compass, label: tx("探索同城", "Explore a city"),
|
||||
title: tx("陌生的城市,也有熟悉的同频。", "A new city. A familiar sense of connection."),
|
||||
description: tx("挑一座城市,了解当地生活,再找适合工作、见面的咖啡馆。", "Choose a city, discover local life, and find a cafe for work or a friendly hello."),
|
||||
href: "/places", cta: tx("逛逛城市", "Explore cities"), secondary: "/places?tab=cafes", secondaryLabel: tx("找一家咖啡馆", "Find a cafe"), step: tx("选城市 → 看地点 → 安排见面", "Choose a city → Find a place → Make a plan") },
|
||||
{ id: "create", icon: Heart, label: tx("一起创造", "Build together"),
|
||||
title: tx("把共同兴趣,变成一起做的事。", "Turn shared interests into something real."),
|
||||
description: tx("从技能互助到远程协作,找到可以一起行动的人和机会。", "From skill exchanges to remote collaboration, discover people and opportunities to build with."),
|
||||
href: "/skills", cta: tx("探索技能互助", "Explore skill exchanges"), secondary: "/team", secondaryLabel: tx("看看共创机会", "Find collaborators"), step: tx("发现技能 → 交流想法 → 一起行动", "Discover skills → Exchange ideas → Build together") },
|
||||
];
|
||||
|
||||
const selected = journeys.find(journey => journey.id === intent) || journeys[0];
|
||||
const selectedCopy = config.copy.socialPages?.[`discovery-${selected.id}`];
|
||||
const Icon = selected.icon;
|
||||
return (
|
||||
<nav
|
||||
className="container home-action-rail reveal"
|
||||
aria-label={socialTx("行动入口")}
|
||||
>
|
||||
{actions.map((action, index) => {
|
||||
const locked = Boolean(action.gated) && !liveOk;
|
||||
const href = locked ? verifyHref : action.href;
|
||||
const Icon = action.icon;
|
||||
return (
|
||||
<Link
|
||||
key={action.id}
|
||||
href={href}
|
||||
className={`home-action-chip ${action.className}${locked ? " is-soft-locked" : ""}`}
|
||||
style={{ ["--stagger" as string]: `${index * 50}ms` }}
|
||||
>
|
||||
<span className="home-action-ico" aria-hidden>
|
||||
<Icon size={20} strokeWidth={1.6} />
|
||||
</span>
|
||||
<span className="home-action-copy">
|
||||
<strong>{action.title}</strong>
|
||||
<small>
|
||||
{locked ? socialTx("先完成实拍") : action.sub}
|
||||
</small>
|
||||
</span>
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
<section className="container social-intent-guide" aria-labelledby="social-intent-title">
|
||||
<div className="intent-heading"><span className="people-eyebrow">{copy?.eyebrow || tx("你的社区,你的节奏", "YOUR COMMUNITY. YOUR PACE.")}</span>
|
||||
<h2 id="social-intent-title">{copy?.title || tx("今天,想从哪里开始?", "Where would you like to start?")}</h2>
|
||||
</div>
|
||||
<div className="intent-options" role="group" aria-label={tx("选择探索方向", "Choose what to explore")}>
|
||||
{journeys.map(journey => { const Mark = journey.icon; return <button key={journey.id} type="button" aria-pressed={intent === journey.id} aria-controls="social-intent-panel" onClick={() => setIntent(journey.id)}><Mark size={18} />{journey.label}</button>; })}
|
||||
</div>
|
||||
<div className="intent-panel" id="social-intent-panel">
|
||||
<div className="intent-art" aria-hidden="true"><span /><Icon size={42} strokeWidth={1.3} /><i /></div>
|
||||
<div className="intent-panel-copy"><p className="intent-step">{selectedCopy?.eyebrow || selected.step}</p><h3>{selectedCopy?.title || selected.title}</h3><p>{selectedCopy?.description || selected.description}</p></div>
|
||||
<div className="intent-panel-actions"><Link href={socialPath(selected.href)} className="social-btn primary">{selected.cta}<ArrowUpRight size={16} /></Link><Link href={socialPath(selected.secondary)}>{selected.secondaryLabel}<ArrowUpRight size={14} /></Link></div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
@ -3,278 +3,151 @@
|
||||
import { useMemo, useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { useSearchParams } from "next/navigation";
|
||||
import { Sparkles } from "lucide-react";
|
||||
import { ArrowUpRight, Heart, MapPin, SlidersHorizontal, Sparkles, X } from "lucide-react";
|
||||
import SiteShell from "./SiteShell";
|
||||
import SocialAvatar from "./SocialAvatar";
|
||||
import {
|
||||
DemoBadge,
|
||||
EmptyState,
|
||||
PageIntro,
|
||||
SearchField,
|
||||
ResultSummary,
|
||||
} from "./SocialUI";
|
||||
import { DemoBadge, EmptyState, PageIntro, SearchField, ResultSummary } from "./SocialUI";
|
||||
import { SELF_MEMBER_ID, useDiscoveryRoster } from "@social/lib/discoveryRoster";
|
||||
import { SOCIAL_CITIES } from "@social/lib/cities";
|
||||
import { socialPath } from "@social/lib/socialPath";
|
||||
import { useRosterLikes } from "@social/lib/useRosterLikes";
|
||||
import { socialTx } from "@social/lib/socialTx";
|
||||
|
||||
const PROFESSION_HINTS = ["设计", "开发", "内容", "产品", "摄影", "全栈"];
|
||||
const INTEREST_HINTS = ["咖啡局", "冲浪", "瑜伽", "夜跑", "出海", "开源"];
|
||||
const LANG_HINTS = ["中文", "English", "日本語", "Português"];
|
||||
import { setRosterLike, useRosterLikes } from "@social/lib/useRosterLikes";
|
||||
import { useSocialI18n } from "@social/lib/useSocialI18n";
|
||||
import { useSocialConfig } from "./SocialExperience";
|
||||
|
||||
export default function PeopleClient() {
|
||||
const params = useSearchParams();
|
||||
const initialQuery = params.get("city") || "";
|
||||
const initialHere = params.get("here") === "1";
|
||||
const initialSoon = params.get("soon") === "1";
|
||||
return (
|
||||
<PeopleDirectory
|
||||
key={`${initialQuery}-${initialHere}-${initialSoon}`}
|
||||
initialQuery={initialQuery}
|
||||
initialHere={initialHere}
|
||||
initialSoon={initialSoon}
|
||||
/>
|
||||
);
|
||||
return <PeopleDirectory key={params.toString()} initialCity={params.get("city") || ""}
|
||||
initialFilter={params.get("filter") === "saved" ? "saved" : "all"}
|
||||
initialPresence={params.get("here") === "1" ? "here" : params.get("soon") === "1" ? "soon" : "all"} />;
|
||||
}
|
||||
|
||||
function PeopleDirectory({
|
||||
initialQuery,
|
||||
initialHere,
|
||||
initialSoon,
|
||||
}: {
|
||||
initialQuery: string;
|
||||
initialHere: boolean;
|
||||
initialSoon: boolean;
|
||||
function PeopleDirectory({ initialCity, initialFilter, initialPresence }: {
|
||||
initialCity: string; initialFilter: string; initialPresence: string;
|
||||
}) {
|
||||
const roster = useDiscoveryRoster();
|
||||
const [query, setQuery] = useState(initialQuery);
|
||||
const [filter, setFilter] = useState("all");
|
||||
const { tx } = useSocialI18n();
|
||||
const copy = useSocialConfig().copy.socialPages?.peopleConnections;
|
||||
const likes = useRosterLikes();
|
||||
const [query, setQuery] = useState("");
|
||||
const [city, setCity] = useState(initialCity);
|
||||
const [filter, setFilter] = useState(initialFilter);
|
||||
const [profession, setProfession] = useState("");
|
||||
const [interest, setInterest] = useState("");
|
||||
const [language, setLanguage] = useState("");
|
||||
const [currentlyHere, setCurrentlyHere] = useState(initialHere);
|
||||
const [arrivingSoon, setArrivingSoon] = useState(initialSoon);
|
||||
const likes = useRosterLikes();
|
||||
|
||||
const list = useMemo(
|
||||
() =>
|
||||
roster.filter((person) => {
|
||||
const haystack =
|
||||
`${person.name} ${person.city} ${person.title} ${person.tags.join(" ")} ${person.lookingFor} ${(person.languages || []).join(" ")}`.toLowerCase();
|
||||
const q = query.toLowerCase().trim();
|
||||
if (q && !haystack.includes(q)) return false;
|
||||
if (filter === "saved" && !likes[person.id]) return false;
|
||||
if (filter === "online" && !person.online) return false;
|
||||
if (profession && !person.title.toLowerCase().includes(profession.toLowerCase()))
|
||||
return false;
|
||||
if (
|
||||
interest &&
|
||||
!`${person.tags.join(" ")} ${person.lookingFor}`.toLowerCase().includes(interest.toLowerCase())
|
||||
)
|
||||
return false;
|
||||
if (
|
||||
language &&
|
||||
!(person.languages || []).some((l) =>
|
||||
l.toLowerCase().includes(language.toLowerCase()),
|
||||
)
|
||||
)
|
||||
return false;
|
||||
// Seed roster has no live trip status — treat online as "here" proxy for demo
|
||||
if (currentlyHere && !person.online) return false;
|
||||
if (arrivingSoon && person.online) return false;
|
||||
return true;
|
||||
}),
|
||||
[
|
||||
query,
|
||||
filter,
|
||||
likes,
|
||||
roster,
|
||||
profession,
|
||||
interest,
|
||||
language,
|
||||
currentlyHere,
|
||||
arrivingSoon,
|
||||
],
|
||||
);
|
||||
|
||||
const reset = () => {
|
||||
setQuery("");
|
||||
setFilter("all");
|
||||
setProfession("");
|
||||
setInterest("");
|
||||
setLanguage("");
|
||||
setCurrentlyHere(false);
|
||||
setArrivingSoon(false);
|
||||
};
|
||||
|
||||
const filtered =
|
||||
Boolean(query) ||
|
||||
filter !== "all" ||
|
||||
profession ||
|
||||
interest ||
|
||||
language ||
|
||||
currentlyHere ||
|
||||
arrivingSoon;
|
||||
|
||||
const [presence, setPresence] = useState(initialPresence);
|
||||
const [sort, setSort] = useState("recommended");
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
const [notice, setNotice] = useState("");
|
||||
const options = useMemo(() => ({
|
||||
cities: [...new Set(roster.map(p => p.city.split("·")[0].trim()))].sort(),
|
||||
professions: [...new Set(roster.map(p => p.title).filter(Boolean))].sort(),
|
||||
interests: [...new Set(roster.flatMap(p => p.tags))].sort(),
|
||||
languages: [...new Set(roster.flatMap(p => p.languages || []))].sort(),
|
||||
}), [roster]);
|
||||
const list = useMemo(() => {
|
||||
const result = roster.filter(person => {
|
||||
const haystack = `${person.name} ${person.city} ${person.title} ${person.tags.join(" ")} ${person.lookingFor} ${(person.languages || []).join(" ")}`.toLowerCase();
|
||||
if (query.trim() && !haystack.includes(query.trim().toLowerCase())) return false;
|
||||
if (city && person.city.split("·")[0].trim() !== city) return false;
|
||||
if (filter === "saved" && !likes[person.id]) return false;
|
||||
if (filter === "online" && !person.online) return false;
|
||||
if (profession && person.title !== profession) return false;
|
||||
if (interest && !person.tags.includes(interest)) return false;
|
||||
if (language && !(person.languages || []).includes(language)) return false;
|
||||
// Presence is explicit profile data; online is never a proxy for location or travel.
|
||||
if (presence === "here" && person.status !== "here") return false;
|
||||
if (presence === "soon" && !["arriving", "soon"].includes(person.status || "")) return false;
|
||||
return true;
|
||||
});
|
||||
if (sort === "name") result.sort((a, b) => a.name.localeCompare(b.name));
|
||||
if (sort === "online") result.sort((a, b) => Number(b.online) - Number(a.online));
|
||||
return result;
|
||||
}, [roster, query, city, filter, profession, interest, language, presence, likes, sort]);
|
||||
const reset = () => { setQuery(""); setCity(""); setFilter("all"); setProfession(""); setInterest(""); setLanguage(""); setPresence("all"); setSort("recommended"); };
|
||||
const chips = [
|
||||
{ value: city, clear: () => setCity("") },
|
||||
{ value: profession, clear: () => setProfession("") },
|
||||
{ value: interest, clear: () => setInterest("") },
|
||||
{ value: language, clear: () => setLanguage("") },
|
||||
{ value: presence === "here" ? tx("当前在此", "Currently here") : presence === "soon" ? tx("即将到达", "Arriving soon") : "", clear: () => setPresence("all") },
|
||||
].filter(chip => chip.value);
|
||||
const filtered = Boolean(query || chips.length || filter !== "all");
|
||||
return (
|
||||
<SiteShell title={socialTx("想见的人")}>
|
||||
<PageIntro title={socialTx("想见的人")} accent="认识新朋友">
|
||||
<SiteShell title={tx("想见的人", "Meet your people")}>
|
||||
<PageIntro title={tx("想见的人", "Meet your people")} accent="认识新朋友"
|
||||
description={tx("从共同兴趣开始,把路过变成相遇。", "Start with something in common. Turn passing through into connection.")}>
|
||||
<div className="social-actions">
|
||||
<DemoBadge>{list.length} 位 · 示例介绍,方便先逛逛</DemoBadge>
|
||||
<Link className="social-btn social-btn-ghost" href={socialPath("/map")}>
|
||||
地图
|
||||
</Link>
|
||||
<DemoBadge>{tx("包含示例介绍 · 关注保存在此设备", "Includes sample profiles · follows stay on this device")}</DemoBadge>
|
||||
<Link className="social-btn social-btn-ghost" href={socialPath("/map")}><MapPin size={16} />{tx("地图", "Map")}</Link>
|
||||
</div>
|
||||
</PageIntro>
|
||||
<div className="social-toolbar reveal">
|
||||
<SearchField
|
||||
value={query}
|
||||
onChange={setQuery}
|
||||
label={socialTx("搜索")}
|
||||
placeholder={socialTx("城市 / 名字 / 兴趣")}
|
||||
/>
|
||||
<div className="social-filters" aria-label={socialTx("筛选")}>
|
||||
<div className="people-discovery-banner">
|
||||
<div><span className="people-eyebrow">{copy?.eyebrow || tx("从一句你好开始", "A HELLO GOES A LONG WAY")}</span>
|
||||
<h2>{copy?.title || tx("下一位同频朋友,也许就在这里。", "Your next connection could be right here.")}</h2>
|
||||
<p>{copy?.description || tx("先关注感兴趣的人,再看介绍、找话题,按自己的节奏认识。", "Save someone interesting, explore their story, and connect at your own pace.")}</p></div>
|
||||
<Link className="social-btn primary" href={socialPath("/roster")}><Sparkles size={16} />{tx("写我的介绍", "Create my profile")}<ArrowUpRight size={16} /></Link>
|
||||
</div>
|
||||
<div className="social-toolbar people-toolbar">
|
||||
<div className="people-toolbar-top">
|
||||
<SearchField value={query} onChange={setQuery} label={tx("搜索", "Search")} placeholder={tx("城市 / 名字 / 兴趣", "City / name / interests")} />
|
||||
<label className="people-select">{tx("城市", "City")}<select value={city} onChange={e => setCity(e.target.value)}>
|
||||
<option value="">{tx("全部城市", "All cities")}</option>
|
||||
{city && !options.cities.includes(city) && <option value={city}>{city}</option>}
|
||||
{options.cities.map(c => <option key={c} value={c}>{c}</option>)}
|
||||
</select></label>
|
||||
<button type="button" className="social-save people-refine" aria-expanded={expanded} aria-controls="people-refinements" onClick={() => setExpanded(v => !v)}>
|
||||
<SlidersHorizontal size={16} />{tx("更多筛选", "Refine")}{chips.length > 0 && <span>{chips.length}</span>}
|
||||
</button>
|
||||
</div>
|
||||
<div className="social-filters" aria-label={tx("筛选", "Filter")}>
|
||||
{[{ id: "all", title: tx("全部", "Everyone") }, { id: "online", title: tx("在线状态", "Online status") }, { id: "saved", title: tx("我关注的", "Following") }].map(f => (
|
||||
<button type="button" key={f.id} className={filter === f.id ? "active" : ""} aria-pressed={filter === f.id} onClick={() => setFilter(f.id)}>
|
||||
{f.title}{f.id === "saved" ? ` · ${roster.filter(p => likes[p.id]).length}` : ""}
|
||||
</button>))}
|
||||
</div>
|
||||
<div id="people-refinements" className="people-refinements" hidden={!expanded}>
|
||||
{[
|
||||
{ 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 className="social-people-geo-filters" aria-label="地理与兴趣">
|
||||
<label>
|
||||
城市
|
||||
<select
|
||||
value={query && SOCIAL_CITIES.some((c) => c.name === query) ? query : ""}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
>
|
||||
<option value="">全部城市</option>
|
||||
{SOCIAL_CITIES.map((c) => (
|
||||
<option key={c.id} value={c.name}>
|
||||
{c.emoji} {c.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
职业
|
||||
<select value={profession} onChange={(e) => setProfession(e.target.value)}>
|
||||
<option value="">不限</option>
|
||||
{PROFESSION_HINTS.map((p) => (
|
||||
<option key={p} value={p}>
|
||||
{p}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
兴趣
|
||||
<select value={interest} onChange={(e) => setInterest(e.target.value)}>
|
||||
<option value="">不限</option>
|
||||
{INTEREST_HINTS.map((p) => (
|
||||
<option key={p} value={p}>
|
||||
{p}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
语言
|
||||
<select value={language} onChange={(e) => setLanguage(e.target.value)}>
|
||||
<option value="">不限</option>
|
||||
{LANG_HINTS.map((p) => (
|
||||
<option key={p} value={p}>
|
||||
{p}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
className={currentlyHere ? "active" : ""}
|
||||
aria-pressed={currentlyHere}
|
||||
onClick={() => {
|
||||
setCurrentlyHere((v) => !v);
|
||||
if (!currentlyHere) setArrivingSoon(false);
|
||||
}}
|
||||
>
|
||||
Currently Here
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={arrivingSoon ? "active" : ""}
|
||||
aria-pressed={arrivingSoon}
|
||||
onClick={() => {
|
||||
setArrivingSoon((v) => !v);
|
||||
if (!arrivingSoon) setCurrentlyHere(false);
|
||||
}}
|
||||
>
|
||||
Arriving Soon
|
||||
</button>
|
||||
{ label: tx("职业", "Profession"), value: profession, set: setProfession, options: options.professions },
|
||||
{ label: tx("兴趣", "Interest"), value: interest, set: setInterest, options: options.interests },
|
||||
{ label: tx("语言", "Language"), value: language, set: setLanguage, options: options.languages },
|
||||
].map(field => <label className="people-select" key={field.label}>{field.label}<select value={field.value} onChange={e => field.set(e.target.value)}>
|
||||
<option value="">{tx("不限", "Any")}</option>{field.options.map(v => <option key={v} value={v}>{v}</option>)}
|
||||
</select></label>)}
|
||||
<label className="people-select">{tx("行程状态", "Travel status")}<select value={presence} onChange={e => setPresence(e.target.value)}>
|
||||
<option value="all">{tx("不限", "Any")}</option><option value="here">{tx("当前在此", "Currently here")}</option><option value="soon">{tx("即将到达", "Arriving soon")}</option>
|
||||
</select></label>
|
||||
<p>{tx("行程仅按本人填写的信息筛选;在线不代表正在当地。", "Travel filters use declared profile status. Online does not mean currently in a city.")}</p>
|
||||
</div>
|
||||
{chips.length > 0 && <div className="people-filter-chips" aria-label={tx("已选筛选", "Active filters")}>{chips.map(chip => <button type="button" key={chip.value} onClick={chip.clear} aria-label={`${tx("移除", "Remove")} ${tx(chip.value)}`}>{tx(chip.value)}<X size={13} /></button>)}</div>}
|
||||
</div>
|
||||
<ResultSummary
|
||||
count={list.length}
|
||||
unit="位朋友"
|
||||
filtered={filtered}
|
||||
onReset={reset}
|
||||
/>
|
||||
<div className="social-people-grid social-discovery-grid">
|
||||
{list.map((person, index) => (
|
||||
<Link
|
||||
key={person.id}
|
||||
href={socialPath(`/people/${person.id}`)}
|
||||
className={`social-people-chip social-chip-pop is-rich reveal${person.online ? " is-online" : ""}`}
|
||||
style={{ ["--stagger" as string]: `${Math.min(index, 12) * 40}ms` }}
|
||||
>
|
||||
<span className="social-people-chip-ava">
|
||||
<SocialAvatar src={person.avatar} size={52} lazy />
|
||||
{person.online ? <i aria-hidden /> : null}
|
||||
</span>
|
||||
<strong>
|
||||
{person.name}
|
||||
{person.id === SELF_MEMBER_ID ? " · 我" : ""}
|
||||
</strong>
|
||||
<span className="connection-member-role">
|
||||
{person.title}
|
||||
{person.vibe ? ` · ${person.vibe.split("·")[0].trim()}` : ""}
|
||||
</span>
|
||||
<em>
|
||||
{person.city.split("·")[0].trim()}
|
||||
{person.tags[0] ? ` · ${person.tags[0]}` : ""}
|
||||
</em>
|
||||
<span className="social-people-chip-want" title={person.lookingFor}>
|
||||
{person.lookingFor}
|
||||
</span>
|
||||
<div className="people-results-bar"><ResultSummary count={list.length} unit={tx("位朋友", "people")} filtered={filtered} onReset={reset} />
|
||||
<label className="people-select">{tx("排序", "Sort")}<select value={sort} onChange={e => setSort(e.target.value)}>
|
||||
<option value="recommended">{tx("推荐顺序", "Recommended")}</option><option value="online">{tx("在线优先", "Online first")}</option><option value="name">{tx("按名字", "Name")}</option>
|
||||
</select></label></div>
|
||||
<p className="people-live-notice" role="status" aria-live="polite">{notice}</p>
|
||||
<div className="people-card-grid">
|
||||
{list.map(person => <article className="people-connection-card" key={person.id}>
|
||||
<div className="people-card-heading"><SocialAvatar src={person.avatar} size={64} lazy />
|
||||
<span className={`people-presence${person.online ? " is-online" : ""}`}>{person.online ? tx("在线状态", "Online status") : tx("探索同频", "Open to connection")}</span>
|
||||
</div>
|
||||
<Link className="people-profile-link" href={socialPath(`/people/${person.id}`)}>
|
||||
<h2>{person.name}{person.id === SELF_MEMBER_ID ? tx(" · 我", " · You") : ""}<ArrowUpRight size={18} /></h2>
|
||||
<p className="people-card-role">{tx(person.title)}</p>
|
||||
<p className="people-card-city"><MapPin size={13} />{tx(person.city)}</p>
|
||||
</Link>
|
||||
))}
|
||||
{!list.length && (
|
||||
<EmptyState
|
||||
emoji="🌊"
|
||||
title={socialTx("暂时没找到")}
|
||||
description="换个城市或兴趣关键词试试,也可以清空筛选再看。"
|
||||
>
|
||||
<button className="social-btn" onClick={reset}>
|
||||
清空筛选
|
||||
</button>
|
||||
</EmptyState>
|
||||
)}
|
||||
</div>
|
||||
<div className="social-people-cta-bar">
|
||||
<Link className="social-btn primary" href={socialPath("/roster")}>
|
||||
<Sparkles size={16} />
|
||||
写我的介绍
|
||||
</Link>
|
||||
<div className="people-card-tags">{person.tags.slice(0, 3).map(tag => <button type="button" key={tag} aria-pressed={interest === tag} onClick={() => setInterest(interest === tag ? "" : tag)}>{tx(tag)}</button>)}</div>
|
||||
<p className="people-card-looking">{tx(person.lookingFor)}</p>
|
||||
<div className="people-card-footer"><Link href={socialPath(`/people/${person.id}`)}>{tx("看看介绍", "View profile")}<ArrowUpRight size={14} /></Link>
|
||||
{person.id !== SELF_MEMBER_ID && <button type="button" className={`people-follow${likes[person.id] ? " is-following" : ""}`} aria-pressed={Boolean(likes[person.id])}
|
||||
aria-label={`${likes[person.id] ? tx("取消关注", "Unfollow") : tx("关注", "Follow")} ${person.name}`}
|
||||
onClick={() => { const next = !likes[person.id]; setRosterLike(person.id, next); setNotice(`${person.name} · ${next ? tx("已关注,保存在此设备", "Followed on this device") : tx("已取消关注", "Unfollowed")}`); }}>
|
||||
<Heart size={15} fill={likes[person.id] ? "currentColor" : "none"} />{likes[person.id] ? tx("已关注", "Following") : tx("关注", "Follow")}
|
||||
</button>}</div>
|
||||
</article>)}
|
||||
</div>
|
||||
{!list.length && <EmptyState emoji="🌊" title={tx("暂时没找到", "No connections found yet")}
|
||||
description={filter === "saved" ? tx("在朋友卡片上点关注,感兴趣的人就会出现在这里。", "Follow someone from their card to find them here.") : tx("试着减少一个筛选条件,给相遇多一点可能。", "Try removing a filter to make room for more connections.")}>
|
||||
<button type="button" className="social-btn" onClick={reset}>{tx("看看全部朋友", "Explore everyone")}</button>
|
||||
</EmptyState>}
|
||||
</SiteShell>
|
||||
);
|
||||
}
|
||||
|
||||
@ -84,6 +84,7 @@ export function profileToMember(
|
||||
bio: profile.bio.trim() || "刚写好介绍,想认识同频的人。",
|
||||
vibe: status === "here" ? "同城想出来" : online ? "在线" : "刚出现",
|
||||
online,
|
||||
status,
|
||||
lookingFor:
|
||||
(profile.lookingFor || "").trim() ||
|
||||
(profile.intents || "").replace(/,/g, " · ") ||
|
||||
|
||||
@ -89,6 +89,7 @@ export function discoveryItemToMember(item: {
|
||||
bio: item.bio || "",
|
||||
vibe: item.status === "here" ? "同城想出来" : item.online ? "在线" : "刚出现",
|
||||
online: Boolean(item.online),
|
||||
status: item.status,
|
||||
lookingFor: item.lookingFor || "想认识同频游民",
|
||||
gender: (item.gender as SocialRosterMember["gender"]) || "f",
|
||||
availability: item.availability || "",
|
||||
|
||||
@ -10,6 +10,8 @@ export type SocialRosterMember = {
|
||||
bio: string;
|
||||
vibe: string;
|
||||
online: boolean;
|
||||
/** Explicit declared travel status; independent of online presence. */
|
||||
status?: string;
|
||||
lookingFor: string;
|
||||
gender: "f" | "m";
|
||||
languages?: string[];
|
||||
|
||||
@ -26,7 +26,9 @@ export function useSocialI18n(): {
|
||||
setLocale: (locale: SocialLocale) => void;
|
||||
} {
|
||||
const { locale: portalLocale, setLocale: setPortalLocale, ready } = useLocale();
|
||||
const locale = toSocialLocale(portalLocale);
|
||||
// Match the portal's server fallback until audience detection is ready.
|
||||
// Browser language/font signals can differ from the server on first render.
|
||||
const locale: SocialLocale = ready ? toSocialLocale(portalLocale) : "zh";
|
||||
const dict = useMemo(() => getSocialDictionary(locale), [locale]);
|
||||
|
||||
// Keep module-level translator in sync for nested non-hook call sites.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user