- feat/weather-game(구름 합치기) 브랜치를 합쳐 아이콘에서 바로 열림 - 오늘 코디 아이콘·창과 그걸 위해 넣은 GET /v1/card/latest 를 걷어냄 - 오늘 타로는 features.ts HIDDEN 으로 숨김 (아이콘 줄·각 모으는 법에서 빠짐, 안내 문구에서도 타로를 뺌)
39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import type { MyGak } from './myGakState'
|
|
import type { TalkData } from '@nalssigak/shared/api/client/types.gen'
|
|
import type { WeatherWhyPayload } from './weatherWhy'
|
|
import { createContext, use } from 'react'
|
|
/** square: 1:1 비율일 때 slides 대신 찍을 틀 (없으면 slides). url: 같이 보낼 링크 (없으면 사이트 주소) */
|
|
export type SharePayload = { title: string; slides: HTMLElement[]; square?: HTMLElement[]; url?: string }
|
|
|
|
type CommentsState = { type: 'comments'; postId: number; draft?: string }
|
|
|
|
export type SheetState =
|
|
| { type: 'gak'; indexId: number }
|
|
| { type: 'article'; articleId: number }
|
|
| { type: 'share'; share: SharePayload }
|
|
| CommentsState
|
|
| { type: 'seasonWeek' }
|
|
| { type: 'login'; then?: CommentsState; why?: 'level' }
|
|
| { type: 'me' }
|
|
| { type: 'region' }
|
|
| { type: 'mix'; shared?: MyGak }
|
|
| { type: 'myGak'; gak: MyGak; shot?: HTMLElement | null }
|
|
| { type: 'install' }
|
|
| { type: 'weatherWhy'; why: WeatherWhyPayload }
|
|
| { type: 'talk'; talk: TalkData }
|
|
| { type: 'tarot' }
|
|
| { type: 'level' }
|
|
| { type: 'levelUp'; level: number }
|
|
| { type: 'gameHelp' }
|
|
| null
|
|
|
|
export type SheetApi = { open: (s: Exclude<SheetState, null>) => void; close: () => void }
|
|
|
|
export const SheetContext = createContext<SheetApi | null>(null)
|
|
|
|
export function useSheet() {
|
|
const ctx = use(SheetContext)
|
|
if (!ctx) throw new Error('useSheet must be used inside SheetProvider')
|
|
return ctx
|
|
}
|