- feat/weather-game(구름 합치기) 브랜치를 합쳐 아이콘에서 바로 열림 - 오늘 코디 아이콘·창과 그걸 위해 넣은 GET /v1/card/latest 를 걷어냄 - 오늘 타로는 features.ts HIDDEN 으로 숨김 (아이콘 줄·각 모으는 법에서 빠짐, 안내 문구에서도 타로를 뺌)
80 lines
3.0 KiB
TypeScript
80 lines
3.0 KiB
TypeScript
import { type ReactNode } from 'react'
|
|
import { Link } from 'react-router'
|
|
import { track } from '../lib/analytics'
|
|
import { HIDDEN } from './features'
|
|
import { useFoliage } from './foliage'
|
|
import { useTarotBadge } from './fortune'
|
|
import { sajuSeenToday } from './SajuPage'
|
|
import { useSheet } from './sheetContext'
|
|
import { Ic, Rail } from './ui'
|
|
|
|
/** 오늘 탭 '내 각' 줄 자리 (아이콘에서 거기로 내려간다) */
|
|
export const MY_GAK_ID = 'my-gak'
|
|
|
|
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 { inSeason } = useFoliage()
|
|
|
|
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: 'saju', label: '날씨 사주', icon: 'yin_yang', badge: sajuSeenToday() ? null : <Dot />, to: '/saju' },
|
|
{ key: 'game', label: '날씨 게임', icon: 'game', to: '/game' },
|
|
...(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' },
|
|
].filter((it) => !HIDDEN.has(it.key))
|
|
|
|
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>
|
|
)
|
|
}
|
|
|