2021-05-11 16:37:15 +02:00
|
|
|
import { createContext } from "react"
|
2021-04-21 15:37:12 +02:00
|
|
|
|
2021-04-23 02:18:06 +02:00
|
|
|
|
|
|
|
/**
|
2021-05-22 04:44:08 +02:00
|
|
|
* A React Context containing an object with the following elements:
|
2021-04-26 18:36:41 +02:00
|
|
|
* - `theme` - A string containing the name of the current theme.
|
|
|
|
* - `setTheme` - A function that allows changing the `theme`.
|
2021-04-23 02:18:06 +02:00
|
|
|
*
|
2021-04-26 18:36:41 +02: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 02:18:06 +02:00
|
|
|
*
|
|
|
|
* @type {React.Context}
|
|
|
|
*/
|
2021-04-26 18:36:41 +02:00
|
|
|
const ContextTheme = createContext({
|
|
|
|
isSet: false,
|
|
|
|
theme: "ThemeDark",
|
2021-05-18 01:44:34 +02:00
|
|
|
setTheme: () => console.error("Trying to setTheme while outside a ContextTheme.Provider!"),
|
2021-04-26 18:36:41 +02:00
|
|
|
})
|
2021-04-21 15:37:12 +02:00
|
|
|
export default ContextTheme
|