2021-05-11 14:37:15 +00:00
|
|
|
import { createContext } from "react"
|
2021-04-21 13:37:12 +00:00
|
|
|
|
2021-04-23 00:18:06 +00:00
|
|
|
|
|
|
|
/**
|
2021-04-26 16:36:41 +00:00
|
|
|
* A context containing an object with the following elements:
|
|
|
|
* - `theme` - A string containing the name of the current theme.
|
|
|
|
* - `setTheme` - A function that allows changing the `theme`.
|
2021-04-23 00:18:06 +00:00
|
|
|
*
|
2021-04-26 16:36:41 +00:00
|
|
|
* If trying to access the context from outside a provider, the theme will be `ThemeDark`, and the function will display
|
|
|
|
* an error in the console.
|
2021-04-23 00:18:06 +00:00
|
|
|
*
|
|
|
|
* @type {React.Context}
|
|
|
|
*/
|
2021-04-26 16:36:41 +00:00
|
|
|
const ContextTheme = createContext({
|
|
|
|
isSet: false,
|
|
|
|
theme: "ThemeDark",
|
2021-05-17 23:44:34 +00:00
|
|
|
setTheme: () => console.error("Trying to setTheme while outside a ContextTheme.Provider!"),
|
2021-04-26 16:36:41 +00:00
|
|
|
})
|
2021-04-21 13:37:12 +00:00
|
|
|
export default ContextTheme
|