1import { create } from "zustand"
2import { ColorScheme } from "./color_scheme"
3
4type ThemeState = {
5 theme: ColorScheme | undefined
6 setTheme: (theme: ColorScheme) => void
7}
8
9export const useThemeStore = create<ThemeState>((set) => ({
10 theme: undefined,
11 setTheme: (theme) => set(() => ({ theme })),
12}))
13
14export const useTheme = (): ColorScheme => {
15 const { theme } = useThemeStore.getState()
16
17 if (!theme) throw new Error("Tried to use theme before it was loaded")
18
19 return theme
20}
21
22export * from "./color_scheme"
23export * from "./ramps"
24export * from "./syntax"
25export * from "./theme_config"