feat: 오늘 탭 아이콘 줄 — 오늘 타로·오늘 코디는 창으로, 단풍 지도·쇼츠·동네 이야기는 페이지로, 내 각은 그 줄로

- 오늘 한 장 칸을 오늘 타로 창으로 옮김. 안 뽑았으면 빨간 점, 뽑았으면 n일째 (로그인 안 하면 기기 기록으로 계산)
- 오늘 코디: 오늘 피드에 올린 코디 카드를 창으로 (GET /v1/card/latest?template=ootd), 오늘 처음 보면 빨간 점
- 단풍 지도 아이콘은 단풍철에만, 아이콘 4개 추가 (Fluent 3D)
- GA4 today_icon
This commit is contained in:
minaChoi committed 2026-10-28 14:37:55 +09:00
1 parent c37773f48f
commit 045d8d6cf0
20 files changed
+347 -70

No files matched your search

+5 -1
View File
@@ -36,6 +36,8 @@ import { useInstall, useInstallable } from './install'
import { InstallSheet } from './installBanner'
import { ARTICLE_CAT, SHEET_CLOSE_MS, SHEET_OPEN_MS } from './lib'
import { MixSheet, MyGakSheet } from './myGak'
import { TarotSheet } from './fortune'
import { OotdSheet } from './todayIcons'
import { ownPage, useRegion } from './regionContext'
import { WeatherWhySheet } from './weatherWhy'
import { useSky } from './skyContext'
@@ -86,7 +88,7 @@ export function SheetProvider({ children }: { children: ReactNode }) {
)
}
const TITLES = { article: '읽을거리', seasonWeek: '이번 주 특집', share: '보내기', comments: '댓글', login: '로그인', me: '내 정보', region: '지역 바꾸기', install: '홈 화면에 추가', weatherWhy: '날씨 점수는 이렇게 나와요', talk: '이야기' } as const
const TITLES = { article: '읽을거리', seasonWeek: '이번 주 특집', share: '보내기', comments: '댓글', login: '로그인', me: '내 정보', region: '지역 바꾸기', install: '홈 화면에 추가', weatherWhy: '날씨 점수는 이렇게 나와요', talk: '이야기', tarot: '오늘 타로', ootd: '오늘 코디' } as const
/** 아래에서 올라오는 창: 네이티브 <dialog>라 ESC·포커스 가두기·포커스 되돌리기가 기본으로 된다 */
function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void }) {
@@ -173,6 +175,8 @@ function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void
{shown.type === 'myGak' && <MyGakSheet gak={shown.gak} shot={shown.shot} onDone={onClose} />}
{shown.type === 'install' && <InstallSheet />}
{shown.type === 'weatherWhy' && <WeatherWhySheet d={shown.why} />}
{shown.type === 'tarot' && <TarotSheet />}
{shown.type === 'ootd' && <OotdSheet />}
{shown.type === 'talk' && <TalkSheet talk={shown.talk} />}
</div>
)}
+5 -3
View File
@@ -23,7 +23,7 @@ import { FoliageCard } from './foliageMap'
import { InstallBanner } from './installBanner'
import { MoonArt } from './moon'
import { MyGakRow } from './myGak'
import { TodayCard } from './fortune'
import { MY_GAK_ID, TodayIcons } from './todayIcons'
import { fromShare } from './myGakState'
import { PostCard, PostCardSkel, PostFrame } from './Post'
import { usePinnedLike } from './pinnedLike'
@@ -639,12 +639,14 @@ export function TodayPage() {
// 피드 칸은 전국 공통이라 지역이 바뀌어도 글 번호가 같다. 지역마다 새로 그려 넘긴 슬라이드·펼친 상태가 남지 않게 한다
<section key={region.code} aria-label="오늘" aria-busy={load === 'loading'} className={cx('transition-opacity', feed.isPlaceholderData && 'opacity-60')}>
<Hero hero={f?.hero} post={f?.hero_post} today={today.data} ranked={stories} all={f?.stories ?? []} feedLoad={load} todayLoad={loadOf(today)} />
<TodayCard />
<TodayIcons />
<ShortsRail />
<FeedComposer />
{mine.length > 0 && <TalkGroup title="오늘 내 글" talks={mine} href="/talk?mine=1" />}
{raining && group(TalkTopic.RAIN)}
<MyGakRow />
<div id={MY_GAK_ID} className="scroll-mt-16">
<MyGakRow />
</div>
{/* 실패 안내는 여기 한 번만, 각 카드 스켈레톤과 같은 크기로 */}
{stories.some((g) => g.active) ? (
<GakCard items={stories} post={f?.gak_post} place={region.name.split(' ').at(-1)!} at={sloted ? `${PREVIEW[preview].label} 기준` : nowAt ? `${kst(nowAt).h}시 기준` : '오늘 기준'} />
+83 -59
View File
@@ -9,7 +9,7 @@ import { cx } from '../lib/utils'
import { useAuth } from './authContext'
import { useRegion } from './regionContext'
import { useSheet } from './sheetContext'
import { Ic, Sec } from './ui'
import { Ic } from './ui'
const KEY = 'nalssigak.b.fortune'
// 기기에 남기는 날 수 (서버도 이 안쪽만 받는다)
@@ -63,7 +63,7 @@ async function draw(regionCode: string, cardCode?: string, days: string[] = []):
}
/** 오늘 카드·행운·체크인. 로그인했으면 서버, 아니면 이 기기에 있는 오늘 카드로 행운만 서버에서 받는다 */
function useTodayCard() {
export function useTodayCard() {
const { loggedIn } = useAuth()
const { region } = useRegion()
const queryClient = useQueryClient()
@@ -132,8 +132,35 @@ function useTodayCard() {
return { today, log, loading, pick, saveLog, loggedIn }
}
/** 오늘 탭 '오늘 한 장': 하루 한 장 뽑는 날씨 카드, 실제 날씨로 정한 행운, 연속 도장, 저녁엔 체크인 */
export function TodayCard() {
const shift = (day: string, n: number) => new Date(Date.parse(`${day}T00:00:00Z`) + n * 86_400_000).toISOString().slice(0, 10)
/** 서버 streak 과 같은 규칙: 오늘(안 뽑았으면 어제)부터 거꾸로 이어 뽑은 날 수, 하루 빠진 날은 7일에 한 번 봐준다 */
function localStreak(days: Set<string>, today: string) {
let d = days.has(today) ? today : shift(today, -1)
let count = 0
const rests: string[] = []
for (;;) {
if (days.has(d)) count++
else if (days.has(shift(d, -1)) && rests.every((r) => (Date.parse(r) - Date.parse(d)) / 86_400_000 >= 7)) rests.push(d)
else return count
d = shift(d, -1)
}
}
/** 아이콘 줄의 오늘 타로 표시: 오늘 뽑았는지, 이어 뽑은 날 수 (로그인 안 했으면 이 기기 기록으로, 서버를 부르지 않는다) */
export function useTarotBadge() {
const { loggedIn } = useAuth()
const { region } = useRegion()
const saved = useSyncExternalStore(subscribe, () => local)
const server = useQuery({ ...getFortuneTodayOptions({ query: { region: region.code } }), enabled: loggedIn, staleTime: 5 * 60_000 })
if (loggedIn) return { drawn: !!server.data?.card, streak: server.data?.streak ?? 0 }
const day = todayKst()
const days = new Set(saved.draws.map((d) => d.day))
return { drawn: days.has(day), streak: days.has(day) ? localStreak(days, day) : 0 }
}
/** 오늘 타로 창: 하루 한 장 뽑는 날씨 카드, 실제 날씨로 정한 행운, 연속 도장, 저녁엔 체크인 */
export function TarotSheet() {
const { today, log, loading, pick, saveLog, loggedIn } = useTodayCard()
const { open } = useSheet()
const shot = useRef<HTMLDivElement>(null)
@@ -147,63 +174,60 @@ export function TodayCard() {
}
return (
<>
<Sec title="오늘 한 장" />
<div className="mx-4 rounded-[22px] bg-white p-3 shadow-[inset_0_-5px_0_var(--shade)]">
{!card ? (
<button
type="button"
onClick={() => pick.mutate()}
disabled={loading || pick.isPending}
className="mx-auto flex w-full cursor-pointer flex-col items-center gap-2"
>
<img src="/fortune/back.webp" alt="" className={cx('aspect-[2/3] w-[150px] rounded-2xl object-cover', (loading || pick.isPending) && 'animate-pulse')} />
<span className="font-jua text-[16px] text-(--orange)">눌러서 오늘 카드 뽑기</span>
</button>
) : (
<div ref={shot} className="b-card-flip rounded-2xl bg-white">
<div className="flex gap-3">
<img src={`/fortune/${card.code}.webp`} alt={card.name} className="aspect-[2/3] w-[112px] shrink-0 rounded-xl object-cover" />
<div className="flex min-w-0 flex-col justify-center gap-1.5">
<b className="font-jua text-[22px] leading-tight font-normal">{card.name}</b>
<p className="m-0 text-[14px] leading-snug font-semibold text-(--ink2)">{card.reading}</p>
</div>
<div className="px-4 pb-2">
{!card ? (
<button
type="button"
onClick={() => pick.mutate()}
disabled={loading || pick.isPending}
className="mx-auto flex w-full cursor-pointer flex-col items-center gap-2"
>
<img src="/fortune/back.webp" alt="" className={cx('aspect-[2/3] w-[150px] rounded-2xl object-cover', (loading || pick.isPending) && 'animate-pulse')} />
<span className="font-jua text-[16px] text-(--orange)">눌러서 오늘 카드 뽑기</span>
</button>
) : (
<div ref={shot} className="b-card-flip rounded-2xl bg-white">
<div className="flex gap-3">
<img src={`/fortune/${card.code}.webp`} alt={card.name} className="aspect-[2/3] w-[112px] shrink-0 rounded-xl object-cover" />
<div className="flex min-w-0 flex-col justify-center gap-1.5">
<b className="font-jua text-[22px] leading-tight font-normal">{card.name}</b>
<p className="m-0 text-[14px] leading-snug font-semibold text-(--ink2)">{card.reading}</p>
</div>
{luck && (
<dl className="m-0 mt-3 grid grid-cols-2 gap-1.5">
<Luck label="행운 시간" value={luck.time} sub="날씨가 가장 좋은 때" />
<Luck label="행운 장소" value={luck.place} />
<Luck label="행운 색" value={card.color} swatch={card.hex} />
<Luck label="오늘 1위" value={luck.top_gak} icon={luck.top_icon} />
</dl>
)}
<p className="m-0 mt-2 text-center text-[11px] font-semibold text-(--ink3)">재미로 보는 날씨 운세</p>
</div>
)}
{(streak > 0 || card) && (
<div className="mt-2.5 flex items-center gap-1.5">
{streak > 0 && (
<>
<span className="flex gap-1" aria-hidden>
{Array.from({ length: STAMPS }, (_, i) => (
<i key={i} className={cx('grid size-[18px] place-items-center rounded-full text-[10px] not-italic', i < filled ? 'bg-(--orange) text-white' : 'bg-[#ffe2cf]')}>
{i < filled ? '✓' : ''}
</i>
))}
</span>
<span className="text-xs font-bold text-(--ink2)">{streak}일째</span>
</>
)}
{card && (
<button type="button" onClick={share} className="ml-auto cursor-pointer rounded-full bg-(--ink) px-4 py-1.5 text-[13px] font-extrabold text-white">
공유
</button>
)}
</div>
)}
{card && today?.checkin_open && <CheckIn log={log} saving={saveLog.isPending} onSave={(v) => saveLog.mutate(v)} anon={!loggedIn} />}
</div>
</>
{luck && (
<dl className="m-0 mt-3 grid grid-cols-2 gap-1.5">
<Luck label="행운 시간" value={luck.time} sub="날씨가 가장 좋은 때" />
<Luck label="행운 장소" value={luck.place} />
<Luck label="행운 색" value={card.color} swatch={card.hex} />
<Luck label="오늘 1위" value={luck.top_gak} icon={luck.top_icon} />
</dl>
)}
<p className="m-0 mt-2 text-center text-[11px] font-semibold text-(--ink3)">재미로 보는 날씨 운세</p>
</div>
)}
{(streak > 0 || card) && (
<div className="mt-2.5 flex items-center gap-1.5">
{streak > 0 && (
<>
<span className="flex gap-1" aria-hidden>
{Array.from({ length: STAMPS }, (_, i) => (
<i key={i} className={cx('grid size-[18px] place-items-center rounded-full text-[10px] not-italic', i < filled ? 'bg-(--orange) text-white' : 'bg-[#ffe2cf]')}>
{i < filled ? '✓' : ''}
</i>
))}
</span>
<span className="text-xs font-bold text-(--ink2)">{streak}일째</span>
</>
)}
{card && (
<button type="button" onClick={share} className="ml-auto cursor-pointer rounded-full bg-(--ink) px-4 py-1.5 text-[13px] font-extrabold text-white">
공유
</button>
)}
</div>
)}
{card && today?.checkin_open && <CheckIn log={log} saving={saveLog.isPending} onSave={(v) => saveLog.mutate(v)} anon={!loggedIn} />}
</div>
)
}
+1 -1
View File
@@ -2,7 +2,7 @@ import type { CSSProperties } from 'react'
import { ARTICLE_LABEL } from '@nalssigak/shared/lib'
const SHARED = new Set(['bear', 'bike', 'bronze', 'camping', 'carwash', 'chimaek', 'cloud', 'coldwind', 'delivery', 'dog', 'garden', 'glasses', 'gold', 'hiking', 'iced_hot', 'jjamppong', 'laundry', 'letter', 'makeup', 'makgeolli', 'maple', 'moon', 'muggy', 'naengmyeon', 'photo', 'picnic', 'rabbit', 'rain', 'running', 'silver', 'snow', 'stars', 'sun_cloud', 'sun', 'sunset', 'taxi', 'umbrella', 'vent', 'walk', 'yajang', 'baseball', 'study', 'netflix', 'chestnut', 'peanut', 'tangerine', 'sweet_potato', 'fallen_leaf', 'kimchi', 'apple', 'mask', 'golf', 'jipkok', 'fishing', 'drive', 'kite', 'waterplay', 'riverwind', 'trot', 'pajeon', 'bingsu', 'blanket', 'indoordry', 'flower', 'bungeoppang', 'singing_rain', 'hangang', 'themepark', 'date', 'frizz', 'boiler', 'sunscreen', 'mosquito', 'tennis', 'hyodo', 'thanks', 'gift', 'party', 'game', 'selfie', 'sentimental', 'ginkgo'])
const OWN = new Set(['fireworks', 'bulb', 'calendar', 'thermo', 'sheaf', 'popup', 'exhibition', 'concert'])
const OWN = new Set(['fireworks', 'bulb', 'calendar', 'thermo', 'sheaf', 'popup', 'exhibition', 'concert', 'crystal_ball', 'tshirt', 'clapper', 'speech'])
/** 아이콘 이름 → 파일 경로 (공용 public/icons, B 전용 public/b/icons). 'none'(데이터 없는 칸)은 그림 없음 */
export function iconSrc(name: string) {
+2
View File
@@ -21,6 +21,8 @@ export type SheetState =
| { type: 'install' }
| { type: 'weatherWhy'; why: WeatherWhyPayload }
| { type: 'talk'; talk: TalkData }
| { type: 'tarot' }
| { type: 'ootd' }
| null
export type SheetApi = { open: (s: Exclude<SheetState, null>) => void; close: () => void }
+136
View File
@@ -0,0 +1,136 @@
import { useState, type ReactNode } from 'react'
import { Link } from 'react-router'
import { useQuery } from '@tanstack/react-query'
import { getPostOptions, latestCardOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
import { kst } from '@nalssigak/shared/lib'
import { track } from '../lib/analytics'
import { useFoliage } from './foliage'
import { useTarotBadge } from './fortune'
import { PostCard, PostCardSkel } from './Post'
import { useRegion } from './regionContext'
import { useSheet } from './sheetContext'
import { Ic, Rail } from './ui'
/** 오늘 탭 '내 각' 줄 자리 (아이콘에서 거기로 내려간다) */
export const MY_GAK_ID = 'my-gak'
const OOTD_SEEN = 'nalssigak.b.ootdSeen'
function readSeen() {
try {
return Number(localStorage.getItem(OOTD_SEEN)) || null
} catch {
// 사파리 프라이빗 모드 등에서는 저장소를 못 쓴다 → 매번 새로 보는 것으로
return null
}
}
function markSeen(postId: number) {
try {
localStorage.setItem(OOTD_SEEN, String(postId))
} catch (e) {
console.warn('[ootd] 본 코디를 저장하지 못함', e)
}
}
function isToday(iso?: string | null) {
if (!iso) return false
const a = kst(iso)
const b = kst(new Date())
return a.y === b.y && a.mo === b.mo && a.d === b.d
}
const useLatestOotd = () => useQuery({ ...latestCardOptions({ query: { template: 'ootd' } }), staleTime: 10 * 60_000 })
type Item = { key: string; label: string; icon: string; badge?: ReactNode; to?: string; onClick?: () => void }
const Dot = () => <span className="absolute -top-0.5 -right-0.5 size-[11px] rounded-full border-2 border-white bg-[#ff4d4f]" />
/** 오늘 탭 히어로 아래 아이콘 줄: 누르면 창이 뜨거나 그 페이지로 간다. 오늘 아직 안 본 것엔 빨간 점 */
export function TodayIcons() {
const { open } = useSheet()
const tarot = useTarotBadge()
const ootd = useLatestOotd().data
const [seen, setSeen] = useState(readSeen)
const { inSeason } = useFoliage()
const newOotd = !!ootd?.post_id && isToday(ootd.published_at) && seen !== ootd.post_id
const items: Item[] = [
{
key: 'tarot',
label: '오늘 타로',
icon: 'crystal_ball',
badge: tarot.drawn ? (
<span className="absolute -bottom-1.5 left-1/2 -translate-x-1/2 rounded-full bg-(--orange) px-1.5 text-[9.5px] leading-4 font-extrabold whitespace-nowrap text-white">{tarot.streak}일째</span>
) : (
<Dot />
),
onClick: () => open({ type: 'tarot' }),
},
{
key: 'ootd',
label: '오늘 코디',
icon: 'tshirt',
badge: newOotd ? <Dot /> : null,
onClick: () => {
if (ootd?.post_id) {
markSeen(ootd.post_id)
setSeen(ootd.post_id)
}
open({ type: 'ootd' })
},
},
...(inSeason ? [{ key: 'foliage', label: '단풍 지도', icon: 'maple', to: '/foliage' }] : []),
{ key: 'shorts', label: '쇼츠', icon: 'clapper', to: '/shorts' },
{ key: 'myGak', label: '내 각', icon: 'rabbit', onClick: () => document.getElementById(MY_GAK_ID)?.scrollIntoView({ behavior: 'smooth', block: 'start' }) },
{ key: 'talk', label: '동네 이야기', icon: 'speech', to: '/talk' },
]
const tile = (it: Item) => (
<>
<span className="relative grid size-[52px] place-items-center rounded-[17px] bg-white shadow-[inset_0_-4px_0_var(--shade)]">
<Ic name={it.icon} className="size-8" />
{it.badge}
</span>
<span className="mt-1.5 text-[11.5px] font-extrabold whitespace-nowrap text-(--ink2)">{it.label}</span>
</>
)
const cls = 'flex w-[60px] cursor-pointer flex-col items-center'
return (
<Rail label="바로 가기" className="pb-2">
{items.map((it) =>
it.to ? (
<Link key={it.key} to={it.to} onClick={() => track('today_icon', { icon: it.key })} className={cls}>
{tile(it)}
</Link>
) : (
<button
key={it.key}
type="button"
onClick={() => {
track('today_icon', { icon: it.key })
it.onClick?.()
}}
className={cls}
>
{tile(it)}
</button>
),
)}
</Rail>
)
}
/** 오늘 코디 창: 오늘 피드에 올린 코디 카드 (오늘 것이 없으면 안내) */
export function OotdSheet() {
const { region } = useRegion()
const latest = useLatestOotd()
const postId = latest.data?.post_id
const today = isToday(latest.data?.published_at)
const post = useQuery({ ...getPostOptions({ path: { post_id: postId ?? 0 }, query: { region: region.code } }), enabled: !!postId && today })
if (latest.isPending || (postId && today && post.isPending)) return <PostCardSkel />
if (!postId || !today || !post.data?.post) return <p className="m-0 px-4 py-10 text-center text-[14px] font-semibold text-(--ink2)">아직 오늘 코디가 없어요</p>
return <PostCard post={post.data.post} />
}
+1
View File
@@ -30,6 +30,7 @@ type Events = {
my_gak_save: { gak_name: string }
fortune_draw: { card: string }
day_log: { mood: number; went_out: boolean; card_hit: boolean | null }
today_icon: { icon: string }
toss_intro_start: Record<string, never>
install_banner_close: Record<string, never>
}