UNPKG

@hitachivantara/uikit-react-shared

Version:

Shared React contexts for the NEXT UI Kit.

35 lines (34 loc) 808 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({ activeTheme: void 0, colorModes: [], selectedMode: "light", changeMode: () => { }, rootId: void 0, // TODO: remove once backwards-compatibility is not needed anymore // @ts-expect-error removed from API interfaces to avoid usage themes: [], selectedTheme: "", changeTheme() { } }); function useEmotionCache() { return useContext(EmotionContext).cache; } export { EmotionContext, HvThemeContext, defaultCacheKey, defaultEmotionCache, useEmotionCache };