mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-10 19:37:08 +02:00
* Upgrade to CRA 4.0.3 * Try to fix tests. No lucky * Fix new ESLint errors * Fix JS tests and remove unwanted dependency. (#1106) * Fix tests * Fix lint * Remove React v16 workaround (fixed in v17) * Force eslint to break on warnings * Lint now needs to be called explicitly in the pipeline Co-authored-by: Yash Jipkate <34203227+YashJipkate@users.noreply.github.com>
23 lines
692 B
JavaScript
23 lines
692 B
JavaScript
import { useSelector } from 'react-redux'
|
|
import useMediaQuery from '@material-ui/core/useMediaQuery'
|
|
import themes from './index'
|
|
import { AUTO_THEME_ID } from '../consts'
|
|
import config from '../config'
|
|
|
|
const useCurrentTheme = () => {
|
|
const prefersLightMode = useMediaQuery('(prefers-color-scheme: light)')
|
|
return useSelector((state) => {
|
|
if (state.theme === AUTO_THEME_ID) {
|
|
return prefersLightMode ? themes.LightTheme : themes.DarkTheme
|
|
}
|
|
const themeName =
|
|
state.theme ||
|
|
Object.keys(themes).find(
|
|
(t) => themes[t].themeName === config.defaultTheme
|
|
) ||
|
|
'DarkTheme'
|
|
return themes[themeName]
|
|
})
|
|
}
|
|
|
|
export default useCurrentTheme
|