feat: 내 각 아이콘·상세, 이야기 내 글·무한 스크롤, 공유 이미지 얇은 띠, 행사 주소 수집
- 내 각: 아이콘 고르기(my_gak.icon), 카드는 아이콘·점수·아쉬운 조건만, 눌러서 상세(시간대·조건별 점수), 공유는 공통 공유 창 - 이야기: 오늘 쓴 내 글 묶음, '내 글' 칩·탭, 무한 스크롤, 사진 카메라 버튼, 지우기 확인, ⋯ 메뉴 하트 옆, 글 시간 서버 계산(1일 전) - 공유 이미지: 1:1·4:5 는 아래 얇은 띠 한 줄로 카드를 크게 - 행사: 수집 때 주소 저장(event.address), 행사 포스트에 장소·주소·기간 - 히어로 말풍선 '오늘 낮은 / 내일 낮은', 내일을 볼 때 배경도 따라감, 달 보름 순간이 낮이면 뜨는 시각으로 - 단풍 지도 피드 맨 위, 행사·계절 띠 포스트 틀 되돌림, 쇼츠 홈 버튼 가림·닫기 버튼, 하단 여백, 회색 글자 대비 - 토스 앱에선 쇼츠 플레이어를 하나만 띄움
This commit is contained in:
1 parent
3a249c509d
commit
ffe6153148
35 files changed
+566
-185
No files matched your search
+58
-26
@@ -1,44 +1,76 @@
|
||||
import { useEffect, useEffectEvent, useRef } from 'react'
|
||||
import { useSearchParams } from 'react-router'
|
||||
import type { TalkTopic } from '@nalssigak/shared/api/client/types.gen'
|
||||
import { cx } from '../lib/utils'
|
||||
import { TalkCard } from './talk'
|
||||
import { TOPICS, useTopicTalks } from './talkState'
|
||||
import { Sec } from './ui'
|
||||
import { useAuth } from './authContext'
|
||||
import { useSheet } from './sheetContext'
|
||||
import { FeedComposer, TalkCard } from './talk'
|
||||
import { TOPICS, useMyTalks, useTopicTalks } from './talkState'
|
||||
import { Rail, Sec } from './ui'
|
||||
|
||||
/** 주제별 사람 글: 위 주제 탭, 아래 글 목록. 피드 묶음의 '전체 보기'가 ?topic= 으로 연다 */
|
||||
type Tab = TalkTopic | 'all' | 'mine'
|
||||
|
||||
/** 목록 끝이 화면 아래 600px 안에 들어오면 다음 쪽을 받는다 (글이 많아도 버튼 없이 이어서) */
|
||||
function MoreOnScroll({ onMore }: { onMore: () => void }) {
|
||||
const ref = useRef<HTMLDivElement>(null)
|
||||
const more = useEffectEvent(onMore)
|
||||
useEffect(() => {
|
||||
const el = ref.current
|
||||
if (!el) return
|
||||
const io = new IntersectionObserver(([e]) => e.isIntersecting && more(), { rootMargin: '0px 0px 600px 0px' })
|
||||
io.observe(el)
|
||||
return () => io.disconnect()
|
||||
}, [])
|
||||
return <div ref={ref} className="h-px" aria-hidden="true" />
|
||||
}
|
||||
|
||||
/** 주제별 사람 글: 위 주제 탭(한 줄 가로로 밀기, 끝에 '내 글'), 아래 글 목록. 피드 묶음의 '전체 보기'가 ?topic= · ?mine=1 로 연다 */
|
||||
export function TalkPage() {
|
||||
const [params, setParams] = useSearchParams()
|
||||
const { loggedIn } = useAuth()
|
||||
const { open } = useSheet()
|
||||
const raw = Number(params.get('topic'))
|
||||
const topic = TOPICS.some(([k]) => k === raw) ? (raw as TalkTopic) : undefined
|
||||
const { talks, loaded, more, loadMore } = useTopicTalks(topic)
|
||||
const tabs: (readonly [TalkTopic | undefined, string])[] = [[undefined, '전체'], ...TOPICS]
|
||||
const tab: Tab = params.get('mine') ? 'mine' : TOPICS.some(([k]) => k === raw) ? (raw as TalkTopic) : 'all'
|
||||
const topicList = useTopicTalks(tab === 'all' || tab === 'mine' ? undefined : tab)
|
||||
const mineList = useMyTalks(tab === 'mine' && loggedIn)
|
||||
const { talks, loaded, more, loadMore } = tab === 'mine' ? mineList : topicList
|
||||
const tabs: (readonly [Tab, string])[] = [['all', '전체'], ...TOPICS, ['mine', '내 글']]
|
||||
const go = (k: Tab) => setParams(k === 'mine' ? { mine: '1' } : k === 'all' ? {} : { topic: String(k) }, { replace: true })
|
||||
|
||||
return (
|
||||
<section aria-label="동네 사람들 글">
|
||||
<Sec title="동네 사람들 글" sub="가까운 동네 글부터 보여요" />
|
||||
<div className="flex flex-wrap gap-1.5 px-4 pb-1" role="tablist" aria-label="글 주제">
|
||||
{tabs.map(([k, label]) => (
|
||||
<button
|
||||
key={label}
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={topic === k}
|
||||
onClick={() => setParams(k ? { topic: String(k) } : {}, { replace: true })}
|
||||
className={cx('cursor-pointer rounded-full px-3 py-1.5 text-[13px] font-extrabold', topic === k ? 'bg-(--ink) text-white' : 'bg-white text-(--ink2)')}
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
))}
|
||||
<div role="tablist" aria-label="글 주제">
|
||||
<Rail className="gap-1.5 pt-0">
|
||||
{tabs.map(([k, label]) => (
|
||||
<button
|
||||
key={label}
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={tab === k}
|
||||
onClick={() => go(k)}
|
||||
className={cx('cursor-pointer rounded-full px-3 py-1.5 text-[13px] font-extrabold whitespace-nowrap', tab === k ? 'bg-(--ink) text-white' : 'bg-white text-(--ink2)')}
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
))}
|
||||
</Rail>
|
||||
</div>
|
||||
{loaded && !talks.length && <p className="mx-4 mt-6 text-center text-[14px] font-semibold text-(--ink3)">아직 이 주제 글이 없어요. 오늘 탭에서 첫 글을 써 주세요.</p>}
|
||||
<FeedComposer />
|
||||
{tab === 'mine' && !loggedIn ? (
|
||||
<p className="mx-4 mt-6 text-center text-[14px] font-semibold text-(--ink3)">
|
||||
로그인하면 내가 쓴 글을 모아 볼 수 있어요.{' '}
|
||||
<button type="button" onClick={() => open({ type: 'login' })} className="cursor-pointer font-extrabold text-(--orange)">
|
||||
로그인
|
||||
</button>
|
||||
</p>
|
||||
) : (
|
||||
loaded && !talks.length && <p className="mx-4 mt-6 text-center text-[14px] font-semibold text-(--ink3)">{tab === 'mine' ? '아직 쓴 글이 없어요. 위 칸에서 첫 글을 써 주세요.' : '아직 이 주제 글이 없어요. 위 칸에서 첫 글을 써 주세요.'}</p>
|
||||
)}
|
||||
{talks.map((t) => (
|
||||
<TalkCard key={`${t.talk_id}:${t.liked}:${t.like_count}`} t={t} />
|
||||
))}
|
||||
{more && (
|
||||
<button type="button" onClick={() => loadMore()} className="mx-3 mt-3 w-[calc(100%-1.5rem)] cursor-pointer rounded-[14px] bg-white py-2.5 text-[13.5px] font-extrabold text-(--ink2)">
|
||||
더 보기
|
||||
</button>
|
||||
)}
|
||||
{more && <MoreOnScroll onMore={() => loadMore()} />}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user