feat: 로딩 스켈레톤·행사 사진·전시·주말 예상 점수·노을 탭 재정리 등 화면 전반 개선

- 화면 전체 스켈레톤, 로딩·완료·실패 사이 레이아웃 고정, 값 없음은 '?'
- 행사 사진·출처 표시, 문화정보 API 전시 연결, 행사 30km 거리 기준
- 각 상세 점수 칸 오늘/내일/토/일, 단기예보 밖 주말은 중기예보 예상 점수
- 6각 차트 축 이름을 좋은 방향으로, 계산 근거 문구 정리
- 아이콘 오용·뜻 모를 표시·빈 데이터·포스트 본문 반복 수정
- 미세먼지 별도 포스트, 노을 명소 전국 155곳 거리 기준, 노을 탭 결론 중심 재구성
- 밤 다크 테마·별똥별, 댓글·좋아요 대기·실패 표시
- 주말 전국 랭킹·당일치기 카드, 계절 이야기 사진 수집
- 문서: 포스트 타입별 내용, 각 데이터 정리, TODO 진행 순서
This commit is contained in:
minaChoi committed 2026-10-06 16:36:11 +09:00
1 parent 296a09d6db
commit ddf05aeb5c
97 files changed
+5475 -720

No files matched your search

+224 -59
View File
@@ -1,4 +1,4 @@
import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { useInfiniteQuery, useMutation, useQuery, useQueryClient, type InfiniteData } from '@tanstack/react-query'
import { useCallback, useDeferredValue, useEffect, useMemo, useRef, useState, type FormEvent, type ReactNode } from 'react'
import { setTokens, subscribeAuth } from '../api/auth'
import {
@@ -18,16 +18,16 @@ import {
unlikeCommentMutation,
updateMeMutation,
} from '../api/client/@tanstack/react-query.gen'
import type { CommentData, Factor, ResAuth, ResIndexDetail } from '../api/client/types.gen'
import type { CommentData, Factor, ResAuth, ResCommentList, ResIndexDetail } from '../api/client/types.gen'
import { cx } from '../lib/utils'
import { useAuth } from './authContext'
import { AVATAR_COLORS, ago, ARTICLE_CAT, articleMeta, cardBg, CHARACTERS, dayLabel, MOODS, shortDay } from './lib'
import { ago, ARTICLE_CAT, articleMeta, AVATAR_COLORS, cardBg, CHARACTERS, dateRange, loadOf, MOODS, shortDay } from './lib'
import { useRegion } from './regionContext'
import { useSky } from './skyContext'
import { storyImage } from './storyImage'
import { SheetContext, useSheet, type SharePayload, type SheetState } from './sheetContext'
import { HeartIcon } from './svg'
import { Avatar, Ic, StateBox } from './ui'
import { Avatar, Ic, Skel, StateBox } from './ui'
export function SheetProvider({ children }: { children: ReactNode }) {
const [state, setState] = useState<SheetState>(null)
@@ -112,10 +112,151 @@ function Body({ children, className }: { children: ReactNode; className?: string
return <div className={cx('flex-1 overflow-auto overscroll-contain px-4 pt-3.5 pb-[18px]', className)}>{children}</div>
}
/** 문구를 모두 같은 칸에 겹쳐 두고 하나만 보인다: 대기 문구로 바뀌어도 버튼 크기가 그대로다 */
function Swap({ labels, at }: { labels: readonly ReactNode[]; at: number }) {
return (
<span className="inline-grid [&>*]:col-start-1 [&>*]:row-start-1">
{labels.map((l, i) => (
<span key={i} className={cx(i !== at && 'invisible')}>
{l}
</span>
))}
</span>
)
}
/* ---------- 시트 스켈레톤: 완료 화면과 같은 틀·같은 줄 높이 ---------- */
const N3 = [0, 1, 2]
const N4 = [0, 1, 2, 3]
const N6 = [0, 1, 2, 3, 4, 5]
const N14 = Array.from({ length: 14 }, (_, i) => i)
function GakSkel() {
return (
<div aria-hidden="true">
<div className="flex items-center gap-3">
<Skel shape className="size-[58px] shrink-0 rounded-full" />
<div className="flex-1">
<h4 className="m-0 font-jua text-[22px] font-normal">
<Skel className="w-28" />
</h4>
<p className="mt-0.5 text-[13.5px] font-semibold">
<Skel className="w-4/5" />
</p>
</div>
<b className="ml-auto font-bagel text-[42px] font-normal">
<Skel className="w-14" />
</b>
</div>
<Skel shape className="mx-auto mt-2 aspect-square w-full max-w-[250px] rounded-full" />
<div className="mt-2.5 grid grid-cols-4 gap-1.5">
{N4.map((i) => (
<div key={i} className="rounded-2xl bg-[#f3f6fb] px-1 py-2.5 text-center">
<small className="block text-xs font-extrabold">
<Skel className="w-8" />
</small>
<b className="block font-bagel text-2xl font-normal">
<Skel className="w-9" />
</b>
<small className="block text-[11px] leading-4 font-extrabold">
<Skel className="w-6" />
</small>
</div>
))}
</div>
<div className="mt-3.5 flex flex-col gap-2.5">
{N6.map((i) => (
<div key={i} className="grid grid-cols-[84px_1fr_52px] items-center gap-x-2.5 text-[13.5px] font-bold">
<span>
<Skel className="w-12" />
</span>
<Skel shape className="h-[9px] rounded-full" />
<em className="text-right text-xs not-italic">
<Skel className="w-10" />
</em>
<p className="col-start-2 col-end-4 -mt-0.5 text-[12.5px] font-semibold">
<Skel className="w-3/4" />
</p>
</div>
))}
</div>
<div className="mt-3.5 flex flex-col gap-1.5 text-[13px] font-semibold">
<span>
<Skel className="w-full" />
<br />
<Skel className="w-1/2" />
</span>
<span>
<Skel className="w-4/5" />
</span>
</div>
</div>
)
}
/** 읽을거리·이번 주 특집: 그림 150px · 머리말 · 제목 · 본문 */
function ArticleSkel() {
return (
<div aria-hidden="true">
<Skel shape className="mb-3.5 h-[150px] rounded-[20px]" />
<p className="text-[13px] font-extrabold">
<Skel className="w-24" />
</p>
<h4 className="mt-1.5 mb-2.5 font-jua text-2xl leading-tight font-normal">
<Skel className="w-4/5" />
</h4>
{N3.map((k) => (
<p key={k} className="mb-2.5 text-[15px] leading-[1.7]">
<Skel className="w-full" />
<br />
<Skel className="w-2/3" />
</p>
))}
</div>
)
}
function CommentsSkel() {
return (
<div aria-hidden="true">
{N3.map((i) => (
<div key={i} className="grid grid-cols-[34px_1fr_24px] items-start gap-2.5 py-2">
<Skel shape className="size-[34px] rounded-full" />
<div>
<p className="m-0 text-sm">
<Skel className="w-3/4" />
</p>
<small className="mt-0.5 block text-xs font-bold">
<Skel className="w-24" />
</small>
</div>
</div>
))}
</div>
)
}
function RegionsSkel() {
return (
<ul className="mt-2 flex flex-col" aria-hidden="true">
{N14.map((i) => (
<li key={i} className="border-b-[1.5px] border-(--line) px-1 py-3 font-jua text-[17px]">
<Skel className="w-28" />
</li>
))}
</ul>
)
}
/* ---------- 각 계산 근거 ---------- */
const labelLines = (label: string) => {
const cut = label.indexOf(' ')
return cut < 0 ? [label] : [label.slice(0, cut), label.slice(cut + 1)]
}
function Radar({ name, factors, size = 250 }: { name: string; factors: Factor[]; size?: number }) {
const c = size / 2
const r = size / 2 - 34
const r = size / 2 - 40
const n = factors.length
const pt = (i: number, v: number) => {
const a = -Math.PI / 2 + (i * 2 * Math.PI) / n
@@ -135,8 +276,12 @@ function Radar({ name, factors, size = 250 }: { name: string; factors: Factor[];
<circle key={f.axis} cx={pt(i, f.value / 100)[0]} cy={pt(i, f.value / 100)[1]} r="4.5" fill="#fff" stroke="#ff7a45" strokeWidth="2.5" />
))}
{factors.map((f, i) => (
<text key={f.axis} x={pt(i, 1.2)[0]} y={pt(i, 1.2)[1]} textAnchor="middle" dominantBaseline="middle" fontFamily="Jua,sans-serif" fontSize="14" fill="#28304a">
{f.label}
<text key={f.axis} x={pt(i, 1.24)[0]} y={pt(i, 1.24)[1]} textAnchor="middle" dominantBaseline="middle" fontFamily="Jua,sans-serif" fontSize="13" fill="#28304a">
{labelLines(f.label).map((line, k, all) => (
<tspan key={k} x={pt(i, 1.24)[0]} dy={k === 0 ? `${-(all.length - 1) * 0.55}em` : '1.1em'}>
{line}
</tspan>
))}
</text>
))}
</svg>
@@ -153,7 +298,8 @@ function GakSheet({ indexId, onTitle }: { indexId: number; onTitle: (t: string)
onTitle(g ? `${g.rank}위 ${g.name}` : '계산 근거')
}, [g, onTitle])
if (!g) return <Body>{<StateBox loading={q.isPending} error={q.error} onRetry={() => q.refetch()} empty="이 각의 계산 근거가 아직 없어요." className="mx-0" />}</Body>
const load = loadOf(q)
if (!g) return <Body>{load === 'loading' ? <GakSkel /> : <StateBox load={load} onRetry={() => q.refetch()} empty="이 각의 계산 근거가 아직 없어요." hold={<GakSkel />} className="inset-0" />}</Body>
const factors = d.factors ?? []
return (
<Body>
@@ -167,18 +313,19 @@ function GakSheet({ indexId, onTitle }: { indexId: number; onTitle: (t: string)
</div>
{factors.length > 2 && <Radar name={g.name} factors={factors} />}
{g.trend && g.trend.length > 0 && (
<div className="mt-2.5 grid grid-cols-3 gap-2">
{g.trend.map((t, j) => (
<div key={t.day} className="rounded-2xl bg-[#f3f6fb] p-2.5 text-center">
<small className="text-xs font-extrabold text-(--ink2)">{dayLabel(t.day, j)}</small>
<div className="mt-2.5 grid grid-cols-4 gap-1.5">
{g.trend.map((t) => (
<div key={t.day} className="rounded-2xl bg-[#f3f6fb] px-1 py-2.5 text-center">
<small className="block text-xs font-extrabold whitespace-nowrap text-(--ink2)">{t.label}</small>
<b className="block font-bagel text-2xl font-normal text-(--orange)">{t.score}</b>
<small className={cx('block text-[11px] leading-4 font-extrabold text-(--ink2)', !t.estimated && 'invisible')}>예상</small>
</div>
))}
</div>
)}
<div className="mt-3.5 flex flex-col gap-2.5">
{factors.map((f) => (
<div key={f.axis} className="grid grid-cols-[50px_1fr_52px] items-center gap-x-2.5 text-[13.5px] font-bold">
<div key={f.axis} className="grid grid-cols-[84px_1fr_52px] items-center gap-x-2.5 text-[13.5px] font-bold">
<span>{f.label}</span>
<i className="block h-[9px] overflow-hidden rounded-full bg-[#e3eaf4]">
<s className="block h-full bg-[linear-gradient(90deg,#ffc86e,var(--orange))]" style={{ width: `${f.value}%` }} />
@@ -191,12 +338,17 @@ function GakSheet({ indexId, onTitle }: { indexId: number; onTitle: (t: string)
<div className="mt-3.5 flex flex-col gap-1.5 text-[13px] font-semibold text-(--ink2)">
{d.zero_reason && (
<span>
<b className="text-(--heart)">오늘 0점인 이유:</b> {d.zero_reason}
<b className="text-(--heart)">오늘 걸린 조건:</b> {d.zero_reason}
</span>
)}
{factors.length > 0 && (
<span>
<b className="text-(--ink)">계산 방법:</b> 요소 점수에 비중을 곱해 더하고, 가장 낮은 요소가 낮을수록 최대 25%까지 더 깎아요
</span>
)}
{d.zero_rules && (
<span>
<b className="text-(--ink)">바로 0점:</b> {d.zero_rules}
<b className="text-(--ink)">점수 깎이는 조건:</b> {d.zero_rules}
</span>
)}
{d.limit && (
@@ -218,7 +370,8 @@ function ArticleSheet({ articleId, onTitle }: { articleId: number; onTitle: (t:
onTitle(a ? (ARTICLE_CAT[a.category]?.[0] ?? '') : '')
}, [a, onTitle])
if (!a) return <Body>{<StateBox loading={q.isPending} error={q.error} onRetry={() => q.refetch()} empty="글을 찾지 못했어요." className="mx-0" />}</Body>
const load = loadOf(q)
if (!a) return <Body>{load === 'loading' ? <ArticleSkel /> : <StateBox load={load} onRetry={() => q.refetch()} empty="글을 찾지 못했어요." hold={<ArticleSkel />} className="inset-0" />}</Body>
return (
<Body>
<div className={cx('mb-3.5 grid h-[150px] place-items-center rounded-[20px]', `b-bg-${cardBg(a.icon, a.article_id)}`)}>
@@ -240,13 +393,14 @@ function SeasonWeekSheet() {
const { open } = useSheet()
const q = useQuery(getSeasonWeekOptions())
const w = q.data
if (!w?.headline) return <Body>{<StateBox loading={q.isPending} error={q.error} onRetry={() => q.refetch()} empty="이번 주 특집이 아직 없어요." className="mx-0" />}</Body>
const load = loadOf(q)
if (!w?.headline) return <Body>{load === 'loading' ? <ArticleSkel /> : <StateBox load={load} onRetry={() => q.refetch()} empty="이번 주 특집이 아직 없어요." hold={<ArticleSkel />} className="inset-0" />}</Body>
return (
<Body>
<div className="mb-3.5 grid h-[150px] place-items-center rounded-[20px] b-bg-peach">
<Ic name="maple" className="w-24" />
</div>
<p className="text-[13px] font-extrabold text-(--ink2)">이번 주 특집 · {w.week}번째 주</p>
<p className="text-[13px] font-extrabold text-(--ink2)">{w.start && w.end ? dateRange(w.start, w.end) : '이번 주'}</p>
<h4 className="mt-1.5 mb-2.5 font-jua text-2xl leading-tight font-normal">{w.headline}</h4>
{(w.poem_lines ?? []).length > 0 && (
<p className="mb-2.5 font-batang text-[17px] leading-[1.7]">
@@ -280,7 +434,7 @@ function ShareSheet({ share }: { share: SharePayload }) {
const msg = isMine ? mine : opts[pick]
const url = window.location.origin
const text = `${msg} — ${share.title} · 날씨각`
const text = msg.trim() ? `${msg} — ${share.title} · 날씨각` : `${share.title} · 날씨각`
const { kind } = useSky()
const [image, setImage] = useState<{ blob: Blob; src: string } | null>(null)
const [imageError, setImageError] = useState(false)
@@ -450,22 +604,29 @@ function CommentRow({ c, postId }: { c: CommentData; postId: number }) {
)
}
const del = () =>
// 지우는 동안은 흐리게 두고, 성공하면 다시 받기 전에 목록 캐시에서 바로 뺀다
const del = () => {
setRemoveFailed(false)
remove.mutate(
{ path: { comment_id: c.comment_id } },
{
onSuccess: (res) => {
setRemoveFailed(!res.result?.success)
if (!res.result?.success) return
queryClient.invalidateQueries({ queryKey: listCommentsInfiniteQueryKey({ path: { post_id: postId } }) })
onSuccess: async (res) => {
if (!res.result?.success) return setRemoveFailed(true)
const key = listCommentsInfiniteQueryKey({ path: { post_id: postId } })
await queryClient.cancelQueries({ queryKey: key })
queryClient.setQueryData<InfiniteData<ResCommentList>>(key, (data) =>
data ? { ...data, pages: data.pages.map((p) => ({ ...p, comments: p.comments?.filter((x) => x.comment_id !== c.comment_id) })) } : data,
)
queryClient.invalidateQueries({ queryKey: key })
queryClient.invalidateQueries({ queryKey: getFeedQueryKey({ query: { region: region.code } }) })
},
onError: () => setRemoveFailed(true),
},
)
}
return (
<div className="grid grid-cols-[34px_1fr_24px] items-start gap-2.5 py-2">
<div className={cx('grid grid-cols-[34px_1fr_24px] items-start gap-2.5 py-2 transition-opacity', remove.isPending && 'opacity-50')} aria-busy={remove.isPending}>
<Avatar character={c.character} color={c.color} mood={c.mood} />
<div>
<p className="m-0 text-sm">
@@ -477,13 +638,12 @@ function CommentRow({ c, postId }: { c: CommentData; postId: number }) {
{c.mine && (
<>
{' · '}
<button type="button" onClick={del} disabled={remove.isPending} className="cursor-pointer font-bold text-(--ink3) underline-offset-2 hover:underline">
지우기
<button type="button" onClick={del} disabled={remove.isPending} className={cx('cursor-pointer text-left font-bold underline-offset-2 hover:underline', removeFailed && !remove.isPending ? 'text-(--heart)' : 'text-(--ink3)')}>
<Swap labels={['지우기', '지우는 중…', '못 지웠어요 · 다시']} at={remove.isPending ? 1 : removeFailed ? 2 : 0} />
</button>
</>
)}
</small>
{removeFailed && <small className="block text-xs font-bold text-(--heart)">지우지 못했어요. 다시 해 주세요.</small>}
</div>
<button type="button" onClick={toggle} aria-pressed={liked} aria-label="댓글 좋아요" className="cursor-pointer pt-1">
<HeartIcon className={cx('size-4 stroke-2', liked ? 'fill-(--heart) stroke-(--heart)' : 'fill-none stroke-(--ink3)')} />
@@ -512,7 +672,8 @@ function CommentsSheet({ postId }: { postId: number }) {
e.preventDefault()
if (!loggedIn) return open({ type: 'login' })
const body = text.trim()
if (!body) return
if (!body || add.isPending) return
setAddFailed(false)
add.mutate(
{ path: { post_id: postId }, body: { body } },
{
@@ -541,21 +702,19 @@ function CommentsSheet({ postId }: { postId: number }) {
</button>
)}
</>
) : list.isSuccess ? (
<p className="my-6 text-center font-semibold text-(--ink3)">
아직 댓글이 없어요.
<br />첫 댓글을 남겨 보세요.
</p>
) : loadOf(list) === 'loading' ? (
<CommentsSkel />
) : (
<StateBox loading={list.isPending} error={list.error} onRetry={() => list.refetch()} className="mx-0" />
<StateBox load={loadOf(list)} onRetry={() => list.refetch()} empty="아직 댓글이 없어요. 첫 댓글을 남겨 보세요." hold={<CommentsSkel />} className="inset-0" />
)}
</Body>
<div className="flex justify-around pt-1 pb-2 text-[22px]" role="group" aria-label="빠른 이모지">
<div className="flex justify-around pt-1 text-[22px]" role="group" aria-label="빠른 이모지">
{EMOJIS.map((e) => (
<button
key={e}
type="button"
className="cursor-pointer"
disabled={add.isPending}
className="cursor-pointer disabled:opacity-40"
onClick={() => {
setText((t) => (t + e).slice(0, 60))
inputRef.current?.focus()
@@ -565,15 +724,13 @@ function CommentsSheet({ postId }: { postId: number }) {
</button>
))}
</div>
{addFailed && (
<p className="px-4 pb-1 text-center text-xs font-bold text-(--heart)" role="alert">
댓글을 올리지 못했어요. 다시 해 주세요.
</p>
)}
<p className="h-4 px-4 text-center text-xs leading-4 font-bold text-(--heart)" role="alert">
{addFailed && '댓글을 올리지 못했어요. 다시 해 주세요.'}
</p>
<form onSubmit={submit} className="flex items-center gap-2.5 border-t border-(--line) px-3 pt-2.5 pb-[calc(10px+env(safe-area-inset-bottom,0px))]">
<input ref={inputRef} value={text} onChange={(e) => setText(e.target.value)} maxLength={60} placeholder={me ? `${me.nickname}(으)로 댓글 달기…` : '댓글 달기…'} aria-label="댓글" className="flex-1 rounded-full border border-[#dfe5ee] bg-[#f7f9fc] px-3.5 py-2.5" />
<input ref={inputRef} value={text} onChange={(e) => setText(e.target.value)} readOnly={add.isPending} maxLength={60} placeholder={me ? `${me.nickname}(으)로 댓글 달기…` : '댓글 달기…'} aria-label="댓글" className="min-w-0 flex-1 rounded-full border border-[#dfe5ee] bg-[#f7f9fc] px-3.5 py-2.5" />
<button type="submit" disabled={add.isPending || (loggedIn && !text.trim())} className="cursor-pointer font-extrabold text-(--rain) disabled:opacity-40">
게시
<Swap labels={['게시', '올리는 중…']} at={add.isPending ? 1 : 0} />
</button>
</form>
</>
@@ -621,7 +778,7 @@ function LoginSheet({ onDone }: { onDone: () => void }) {
return (
<Body>
<form onSubmit={submit} className="flex flex-col gap-2.5">
<p className="text-center text-sm font-semibold text-(--ink2)">좋아요·저장·댓글은 로그인한 뒤에 할 수 있어요.</p>
<p className="text-center text-sm font-semibold text-(--ink2)">좋아요·댓글은 로그인한 뒤에 할 수 있어요.</p>
<div className="grid grid-cols-2 gap-1 rounded-full bg-[#f3f6fb] p-1" role="group" aria-label="로그인 또는 가입">
{(
[
@@ -641,7 +798,7 @@ function LoginSheet({ onDone }: { onDone: () => void }) {
{error}
</p>
<button type="submit" disabled={pending} className="cursor-pointer rounded-[14px] bg-(--orange) p-[13px] font-jua text-[17px] text-white shadow-[inset_0_-5px_0_var(--orange-deep)] disabled:opacity-60">
{mode === 'login' ? '로그인' : '가입하고 시작하기'}
<Swap labels={mode === 'login' ? ['로그인', '로그인 중…'] : ['가입하고 시작하기', '가입하는 중…']} at={pending ? 1 : 0} />
</button>
<button type="button" onClick={onDone} className="cursor-pointer rounded-[14px] p-[13px] text-[15px] font-extrabold text-(--ink2)">
나중에 할게요
@@ -676,6 +833,12 @@ function MeSheet({ onDone }: { onDone: () => void }) {
)
}
// 저장하는 동안은 고른 값을 바로 선택으로 보여 준다. 실패하면 me 값으로 돌아간다
const saving = update.isPending ? update.variables?.body : undefined
const character = saving?.character ?? me.character
const color = saving?.color ?? me.color
const mood = saving?.mood ?? me.mood
return (
<Body className="flex flex-col gap-3">
<div className="flex flex-col items-center gap-1.5">
@@ -690,10 +853,10 @@ function MeSheet({ onDone }: { onDone: () => void }) {
key={key}
type="button"
role="radio"
aria-checked={me.character === key}
aria-checked={character === key}
disabled={update.isPending}
onClick={() => save({ character: key })}
className={cx('flex cursor-pointer flex-col items-center gap-1 rounded-[18px] border-2 bg-[#f7f9fc] py-2.5 font-jua text-[15px]', me.character === key ? 'border-(--orange) text-(--orange)' : 'border-transparent text-(--ink)')}
className={cx('flex cursor-pointer flex-col items-center gap-1 rounded-[18px] border-2 bg-[#f7f9fc] py-2.5 font-jua text-[15px]', character === key ? 'border-(--orange) text-(--orange)' : 'border-transparent text-(--ink)')}
>
<Ic name={key} className="w-12" />
{label}
@@ -709,11 +872,11 @@ function MeSheet({ onDone }: { onDone: () => void }) {
key={key}
type="button"
role="radio"
aria-checked={me.color === key}
aria-checked={color === key}
aria-label={key}
disabled={update.isPending}
onClick={() => save({ color: key })}
className={cx('size-9 cursor-pointer rounded-full border-[3px]', me.color === key ? 'border-(--ink)' : 'border-white shadow-[0_0_0_1px_var(--line)]')}
className={cx('size-9 cursor-pointer rounded-full border-[3px]', color === key ? 'border-(--ink)' : 'border-white shadow-[0_0_0_1px_var(--line)]')}
style={{ background: hex }}
/>
))}
@@ -727,10 +890,10 @@ function MeSheet({ onDone }: { onDone: () => void }) {
key={key}
type="button"
role="radio"
aria-checked={me.mood === key}
aria-checked={mood === key}
disabled={update.isPending}
onClick={() => save({ mood: me.mood === key ? '' : key })}
className={cx('flex cursor-pointer flex-col items-center gap-0.5 rounded-[14px] border-2 bg-[#f7f9fc] py-2 text-xs font-bold', me.mood === key ? 'border-(--orange) text-(--orange)' : 'border-transparent text-(--ink2)')}
onClick={() => save({ mood: mood === key ? '' : key })}
className={cx('flex cursor-pointer flex-col items-center gap-0.5 rounded-[14px] border-2 bg-[#f7f9fc] py-2 text-xs font-bold', mood === key ? 'border-(--orange) text-(--orange)' : 'border-transparent text-(--ink2)')}
>
<span className="text-[22px] leading-none">{emoji}</span>
{label}
@@ -748,11 +911,11 @@ function MeSheet({ onDone }: { onDone: () => void }) {
>
<input value={nickname} onChange={(e) => setNickname(e.target.value)} required minLength={2} maxLength={12} aria-label="닉네임" placeholder="닉네임 (2~12자)" className="flex-1 rounded-[14px] border border-[#dfe5ee] bg-[#f7f9fc] px-3.5 py-3" />
<button type="submit" disabled={update.isPending || nickname.trim() === me.nickname} className="cursor-pointer rounded-[14px] bg-(--ink) px-4 py-3 text-sm font-extrabold text-white disabled:opacity-40">
바꾸기
<Swap labels={['바꾸기', '저장 중…']} at={saving?.nickname != null ? 1 : 0} />
</button>
</form>
<p className="m-0 min-h-5 text-center text-[13px] font-bold text-(--heart)" aria-live="polite">
{error}
<p className={cx('m-0 min-h-5 text-center text-[13px] font-bold', saving ? 'text-(--ink2)' : 'text-(--heart)')} aria-live="polite">
{saving ? (saving.nickname == null ? '저장 중…' : '') : error}
</p>
<button
type="button"
@@ -779,6 +942,7 @@ function RegionSheet({ onDone }: { onDone: () => void }) {
const deferred = useDeferredValue(q.trim())
const list = useQuery(listRegionsOptions(deferred ? { query: { q: deferred } } : undefined))
const regions = list.data?.regions ?? []
const listLoad = loadOf(list)
return (
<Body>
@@ -789,8 +953,9 @@ function RegionSheet({ onDone }: { onDone: () => void }) {
{LOCATE_TEXT[locateStatus]}
</p>
<input value={q} onChange={(e) => setQ(e.target.value)} placeholder="구 이름으로 찾기 (예: 마포)" aria-label="구 이름으로 찾기" className="mt-1 w-full rounded-full border border-[#dfe5ee] bg-[#f7f9fc] px-3.5 py-2.5" />
<StateBox loading={list.isPending} error={list.error} onRetry={() => list.refetch()} empty={list.isSuccess && !regions.length ? '찾는 구가 없어요.' : undefined} className="mx-0" />
<ul className="mt-2 flex flex-col">
{listLoad === 'loading' && <RegionsSkel />}
{listLoad !== 'loading' && !regions.length && (listLoad === 'ready' ? <StateBox load={listLoad} empty="찾는 구가 없어요." className="mt-3" /> : <StateBox load={listLoad} onRetry={() => list.refetch()} hold={<RegionsSkel />} className="inset-x-0 top-2 bottom-0" />)}
<ul className={cx('mt-2 flex flex-col transition-opacity', list.isPlaceholderData && 'opacity-60')}>
{regions.map((r) => (
<li key={r.code}>
<button
@@ -809,7 +974,7 @@ function RegionSheet({ onDone }: { onDone: () => void }) {
))}
</ul>
<p className="mt-4 flex items-center justify-center gap-2 text-[13px] font-bold text-(--ink2)">
{me ? `${me.nickname}(으)로 로그인했어요` : '로그인하면 좋아요·저장·댓글을 쓸 수 있어요'}
{me ? `${me.nickname}(으)로 로그인했어요` : '로그인하면 좋아요·댓글을 쓸 수 있어요'}
<button type="button" onClick={me ? logout : () => open({ type: 'login' })} className="cursor-pointer font-extrabold text-(--rain)">
{me ? '로그아웃' : '로그인'}
</button>