UNPKG

@mskcc/carbon-react

Version:

Carbon react components for the MSKCC DSM

37 lines (32 loc) 762 B
/** * MSKCC 2021, 2024 */ import * as React from 'react'; const MskThemeContext = /*#__PURE__*/React.createContext({ theme: 'light', setTheme: () => {} }); function MskThemeProvider(_ref) { let { children, theme: initialTheme = 'light' } = _ref; const [theme, setTheme] = React.useState(initialTheme); React.useEffect(() => { const root = document.documentElement; root.setAttribute('data-theme', theme); }, [theme]); return /*#__PURE__*/React.createElement(MskThemeContext.Provider, { value: { theme, setTheme } }, children); } /** * Get access to the current theme */ function useMskTheme() { return React.useContext(MskThemeContext); } export { MskThemeContext, MskThemeProvider, useMskTheme };