feat: 동네 이야기를 아래 탭 '이야기'(/talk)로 옮김, 오늘 탭에서는 뺌

This commit is contained in:
minaChoi committed 2026-10-20 13:34:19 +09:00
1 parent 798286d975
commit 017022a0b0
7 files changed
+27 -49

No files matched your search

+2 -1
View File
@@ -20,6 +20,7 @@ const TABS = [
{ to: '/gak', key: 'gak', label: '각', title: '오늘의 각' },
// 메인인 오늘 탭을 가운데에
{ to: '/', key: 'today', label: '오늘', title: null },
{ to: '/talk', key: 'talk', label: '이야기', title: '동네 이야기' },
{ to: '/week', key: 'week', label: '주말·행사', title: '주말·행사' },
{ to: '/season', key: 'season', label: '계절·상식', title: '계절·상식' },
] as const
@@ -228,7 +229,7 @@ function Shell() {
<main className="relative z-[1]">
<Outlet />
</main>
<nav aria-label="주요 메뉴" className="b-tabbar fixed inset-x-0 bottom-0 z-30 grid grid-cols-5 border-t px-[max(4px,calc((100%-432px)/2))] pt-[7px] pb-[calc(8px+env(safe-area-inset-bottom,0px))] backdrop-blur-[10px]">
<nav aria-label="주요 메뉴" className="b-tabbar fixed inset-x-0 bottom-0 z-30 grid grid-cols-6 border-t px-[max(4px,calc((100%-432px)/2))] pt-[7px] pb-[calc(8px+env(safe-area-inset-bottom,0px))] backdrop-blur-[10px]">
{TABS.map((t) =>
t.key === 'today' ? (
// 메인 탭: 막대 위로 솟은 큰 주황 동그라미
+1 -3
View File
@@ -28,7 +28,6 @@ import { ago, ARTICLE_CAT, articleMeta, AVATAR_COLORS, cardBg, CHARACTERS, dateR
import { MixSheet } from './myGak'
import { useMyGak } from './myGakState'
import { ownPage, useRegion } from './regionContext'
import { TalkSheet } from './talk'
import { useSky } from './skyContext'
import { SHARE_SIZES, shareImage, type ShareSize } from './storyImage'
import { SheetContext, useSheet, type SharePayload, type SheetState } from './sheetContext'
@@ -75,7 +74,7 @@ export function SheetProvider({ children }: { children: ReactNode }) {
)
}
const TITLES = { article: '읽을거리', seasonWeek: '이번 주 특집', share: '보내기', comments: '댓글', login: '로그인', me: '내 정보', region: '지역 바꾸기', talks: '동네 이야기' } as const
const TITLES = { article: '읽을거리', seasonWeek: '이번 주 특집', share: '보내기', comments: '댓글', login: '로그인', me: '내 정보', region: '지역 바꾸기' } as const
/** 아래에서 올라오는 창: 네이티브 <dialog>라 ESC·포커스 가두기·포커스 되돌리기가 기본으로 된다 */
function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void }) {
@@ -136,7 +135,6 @@ function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void
{state.type === 'me' && <MeSheet onDone={onClose} />}
{state.type === 'region' && <RegionSheet onDone={onClose} />}
{state.type === 'mix' && <MixSheet ids={state.ids} shared={state.shared} onDone={onClose} />}
{state.type === 'talks' && <TalkSheet />}
</div>
)}
{!state && <RegionLinks />}
-2
View File
@@ -10,7 +10,6 @@ import { PostCard, PostCardSkel } from './Post'
import { useRegion } from './regionContext'
import { useSheet } from './sheetContext'
import { useSky } from './skyContext'
import { TalkBand } from './talk'
import { Ic, Rail, Sec, Skel, SkelRail, StateBox, Thumb } from './ui'
import { deg, slotAt } from './weatherText'
@@ -392,7 +391,6 @@ export function TodayPage() {
<Sec title="오늘의 각" sub="누르면 계산 근거를 보여 줘요" more={{ to: '/gak' }} />
{/* 실패 안내는 여기 한 번만, 각 줄 스켈레톤과 같은 크기로 */}
{stories.length ? <Stories items={stories} /> : load === 'loading' ? <StoriesSkel /> : <StateBox load={load} onRetry={() => feed.refetch()} empty="오늘 계산된 각이 없어요." hold={<StoriesSkel />} className="inset-x-3 top-3 bottom-1" />}
<TalkBand />
<div>
{load === 'loading' && <PostsSkel />}
{/* 글이 없거나 못 받아도 스켈레톤 두 장 자리는 그대로 둔다 */}
-1
View File
@@ -13,7 +13,6 @@ export type SheetState =
| { type: 'me' }
| { type: 'region' }
| { type: 'mix'; ids?: number[]; shared?: boolean }
| { type: 'talks' }
| null
export type SheetApi = { open: (s: Exclude<SheetState, null>) => void; close: () => void }
+2 -1
View File
@@ -35,7 +35,7 @@ export function PinIcon({ className }: P) {
)
}
export function TabIcon({ name, className }: P & { name: 'today' | 'gak' | 'sky' | 'week' | 'season' }) {
export function TabIcon({ name, className }: P & { name: 'today' | 'gak' | 'sky' | 'week' | 'season' | 'talk' }) {
return (
<svg viewBox="0 0 24 24" {...line} className={className} aria-hidden="true">
{name === 'today' && <path d="M3 10.5 12 3l9 7.5V20a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z" />}
@@ -55,6 +55,7 @@ export function TabIcon({ name, className }: P & { name: 'today' | 'gak' | 'sky'
<circle cx="12" cy="15" r="1.6" />
</>
)}
{name === 'talk' && <path d="M4 5.5A2.5 2.5 0 0 1 6.5 3h11A2.5 2.5 0 0 1 20 5.5v8a2.5 2.5 0 0 1-2.5 2.5H10l-4.5 4v-4h0A1.5 1.5 0 0 1 4 14.5zM8 8.5h8M8 12h5" />}
{name === 'season' && <path d="M12 6.5C10 5 7 4.5 3.5 5v14c3.5-.5 6.5 0 8.5 1.5 2-1.5 5-2 8.5-1.5V5C17 4.5 14 5 12 6.5zM12 6.5v14" />}
</svg>
)
+20 -41
View File
@@ -1,4 +1,4 @@
import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { useInfiniteQuery, useMutation, useQueryClient } from '@tanstack/react-query'
import { useState, type FormEvent } from 'react'
import {
addTalkMutation,
@@ -6,7 +6,6 @@ import {
deleteTalkMutation,
likeTalkMutation,
listTalksInfiniteOptions,
listTalksOptions,
reportTalkMutation,
unlikeTalkMutation,
} from '../api/client/@tanstack/react-query.gen'
@@ -20,7 +19,6 @@ import { HeartIcon } from './svg'
import { Avatar, Sec, StateBox, TAP44 } from './ui'
const BODY_MAX = 100
const PREVIEW = 3
// 서버 ErrorType 이름 → 안내
const WRITE_ERRORS: Record<string, string> = {
@@ -207,50 +205,31 @@ function TalkRow({ t }: { t: TalkData }) {
)
}
/** 오늘 탭의 동네 이야기: 쓰기 칸과 최근 글 몇 개 */
export function TalkBand() {
const { open } = useSheet()
const q = useQuery(listTalksOptions())
const talks = q.data?.talks ?? []
const load = loadOf(q)
return (
<section aria-label="동네 이야기">
<Sec title="동네 이야기" sub="전국 사람들이 쓰는 지금 날씨 이야기" />
<Composer />
<div className="relative mx-3 mt-2 min-h-[60px] rounded-[22px] bg-white px-3 py-1 shadow-[inset_0_-5px_0_var(--shade)]">
{talks.length ? (
talks.slice(0, PREVIEW).map((t) => <TalkRow key={`${t.talk_id}:${t.liked}:${t.like_count}`} t={t} />)
) : (
<StateBox load={load} onRetry={() => q.refetch()} empty="아직 글이 없어요. 첫 이야기를 남겨 보세요." className="inset-0" />
)}
{talks.length > PREVIEW && (
<button type="button" onClick={() => open({ type: 'talks' })} className="w-full cursor-pointer border-t border-(--line) py-2.5 text-center text-sm font-bold text-(--ink2)">
이야기 더 보기
</button>
)}
</div>
</section>
)
}
/** 동네 이야기 전체 (아래로 더 받기) */
export function TalkSheet() {
/** 이야기 탭: 쓰기 칸과 전국 최신 글 (아래로 더 받기) */
export function TalkPage() {
const list = useInfiniteQuery({
...listTalksInfiniteOptions(),
initialPageParam: {},
getNextPageParam: (last) => last.next_cursor ?? undefined,
})
const talks = list.data?.pages.flatMap((p) => p.talks ?? []) ?? []
const load = loadOf(list)
return (
<div className="flex-1 overflow-auto overscroll-contain px-4 pt-1.5 pb-[18px]">
{talks.map((t) => (
<TalkRow key={`${t.talk_id}:${t.liked}:${t.like_count}`} t={t} />
))}
{list.hasNextPage && (
<button type="button" onClick={() => list.fetchNextPage()} disabled={list.isFetchingNextPage} className="my-2 w-full cursor-pointer text-center text-sm font-bold text-(--ink3) disabled:opacity-50">
{list.isFetchingNextPage ? '불러오는 중…' : '더 보기'}
</button>
)}
</div>
<section aria-label="동네 이야기" aria-busy={load === 'loading'}>
<Sec title="지금 날씨 이야기" sub="전국 사람들이 쓰는 동네 날씨 이야기" />
<Composer />
<div className="relative mx-3 mt-2 min-h-[120px] rounded-[22px] bg-white px-3 py-1 shadow-[inset_0_-5px_0_var(--shade)]">
{talks.length ? (
talks.map((t) => <TalkRow key={`${t.talk_id}:${t.liked}:${t.like_count}`} t={t} />)
) : (
<StateBox load={load} onRetry={() => list.refetch()} empty="아직 글이 없어요. 첫 이야기를 남겨 보세요." className="inset-0" />
)}
{list.hasNextPage && (
<button type="button" onClick={() => list.fetchNextPage()} disabled={list.isFetchingNextPage} className="w-full cursor-pointer border-t border-(--line) py-2.5 text-center text-sm font-bold text-(--ink2) disabled:opacity-50">
{list.isFetchingNextPage ? '불러오는 중…' : '더 보기'}
</button>
)}
</div>
</section>
)
}