1
1
import { FC , PropsWithChildren , createContext , useContext , useMemo } from 'react'
2
2
import { ThemeProvider as MuiThemeProvider , createTheme } from '@mui/material/styles'
3
3
import ScopedCssBaseline from '@mui/material/ScopedCssBaseline'
4
+ import { LocalizationProvider } from '@mui/x-date-pickers'
5
+ import { AdapterMoment } from '@mui/x-date-pickers/AdapterMoment'
4
6
import { ConfigProvider , theme } from 'antd'
5
7
import heIL from 'antd/es/locale/he_IL'
6
8
import { useTranslation } from 'react-i18next'
@@ -38,6 +40,8 @@ export const ThemeProvider: FC<PropsWithChildren> = ({ children }) => {
38
40
// Re-create the theme when the theme changes or the language changes
39
41
const theme = useMemo ( ( ) => {
40
42
const direction = i18n . language === 'he' ? 'rtl' : 'ltr'
43
+ document . documentElement . dir = direction
44
+ document . documentElement . lang = i18n . language
41
45
return createTheme ( {
42
46
direction,
43
47
palette : {
@@ -47,22 +51,24 @@ export const ThemeProvider: FC<PropsWithChildren> = ({ children }) => {
47
51
} , [ isDarkTheme , i18n . language ] )
48
52
49
53
return (
50
- < ConfigProvider
51
- direction = { i18n . dir ( ) }
52
- locale = { heIL }
53
- theme = { {
54
- algorithm : isDarkTheme ? darkAlgorithm : defaultAlgorithm ,
55
- token : {
56
- colorBgBase : isDarkTheme ? '#1c1d1c' : '#ffffff' ,
57
- colorTextBase : isDarkTheme ? '#ffffff' : '#000000' ,
58
- } ,
59
- } } >
60
- < MuiThemeProvider theme = { theme } >
61
- < ScopedCssBaseline enableColorScheme >
62
- < ThemeContext . Provider value = { contextValue } > { children } </ ThemeContext . Provider >
63
- </ ScopedCssBaseline >
64
- </ MuiThemeProvider >
65
- </ ConfigProvider >
54
+ < LocalizationProvider dateAdapter = { AdapterMoment } adapterLocale = { i18n . language } >
55
+ < ConfigProvider
56
+ direction = { i18n . dir ( ) }
57
+ locale = { heIL }
58
+ theme = { {
59
+ algorithm : isDarkTheme ? darkAlgorithm : defaultAlgorithm ,
60
+ token : {
61
+ colorBgBase : isDarkTheme ? '#1c1d1c' : '#ffffff' ,
62
+ colorTextBase : isDarkTheme ? '#ffffff' : '#000000' ,
63
+ } ,
64
+ } } >
65
+ < MuiThemeProvider theme = { theme } >
66
+ < ScopedCssBaseline enableColorScheme >
67
+ < ThemeContext . Provider value = { contextValue } > { children } </ ThemeContext . Provider >
68
+ </ ScopedCssBaseline >
69
+ </ MuiThemeProvider >
70
+ </ ConfigProvider >
71
+ </ LocalizationProvider >
66
72
)
67
73
}
68
74
0 commit comments