mirror of
https://github.com/zed-industries/zed.git
synced 2024-10-28 09:17:12 +00:00
26 lines
616 B
TypeScript
26 lines
616 B
TypeScript
import { create } from "zustand"
|
|
import { ColorScheme } from "./color_scheme"
|
|
|
|
type ThemeState = {
|
|
theme: ColorScheme | undefined
|
|
setTheme: (theme: ColorScheme) => void
|
|
}
|
|
|
|
export const useThemeStore = create<ThemeState>((set) => ({
|
|
theme: undefined,
|
|
setTheme: (theme) => set(() => ({ theme })),
|
|
}))
|
|
|
|
export const useTheme = (): ColorScheme => {
|
|
const { theme } = useThemeStore.getState()
|
|
|
|
if (!theme) throw new Error("Tried to use theme before it was loaded")
|
|
|
|
return theme
|
|
}
|
|
|
|
export * from "./color_scheme"
|
|
export * from "./ramps"
|
|
export * from "./syntax"
|
|
export * from "./theme_config"
|