-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
ThemeLocaleProvider.tsx
43 lines (35 loc) · 1.22 KB
/
ThemeLocaleProvider.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import '@fontsource-variable/inter';
import 'overlayscrollbars/overlayscrollbars.css';
import { ChakraProvider, DarkMode, extendTheme, theme as _theme, TOAST_OPTIONS } from '@invoke-ai/ui-library';
import type { ReactNode } from 'react';
import { memo, useEffect, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
type ThemeLocaleProviderProps = {
children: ReactNode;
};
function ThemeLocaleProvider({ children }: ThemeLocaleProviderProps) {
const { i18n } = useTranslation();
const direction = i18n.dir();
const theme = useMemo(() => {
return extendTheme({
..._theme,
direction,
shadows: {
..._theme.shadows,
selectedForCompare:
'0px 0px 0px 1px var(--invoke-colors-base-900), 0px 0px 0px 4px var(--invoke-colors-green-400)',
hoverSelectedForCompare:
'0px 0px 0px 1px var(--invoke-colors-base-900), 0px 0px 0px 4px var(--invoke-colors-green-300)',
},
});
}, [direction]);
useEffect(() => {
document.body.dir = direction;
}, [direction]);
return (
<ChakraProvider theme={theme} toastOptions={TOAST_OPTIONS}>
<DarkMode>{children}</DarkMode>
</ChakraProvider>
);
}
export default memo(ThemeLocaleProvider);