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

+131 -55
View File
@@ -1,32 +1,34 @@
import { useRef, useState, type CSSProperties, type MouseEvent, type ReactNode } from 'react'
import { PostType, SlotTone, type GakSlide, type HoursSlide, type PostData, type ResFeed, type RowsSlide, type SunsetSlide, type WeekSlide } from '../api/client/types.gen'
import { useEffect, useRef, useState, type CSSProperties, type MouseEvent, type ReactNode } from 'react'
import { PostType, SlotTone, type GakSlide, type HoursSlide, type PlanSlide, type PostData, type ResFeed, type RowsSlide, type SunsetSlide, type WeekSlide } from '../api/client/types.gen'
import { cx } from '../lib/utils'
import { cardBg, clockShort, fall } from './lib'
import type { SlideBg } from './types'
import { deg } from './weatherText'
import { useMutation, useQueryClient, type QueryClient } from '@tanstack/react-query'
import { likePostMutation, savePostMutation, unlikePostMutation, unsavePostMutation } from '../api/client/@tanstack/react-query.gen'
import { likePostMutation, unlikePostMutation } from '../api/client/@tanstack/react-query.gen'
import { useAuth } from './authContext'
import { useRegion } from './regionContext'
import { useSheet } from './sheetContext'
import { CommentIcon, HeartIcon, MoreIcon, SaveIcon, SendIcon } from './svg'
import { CommentIcon, HeartIcon, SendIcon } from './svg'
import { useCarousel } from './carousel'
import { Arrows, Ic, Rows } from './ui'
import { Arrows, Credit, Ic, Rows, Skel, Thumb } from './ui'
const ACCOUNTS: Record<PostType, readonly [string, string]> = {
[PostType.WEATHER]: ['오늘 날씨', 'sun'],
[PostType.GAK]: ['오늘의 각', 'rabbit'],
[PostType.SUNSET]: ['노을', 'sunset'],
[PostType.SEASON]: ['계절 소식', 'maple'],
[PostType.EVENT]: ['행사', 'fireworks'],
[PostType.EVENT]: ['가까운 행사', 'fireworks'],
[PostType.TIP]: ['날씨 상식', 'bulb'],
[PostType.WEEK]: ['주말 추천', 'calendar'],
[PostType.WEEK]: ['주말 예보', 'calendar'],
[PostType.ALERT]: ['생활 알림', 'umbrella'],
[PostType.TOMORROW]: ['내일 미리보기', 'moon'],
[PostType.QUOTE]: ['오늘의 한 문장', 'letter'],
[PostType.WEEKEND_PLAN]: ['주말 플랜', 'calendar'],
[PostType.AIR]: ['미세먼지', 'vent'],
[PostType.DAY_TRIP]: ['당일치기', 'picnic'],
}
type Slide = HoursSlide | RowsSlide | GakSlide | SunsetSlide | WeekSlide
type Slide = HoursSlide | RowsSlide | GakSlide | SunsetSlide | WeekSlide | PlanSlide
const GAK_BG: SlideBg[] = ['butter', 'peach', 'lilac']
const ROW_ICON_BG: Record<string, SlideBg> = { umbrella: 'lilac', vent: 'mint', sunset: 'peach', thermo: 'sky', maple: 'peach' }
@@ -36,9 +38,12 @@ function slideBg(post: PostData, slide: Slide): SlideBg {
if (slide.kind === 'hours') return 'sky'
if (slide.kind === 'sunset') return 'dusk'
if (slide.kind === 'week') return 'mint'
if (slide.kind === 'plan') return slide.eyebrow.startsWith('일') ? 'peach' : 'butter'
if (slide.kind === 'gak') return GAK_BG[post.post_id % GAK_BG.length]
if (post.post_type === PostType.EVENT) return 'night'
if (post.post_type === PostType.TIP) return 'sky'
if (post.post_type === PostType.AIR) return slide.icon === 'vent' ? 'mint' : 'lilac'
if (post.post_type === PostType.DAY_TRIP) return slide.image ? 'night' : 'mint'
return ROW_ICON_BG[slide.icon] ?? cardBg(slide.icon, post.post_id)
}
@@ -73,7 +78,10 @@ const slideBase = 'relative flex h-full w-full shrink-0 flex-col px-5 py-[22px]'
function SlideView({ slide, bg }: { slide: Slide; bg: SlideBg }) {
const { open } = useSheet()
if (slide.kind === 'hours')
if (slide.kind === 'hours') {
const temps = slide.hours.flatMap((h) => (h.temp_c == null ? [] : [h.temp_c]))
const lo = Math.min(...temps)
const span = Math.max(...temps) - lo || 1
return (
<div className={cx(slideBase, 'b-bg-sky')}>
<Eyebrow>{slide.eyebrow}</Eyebrow>
@@ -85,10 +93,13 @@ function SlideView({ slide, bg }: { slide: Slide; bg: SlideBg }) {
<div
key={h.label}
className={cx(
'flex flex-col items-center justify-between rounded-[18px] px-1 pt-2.5 pb-[9px] text-xs font-bold text-(--ink2)',
'relative flex flex-col items-center justify-between overflow-hidden rounded-[18px] px-1 pt-2.5 pb-[9px] text-xs font-bold text-(--ink2) [&>*]:relative',
h.tone === SlotTone.NIGHT ? 'bg-[#e3e7ff] shadow-[inset_0_-5px_0_#c7cff5]' : h.tone === SlotTone.SUNSET ? 'bg-[#ffe3d2] shadow-[inset_0_-5px_0_#ffc19f]' : 'bg-white shadow-[inset_0_-5px_0_var(--shade)]',
)}
>
{h.temp_c != null && (
<i className="absolute! inset-x-0 bottom-0 bg-linear-to-t from-[rgb(255_122_69/0.34)] to-[rgb(255_122_69/0.1)]" style={{ height: `${20 + ((h.temp_c - lo) / span) * 70}%` }} aria-hidden="true" />
)}
<span>{h.label}</span>
<Ic name={h.icon} className="w-[34px]" />
<b className="font-bagel text-[21px] font-normal text-(--ink)">{deg(h.temp_c)}</b>
@@ -97,6 +108,7 @@ function SlideView({ slide, bg }: { slide: Slide; bg: SlideBg }) {
</div>
</div>
)
}
if (slide.kind === 'gak')
return (
<div className={cx(slideBase, `b-bg-${bg}`)}>
@@ -107,14 +119,14 @@ function SlideView({ slide, bg }: { slide: Slide; bg: SlideBg }) {
<p className="m-0 font-jua text-[29px] leading-tight">{slide.name}</p>
<Eyebrow className="mt-1">{slide.summary}</Eyebrow>
<button type="button" onClick={() => open({ type: 'gak', indexId: slide.index_id })} className="mt-3 cursor-pointer self-start rounded-full bg-(--orange) px-4 py-[9px] font-jua text-[15px] text-white shadow-[inset_0_-5px_0_var(--orange-deep)]">
계산 근거 보기 ⬡
계산 근거 보기
</button>
</div>
)
if (slide.kind === 'sunset')
return (
<div className={cx(slideBase, 'b-bg-dusk')}>
<Eyebrow className="opacity-90">{slide.eyebrow}</Eyebrow>
<Eyebrow>{slide.eyebrow}</Eyebrow>
<Big>
<Lines text={slide.line} />
</Big>
@@ -140,15 +152,59 @@ function SlideView({ slide, bg }: { slide: Slide; bg: SlideBg }) {
</Big>
<div className="mt-auto grid grid-cols-2 gap-2.5">
{slide.days.map((d) => (
<div key={d.day} className="rounded-[18px] bg-white/80 px-3 py-2.5 shadow-[inset_0_-5px_0_rgb(217_229_244/0.9)]">
<Ic name={d.icon} className="w-[38px]" />
<b className="block font-jua text-lg font-normal">
<div key={d.day} className="flex flex-col gap-0.5 rounded-[18px] bg-white/85 px-3 py-2.5 shadow-[inset_0_-5px_0_rgb(217_229_244/0.9)]">
<Ic name={d.icon} className="w-[34px]" />
<b className="font-jua text-lg font-normal">
{d.weekday} {d.day.split('-').slice(1).map(Number).join('.')}
</b>
<small className="text-[12.5px] font-bold text-(--ink2)">{d.text}</small>
<span className="font-jua text-[22px]">
<span className="text-(--rain)">{deg(d.temp_min_c)}</span> → <span className="text-(--orange)">{deg(d.temp_max_c)}</span>
</span>
<small className="text-xs font-bold text-(--ink2)">
비 {d.rain_prob ?? '?'}%{d.temp_min_c != null && d.temp_max_c != null && ` · 일교차 ${Math.round(d.temp_max_c - d.temp_min_c)}°`}
</small>
</div>
))}
</div>
{slide.tip && <p className="mt-3 rounded-[14px] bg-(--ink) px-3 py-2.5 text-[13px] leading-snug font-bold text-white">{slide.tip}</p>}
</div>
)
if (slide.kind === 'plan') {
const credits = [...new Set(slide.steps.flatMap((st) => (st.image && st.image_credit ? [st.image_credit] : [])))]
return (
<div className={cx(slideBase, `b-bg-${bg}`)}>
<Eyebrow>{slide.eyebrow}</Eyebrow>
<Big className="text-[24px]!">
<Lines text={slide.line} />
</Big>
<ol className="mt-auto flex flex-col gap-2">
{slide.steps.map((st, i) => (
<li key={i} className="grid grid-cols-[52px_26px_minmax(0,1fr)_auto] items-center gap-1.5 rounded-[14px] bg-white/80 px-2 py-1.5">
<time className="font-jua text-sm text-(--ink2) tabular-nums">{st.time}</time>
<Ic name={st.icon} className="w-[22px] justify-self-center" />
<span className="min-w-0">
<b className="block truncate text-[13.5px]">{st.title}</b>
<small className="block truncate text-[11.5px] font-semibold text-(--ink2)">{st.sub}</small>
</span>
{st.image && <Thumb image={st.image} icon={st.icon} className="size-[46px] rounded-[10px]" iconClassName="w-[26px]" />}
</li>
))}
</ol>
{credits.length > 0 && <small className="mt-1.5 block text-right text-[10px] font-semibold text-(--ink2)">사진 {credits.join(' · ')}</small>}
</div>
)
}
if (slide.kind === 'rows' && slide.image)
return (
<div className={'relative flex h-full w-full shrink-0 flex-col justify-end bg-cover bg-center text-white'} style={{ backgroundImage: `url(${slide.image})` }}>
{slide.image_credit && <Credit text={slide.image_credit} className="top-2.5 right-2.5" />}
<div className="bg-linear-to-b from-transparent via-[rgb(16_20_34/0.55)] via-35% to-[rgb(16_20_34/0.85)] px-5 pt-20 pb-3.5">
<Eyebrow>{slide.eyebrow}</Eyebrow>
<Big>
<Lines text={slide.line} />
</Big>
<Rows rows={slide.rows ?? []} dark />
</div>
</div>
)
return (
@@ -176,7 +232,7 @@ const BURST: [number, number, number, string][] = [
[52, -100, 12, '#ffc86e'],
]
/** 받아 둔 피드 데이터에도 좋아요·저장을 반영한다. 안 하면 다른 탭에 다녀왔을 때 예전 값으로 다시 그려진다 */
/** 받아 둔 피드 데이터에도 좋아요를 반영한다. 안 하면 다른 탭에 다녀왔을 때 예전 값으로 다시 그려진다 */
function patchFeed(queryClient: QueryClient, postId: number, patch: Partial<PostData>) {
queryClient.setQueriesData<ResFeed>({ predicate: (q) => (q.queryKey[0] as { _id?: string } | undefined)?._id === 'getFeed' }, (feed) =>
feed?.posts ? { ...feed, posts: feed.posts.map((p) => (p.post_id === postId ? { ...p, ...patch } : p)) } : feed,
@@ -202,58 +258,88 @@ export function PostCard({ post }: PostProps) {
return post.size === 'line' ? <LineCard post={post} /> : <FullCard post={post} />
}
/** FullCard 와 같은 틀(머리줄·4:5 그림·버튼줄·글 한 줄)의 스켈레톤 */
export function PostCardSkel() {
return (
<div className="mt-3.5 border-y border-(--line) bg-white" aria-hidden="true">
<div className="flex items-center gap-2.5 px-3 py-2.5">
<Skel shape className="size-[34px] shrink-0 rounded-full" />
<span>
<b className="block text-sm leading-tight font-extrabold">
<Skel className="w-12" />
</b>
<small className="text-xs font-semibold">
<Skel className="w-16" />
</small>
</span>
</div>
<Skel shape className="aspect-[4/5]" />
<div className="flex items-center gap-3.5 px-3 pt-2.5 pb-1">
<Skel shape className="size-7 rounded-full" />
<Skel shape className="size-7 rounded-full" />
<Skel shape className="size-7 rounded-full" />
</div>
<p className="px-3 py-0.5 text-sm">
<Skel className="w-20" />
</p>
<p className="px-3 py-0.5 text-sm">
<Skel className="w-4/5" />
</p>
<p className="px-3 pt-[3px] text-sm">
<Skel className="w-32" />
</p>
<p className="px-3 pt-1 pb-3 text-[11.5px]">
<Skel className="w-8" />
</p>
</div>
)
}
function FullCard({ post }: PostProps) {
const { open } = useSheet()
const { region } = useRegion()
const { loggedIn } = useAuth()
const liked = !!post.liked
const likeCount = post.like_count
const saved = !!post.saved
const queryClient = useQueryClient()
const like = useMutation(likePostMutation())
const unlike = useMutation(unlikePostMutation())
const save = useMutation(savePostMutation())
const unsave = useMutation(unsavePostMutation())
const { ref: sliderRef, api: slider, prev: canPrev, next: canNext, index } = useCarousel({ align: 'start' })
const { ref: sliderRef, api: slider, prev: canPrev, next: canNext, index } = useCarousel({ align: 'start', active: post.slides.length > 1 })
const [pop, setPop] = useState(0)
const [likeFailed, setLikeFailed] = useState(0)
const lastTap = useRef(0)
const cardRef = useRef<HTMLDivElement>(null)
const [account, avatar] = ACCOUNTS[post.post_type]
const n = post.slides.length
const bgs = post.slides.map((sl) => slideBg(post, sl))
const accountName = post.post_type === PostType.EVENT ? `${region.name.split(' ')[0]} ${account}` : account
const share = () => open({ type: 'share', share: { title: post.title, icon: post.icon, bg: bgs[0] ?? 'sky', messages: post.share_messages ?? [], card: cardRef.current } })
const comments = () => open({ type: 'comments', postId: post.post_id })
const patch = (values: Partial<PostData>) => patchFeed(queryClient, post.post_id, values)
useEffect(() => {
if (!likeFailed) return
const t = setTimeout(() => setLikeFailed(0), 2500)
return () => clearTimeout(t)
}, [likeFailed])
// 화면을 먼저 바꾸고, 실패하면 되돌린다 (서버는 실패도 200 + result.success=false 로 준다)
const setLike = (on: boolean) => {
if (!loggedIn) return open({ type: 'login' })
if (on === liked || like.isPending || unlike.isPending) return
if (on) setPop((p) => p + 1)
setLikeFailed(0)
patch({ liked: on, like_count: likeCount + (on ? 1 : -1) })
const revert = () => {
patch({ liked, like_count: likeCount })
setLikeFailed(Date.now())
}
;(on ? like : unlike).mutate(
{ path: { post_id: post.post_id } },
{
onSuccess: (res) =>
res.result?.success
? patch({ liked: res.liked ?? on, ...(res.like_count != null ? { like_count: res.like_count } : {}) })
: patch({ liked, like_count: likeCount }),
onError: () => patch({ liked, like_count: likeCount }),
},
)
}
const toggleSave = () => {
if (!loggedIn) return open({ type: 'login' })
if (save.isPending || unsave.isPending) return
const on = !saved
patch({ saved: on })
;(on ? save : unsave).mutate(
{ path: { post_id: post.post_id } },
{
onSuccess: (res) => patch({ saved: res.result?.success ? (res.saved ?? on) : saved }),
onError: () => patch({ saved }),
: revert(),
onError: revert,
},
)
}
@@ -278,11 +364,8 @@ function FullCard({ post }: PostProps) {
</span>
<span>
<b className="block text-sm leading-tight font-extrabold">날씨각</b>
<small className="text-xs font-semibold text-(--ink2)">{accountName}</small>
<small className="text-xs font-semibold text-(--ink2)">{account}</small>
</span>
<button type="button" onClick={share} aria-label="더 보기" className="ml-auto grid size-7 cursor-pointer place-items-center text-(--ink)">
<MoreIcon />
</button>
</div>
<div ref={cardRef} className="relative aspect-[4/5] overflow-hidden" onClick={onTap}>
{n > 1 && (
@@ -327,8 +410,11 @@ function FullCard({ post }: PostProps) {
<span className="b-like-toast absolute top-[62%] rounded-full bg-white px-4 py-2 font-jua text-[17px] text-(--heart) opacity-0 shadow-[0_8px_18px_rgb(40_48_74/0.18)]">좋아요했어요!</span>
</div>
)}
<p data-noshot role="status" className="pointer-events-none absolute inset-x-0 bottom-4 z-[5] m-0 flex justify-center px-4">
{likeFailed > 0 && <span className="rounded-full bg-[rgb(30_36_56/0.82)] px-3.5 py-2 text-[13px] font-bold text-white">{liked ? '좋아요를 취소하지 못했어요' : '좋아요를 반영하지 못했어요'}. 다시 해 주세요.</span>}
</p>
</div>
<div className="relative flex items-center gap-3.5 px-3 pt-2.5 pb-1 [&_svg]:size-[26px] [&_svg]:stroke-[1.9]">
<div className="flex items-center gap-3.5 px-3 pt-2.5 pb-1 [&_svg]:size-[26px] [&_svg]:stroke-[1.9]">
<button type="button" onClick={() => setLike(!liked)} aria-pressed={liked} aria-label="좋아요" className="grid size-7 cursor-pointer place-items-center">
<HeartIcon className={liked ? 'fill-(--heart) stroke-(--heart)' : 'fill-none stroke-(--ink)'} />
</button>
@@ -338,16 +424,6 @@ function FullCard({ post }: PostProps) {
<button type="button" onClick={share} aria-label="보내기" className="grid size-7 cursor-pointer place-items-center">
<SendIcon className="fill-none stroke-(--ink) [stroke-linecap:round] [stroke-linejoin:round]" />
</button>
{n > 1 && (
<span className="absolute left-1/2 flex -translate-x-1/2 gap-1" aria-hidden="true">
{post.slides.map((_, k) => (
<i key={k} className={cx('size-1.5 rounded-full', k === index ? 'bg-(--rain)' : 'bg-[#cfd8e6]')} />
))}
</span>
)}
<button type="button" onClick={toggleSave} aria-pressed={saved} aria-label="저장" className="ml-auto grid size-7 cursor-pointer place-items-center">
<SaveIcon className={cx('stroke-(--ink) [stroke-linejoin:round]', saved ? 'fill-(--ink)' : 'fill-none')} />
</button>
</div>
<p className="px-3 py-0.5 text-sm font-extrabold">좋아요 {likeCount.toLocaleString()}개</p>
<p className="px-3 py-0.5 text-sm">