feat: 기념일 꾸밈 — 할로윈·빼빼로데이·크리스마스·추석 기간에만 이야기 주제와 구름 합치기 그림이 바뀜

frontend/src/b/holiday.ts 한 곳에 기간·주제·배경·게임 그림. ?holiday=<key> 로 미리 보기.
GA: game_start theme 추가, talk_post topic 6~9.
This commit is contained in:
minaChoi committed 2026-10-30 09:15:53 +09:00
1 parent 48299e3ac5
commit 4fec164364
36 files changed
+171 -13

No files matched your search

+2 -2
View File
@@ -10,7 +10,7 @@ import { slotAt } from '@nalssigak/shared/lib/weatherText'
import { track } from '../lib/analytics'
import { cx } from '../lib/utils'
import { useAuth } from './authContext'
import { createGame, DROP_Y, H, LEVELS, LINE_Y, loadBest, randomLevel, roundTarget, saveBest, W, windDir, type Game } from './cloudMerge'
import { createGame, DROP_Y, H, HOLIDAY, LEVELS, LINE_Y, loadBest, randomLevel, roundTarget, saveBest, W, windDir, type Game } from './cloudMerge'
import { useLevel } from './level'
import { iconSrc } from './lib'
import { useRegion } from './regionContext'
@@ -213,7 +213,7 @@ export function CloudMergePage() {
const onUp = (e: PointerEvent<HTMLCanvasElement>) => {
const game = gameRef.current
if (!game || over || performance.now() < coolRef.current) return
if (dropsRef.current === 0) track('game_start', { again: play > 0, logged_in: loggedIn, wind_ms: windMs })
if (dropsRef.current === 0) track('game_start', { again: play > 0, logged_in: loggedIn, wind_ms: windMs, theme: HOLIDAY?.key ?? 'basic' })
dropsRef.current += 1
game.drop(nextRef.current, toX(e))
coolRef.current = performance.now() + 450
+2 -2
View File
@@ -5,7 +5,7 @@ import { cx } from '../lib/utils'
import { useAuth } from './authContext'
import { useSheet } from './sheetContext'
import { FeedComposer, TalkCard } from './talk'
import { TOPICS, useMyTalks, useTopicTalks } from './talkState'
import { openTopics, TOPICS, useMyTalks, useTopicTalks } from './talkState'
import { Rail, Sec } from './ui'
type Tab = TalkTopic | 'all' | 'mine'
@@ -34,7 +34,7 @@ export function TalkPage() {
const topicList = useTopicTalks(tab === 'all' || tab === 'mine' ? undefined : tab)
const mineList = useMyTalks(tab === 'mine' && loggedIn)
const { talks, loaded, more, loadMore } = tab === 'mine' ? mineList : topicList
const tabs: (readonly [Tab, string])[] = [['all', '전체'], ...TOPICS, ['mine', '내 글']]
const tabs: (readonly [Tab, string])[] = [['all', '전체'], ...openTopics(), ['mine', '내 글']]
const go = (k: Tab) => setParams(k === 'mine' ? { mine: '1' } : k === 'all' ? {} : { topic: String(k) }, { replace: true })
return (
+6 -1
View File
@@ -1,7 +1,8 @@
import Matter from 'matter-js'
import { currentHoliday } from './holiday'
/** 작은 것부터 큰 것 순서. 같은 단계 둘이 닿으면 다음 단계로 합쳐지고, 해 둘은 사라지며 보너스 */
export const LEVELS = [
const BASE = [
{ icon: 'muggy', name: '물방울', r: 15, color: '#d9f0ff' },
{ icon: 'snow', name: '눈송이', r: 21, color: '#e4ecff' },
{ icon: 'cloud', name: '구름', r: 28, color: '#f1f3f8' },
@@ -12,6 +13,10 @@ export const LEVELS = [
{ icon: 'sun', name: '해', r: 78, color: '#ffd2a1' },
] as const
/** 기념일엔 그림·이름만 그날 것으로 (크기·색·합치기 규칙은 그대로) */
export const HOLIDAY = currentHoliday()
export const LEVELS = BASE.map((l, i) => (HOLIDAY ? { ...l, ...HOLIDAY.game[i] } : l))
export const W = 360
export const H = 540
/** 이 선 위에 쌓인 채로 LOSE_MS 넘게 있으면 끝 */
+115
View File
@@ -0,0 +1,115 @@
import { TalkTopic } from '@nalssigak/shared/api/client/types.gen'
import { kst } from '@nalssigak/shared/lib'
/** 게임 8단계 그림을 바꾼다. 작은 것부터 큰 것 순서, 크기·색은 원래 단계 그대로 */
type GamePiece = { icon: string; name: string }
/**
* 기념일 꾸밈. 기간(KST, 양 끝 포함) 안에만 켜진다. 'MM-DD' 는 해마다, 'YYYY-MM-DD' 는 그해만(음력 기념일).
* 새 기념일: 여기에 한 줄 + TalkTopic(backend/common/enums.py) + 그림(public/b/icons, lib.ts OWN)
*/
export type Holiday = {
key: 'halloween' | 'pepero' | 'christmas' | 'chuseok'
name: string
ranges: readonly (readonly [string, string])[]
topic: TalkTopic
/** 글만 있는 사람 글 배경 (b.css b-bg-*) */
bg: string
game: readonly GamePiece[]
}
export const HOLIDAYS: readonly Holiday[] = [
{
key: 'halloween',
name: '할로윈',
ranges: [['10-31', '11-01']],
topic: TalkTopic.HALLOWEEN,
bg: 'night',
game: [
{ icon: 'candy', name: '사탕' },
{ icon: 'lollipop', name: '막대사탕' },
{ icon: 'spider', name: '거미' },
{ icon: 'spider_web', name: '거미줄' },
{ icon: 'bat', name: '박쥐' },
{ icon: 'ghost', name: '유령' },
{ icon: 'skull', name: '해골' },
{ icon: 'jack_o_lantern', name: '호박등' },
],
},
{
key: 'pepero',
name: '빼빼로데이',
ranges: [['11-11', '11-11']],
topic: TalkTopic.PEPERO,
bg: 'peach',
game: [
{ icon: 'candy', name: '사탕' },
{ icon: 'cookie', name: '쿠키' },
{ icon: 'chocolate_bar', name: '초콜릿' },
{ icon: 'ribbon', name: '리본' },
{ icon: 'love_letter', name: '편지' },
{ icon: 'red_heart', name: '하트' },
{ icon: 'heart_with_ribbon', name: '리본 하트' },
{ icon: 'wrapped_gift', name: '선물' },
],
},
{
key: 'christmas',
name: '크리스마스',
ranges: [['12-24', '12-25']],
topic: TalkTopic.CHRISTMAS,
bg: 'mint',
game: [
{ icon: 'snowflake', name: '눈송이' },
{ icon: 'star', name: '별' },
{ icon: 'bell', name: '종' },
{ icon: 'socks', name: '양말' },
{ icon: 'cookie', name: '쿠키' },
{ icon: 'wrapped_gift', name: '선물' },
{ icon: 'snowman', name: '눈사람' },
{ icon: 'christmas_tree', name: '트리' },
],
},
{
key: 'chuseok',
name: '추석',
ranges: [['2027-09-14', '2027-09-16']],
topic: TalkTopic.CHUSEOK,
bg: 'butter',
game: [
{ icon: 'chestnut', name: '밤' },
{ icon: 'pear', name: '배' },
{ icon: 'apple', name: '사과' },
{ icon: 'dango', name: '떡' },
{ icon: 'rabbit', name: '토끼' },
{ icon: 'maple', name: '단풍' },
{ icon: 'moon_viewing', name: '달맞이' },
{ icon: 'full_moon', name: '보름달' },
],
},
]
const pad = (n: number) => String(n).padStart(2, '0')
function inRange([from, to]: readonly [string, string], y: number, md: string) {
const day = from.length === 10 ? `${y}-${md}` : md
return from <= day && day <= to
}
/** 미리 보기 기념일: 주소의 ?holiday= 를 탭이 닫힐 때까지 기억 */
function previewKey() {
const q = new URLSearchParams(location.search).get('holiday')
if (q) sessionStorage.setItem('holiday', q)
return q ?? sessionStorage.getItem('holiday')
}
/** 오늘(KST) 켜진 기념일. ?holiday=christmas 로 미리 보기 */
export function currentHoliday(now = new Date()): Holiday | undefined {
const preview = previewKey()
if (preview) return HOLIDAYS.find((h) => h.key === preview)
const { y, mo, d } = kst(now)
const md = `${pad(mo)}-${pad(d)}`
return HOLIDAYS.find((h) => h.ranges.some((r) => inRange(r, y, md)))
}
export const holidayByTopic = (t?: number) => HOLIDAYS.find((h) => h.topic === t)
+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', 'crystal_ball', 'yin_yang', 'tshirt', 'clapper', 'speech', 'droplet', 'leaf', 'rainbow', 'milky_way', 'shooting_star', 'alarm_clock', 'check_mark_button', 'sparkles', 'warning', 'locked', 'money_bag', 'red_heart', 'briefcase', 'spiral_calendar', 'two_hearts', 'sunrise'])
const OWN = new Set(['fireworks', 'bulb', 'calendar', 'thermo', 'sheaf', 'popup', 'exhibition', 'concert', 'crystal_ball', 'yin_yang', 'tshirt', 'clapper', 'speech', 'droplet', 'leaf', 'rainbow', 'milky_way', 'shooting_star', 'alarm_clock', 'check_mark_button', 'sparkles', 'warning', 'locked', 'money_bag', 'red_heart', 'briefcase', 'spiral_calendar', 'two_hearts', 'sunrise', 'candy', 'lollipop', 'spider', 'spider_web', 'bat', 'ghost', 'skull', 'jack_o_lantern', 'cookie', 'chocolate_bar', 'ribbon', 'love_letter', 'heart_with_ribbon', 'wrapped_gift', 'snowflake', 'star', 'bell', 'socks', 'snowman', 'christmas_tree', 'pear', 'dango', 'moon_viewing', 'full_moon'])
/** 아이콘 이름 → 파일 경로 (공용 public/icons, B 전용 public/b/icons). 'none'(데이터 없는 칸)은 그림 없음 */
export function iconSrc(name: string) {
+4 -3
View File
@@ -15,7 +15,8 @@ import { cx } from '../lib/utils'
import { useAuth } from './authContext'
import { kst } from '@nalssigak/shared/lib'
import { useRegion } from './regionContext'
import { topicName, TOPICS, useMyTalks } from './talkState'
import { holidayByTopic } from './holiday'
import { openTopics, topicName, useMyTalks } from './talkState'
import { useSheet } from './sheetContext'
import { CameraIcon, CommentIcon, HeartIcon, SendIcon } from './svg'
import { Avatar, TAP44 } from './ui'
@@ -153,7 +154,7 @@ function Composer({ onDone }: { onDone?: (t: TalkData) => void }) {
</div>
)}
<div className="mt-2 flex flex-wrap gap-1.5" role="radiogroup" aria-label="글 주제">
{TOPICS.map(([k, label]) => (
{openTopics().map(([k, label]) => (
<button
key={k}
type="button"
@@ -377,7 +378,7 @@ export function TalkPost({ t }: { t: TalkData }) {
<MenuButton menu={menu} setMenu={setMenu} className="ml-auto" />
</div>
{menu !== 'closed' && <TalkMenu t={t} menu={menu} setMenu={setMenu} className="px-3 pb-2.5" />}
<div ref={bodyRef} onClick={onTap} className={cx('b-day aspect-[4/5] overflow-hidden', !src && `b-bg-${(t.topic && TOPIC_BG[t.topic]) || 'mint'} grid place-items-center px-7`)}>
<div ref={bodyRef} onClick={onTap} className={cx('b-day aspect-[4/5] overflow-hidden', !src && `b-bg-${(t.topic && (TOPIC_BG[t.topic] ?? holidayByTopic(t.topic)?.bg)) || 'mint'} grid place-items-center px-7`)}>
{src ? (
<img src={src} alt="" loading="lazy" className="size-full bg-[#eef4fc] object-cover" />
) : (
+8
View File
@@ -1,6 +1,7 @@
import { useInfiniteQuery } from '@tanstack/react-query'
import { listMyTalksInfiniteOptions, listTalksInfiniteOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
import { TalkTopic } from '@nalssigak/shared/api/client/types.gen'
import { currentHoliday, HOLIDAYS } from './holiday'
import { useRegion } from './regionContext'
// 글 주제와 이름
@@ -10,9 +11,16 @@ export const TOPICS = [
[TalkTopic.RAIN, '비·눈'],
[TalkTopic.FOLIAGE, '단풍·꽃'],
[TalkTopic.OUTFIT, '오늘 옷차림'],
...HOLIDAYS.map((h) => [h.topic, h.name] as const),
] as const
export const topicName = (t?: number) => TOPICS.find(([k]) => k === t)?.[1] ?? '동네 이야기'
/** 지금 고를 수 있는 주제: 기념일 주제는 그 기간에만 */
export function openTopics() {
const on = currentHoliday()?.topic
return TOPICS.filter(([k]) => !HOLIDAYS.some((h) => h.topic === k) || k === on)
}
/** 주제별 글 페이지 목록 (topic 없으면 전체) */
export function useTopicTalks(topic?: TalkTopic) {
const { region } = useRegion()
+2 -1
View File
@@ -1,4 +1,5 @@
import type { PinnedKey } from '../b/pinnedLike'
import type { Holiday } from '../b/holiday'
import type { SheetState } from '../b/sheetContext'
/** GA4로 보내는 이벤트와 값. 목록은 docs/이벤트_추적.md */
@@ -37,7 +38,7 @@ type Events = {
today_icon: { icon: string }
saju_input: { with_time: boolean }
saju_view: { scene: string; score: number; strength: string; top_element: string }
game_start: { again: boolean; logged_in: boolean; wind_ms: number }
game_start: { again: boolean; logged_in: boolean; wind_ms: number; theme: 'basic' | Holiday['key'] }
game_round: { round: number; score: number; logged_in: boolean }
game_over: { round: number; score: number; best: boolean; drops: number }
toss_intro_start: Record<string, never>