diff --git a/src/contexts/color-mode/index.tsx b/src/contexts/color-mode/index.tsx index 077811d..4befbdc 100644 --- a/src/contexts/color-mode/index.tsx +++ b/src/contexts/color-mode/index.tsx @@ -1,5 +1,6 @@ import React, {PropsWithChildren, createContext, useEffect, useState} from 'react' -import {ThemeProvider} from '@mui/material/styles' +import {ThemeProvider, createTheme} from '@mui/material/styles' +import {ruRU} from '@mui/material/locale' import {CustomTheme} from './theme' type ColorModeContextType = { @@ -21,13 +22,11 @@ export const ColorModeContextProvider: React.FC = ({children} }, [mode]) const setColorMode = () => { - if (mode === 'light') { - setMode('dark') - } else { - setMode('light') - } + setMode((prevMode) => (prevMode === 'light' ? 'dark' : 'light')) } + const appliedTheme = createTheme(mode === 'light' ? CustomTheme.Light : CustomTheme.Dark, ruRU) + return ( = ({children} mode, }} > - {children} + {children} ) }