UNPKG

@hitachivantara/uikit-react-shared

Version:

Shared React contexts for the NEXT UI Kit.

31 lines (30 loc) 647 B
import { createContext, useContext } from "react"; import createCache from "@emotion/cache"; const defaultCacheKey = "hv"; const defaultEmotionCache = createCache({ key: defaultCacheKey, prepend: true }); const EmotionContext = createContext({ cache: defaultEmotionCache }); const HvThemeContext = createContext({ themes: [], activeTheme: void 0, colorModes: [], selectedTheme: "", selectedMode: "", changeTheme: () => { }, rootId: void 0 }); function useEmotionCache() { return useContext(EmotionContext).cache; } export { EmotionContext, HvThemeContext, defaultCacheKey, defaultEmotionCache, useEmotionCache };