14 lines
572 B
TypeScript
14 lines
572 B
TypeScript
import { createContext, use } from 'react'
|
|
import type { TimeKind } from './lib'
|
|
|
|
/** 화면 전체 하늘 배경의 시간대. 히어로의 미리보기 버튼으로 고른 값은 탭을 옮겨도 유지된다 */
|
|
export type SkyApi = { kind: TimeKind; preview: TimeKind | null; setServerKind: (k: TimeKind | null) => void; setPreview: (k: TimeKind | null) => void }
|
|
|
|
export const SkyContext = createContext<SkyApi | null>(null)
|
|
|
|
export function useSky() {
|
|
const ctx = use(SkyContext)
|
|
if (!ctx) throw new Error('useSky must be used inside SkyProvider')
|
|
return ctx
|
|
}
|