feat: forced file naming format (#2270)

This commit is contained in:
Himself65
2023-05-09 06:37:07 +08:00
committed by GitHub
parent 95bc5cac49
commit 4f99ad2db4
132 changed files with 208 additions and 100 deletions

View File

@@ -0,0 +1,31 @@
import type { ThemeProviderProps } from '@affine/component';
import { ThemeProvider as NextThemeProvider, useTheme } from 'next-themes';
import type { PropsWithChildren } from 'react';
import type React from 'react';
import { memo, useRef } from 'react';
const themes = ['dark', 'light'];
const DesktopThemeSync = memo(function DesktopThemeSync() {
const { theme } = useTheme();
const lastThemeRef = useRef(theme);
if (lastThemeRef.current !== theme) {
if (environment.isDesktop && theme) {
window.apis?.onThemeChange(theme);
}
lastThemeRef.current = theme;
}
return null;
});
export const ThemeProvider = ({
children,
...props
}: PropsWithChildren<ThemeProviderProps>) => {
return (
<NextThemeProvider themes={themes} enableSystem={true} {...props}>
{children}
<DesktopThemeSync />
</NextThemeProvider>
);
};