2021-06-21 21:35:28 +00:00
|
|
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
|
|
import { useCallback } from 'react'
|
|
|
|
import state, { useSelector } from 'state'
|
2021-07-10 20:39:29 +00:00
|
|
|
import { Theme } from 'types'
|
2021-05-14 22:56:41 +00:00
|
|
|
|
|
|
|
export default function useTheme() {
|
2021-07-10 20:39:29 +00:00
|
|
|
const theme: Theme = useSelector((state) =>
|
2021-06-21 21:35:28 +00:00
|
|
|
state.data.settings.isDarkMode ? 'dark' : 'light'
|
2021-05-14 22:56:41 +00:00
|
|
|
)
|
|
|
|
|
2021-06-21 21:35:28 +00:00
|
|
|
const toggleTheme = useCallback(() => state.send('TOGGLED_THEME'), [])
|
2021-05-14 22:56:41 +00:00
|
|
|
|
|
|
|
return { theme, toggleTheme }
|
|
|
|
}
|