- /type 에서 질문 8개에 답하면 날씨 유형 8개 중 하나가 나온다 (/type/{유형})
- 결과를 친구에게 보내면 그 결과의 주소가 가고, 미리보기(제목·설명·그림)가 유형마다 다르다
- 링크로 들어오면 그 결과가 그대로 보이고 '테스트 해 보기'로 이어진다
- 결과마다 다른 유형과의 궁합(찰떡·잘 맞아요·서로 달라서 재밌어요·삐걱삐걱)과
오늘 잘 맞는 각 3개(풀 6개에서 날짜+유형 기준으로 고정)를 보여 준다
- 오늘 탭 아이콘 줄에 '날씨 유형' 추가, /type 첫 진입은 '날씨 불러오는 중' 덮개를 건너뜀
- GA4 이벤트 7개: type_landing, type_start, type_result, type_share, type_gak, type_match, type_to_today
- 프론트 테스트 추가 (frontend 에서 npm test)
- 유형 그림 8장과 미리보기 그림 9장은 임시 그림 (진짜 그림으로 교체 예정, TODO.md)
- 설계·계획 문서 추가, TODO.md 의 '4주 새 기능 동결' 행 삭제
90 lines
3.8 KiB
TypeScript
90 lines
3.8 KiB
TypeScript
import { useState, type ReactNode } from 'react'
|
|
import { Link } from 'react-router'
|
|
import { track } from '../lib/analytics'
|
|
import { HIDDEN } from './features'
|
|
import { firstSnowInSeason } from './firstSnow'
|
|
import { useFoliage } from './foliage'
|
|
import { useTarotBadge } from './fortune'
|
|
import { sajuSeenToday } from './SajuPage'
|
|
import { useSunrise } from './sunrise'
|
|
import { useSheet } from './sheetContext'
|
|
import { Ic, Rail } from './ui'
|
|
import { showTypeDot } from './weatherType'
|
|
|
|
/** 오늘 탭 '내 각' 줄 자리 (아이콘에서 거기로 내려간다) */
|
|
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 [snowSeason] = useState(() => firstSnowInSeason())
|
|
const { inSeason: sunriseSeason } = useSunrise()
|
|
|
|
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: 'type', label: '날씨 유형', icon: 'rainbow', badge: showTypeDot() ? <Dot /> : null, to: '/type' },
|
|
{ key: 'game', label: '날씨 게임', icon: 'game', to: '/game' },
|
|
// 계절 지도 칸: 단풍 지도 → 첫눈 지도 → 해돋이 지도 순으로 한 번에 하나만 나온다
|
|
...(inSeason ? [{ key: 'foliage', label: '단풍 지도', icon: 'maple', to: '/foliage' }] : []),
|
|
...(snowSeason ? [{ key: 'firstSnow', label: '첫눈 지도', icon: 'snow', to: '/first-snow' }] : []),
|
|
...(sunriseSeason ? [{ key: 'sunrise', label: '해돋이 지도', icon: 'sunset', to: '/sunrise' }] : []),
|
|
{ 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>
|
|
)
|
|
}
|
|
|