feat(core): add edgelessTheme property and edgelessDefault theme setting (#8614)

close AF-1430 AF-1471

https://github.com/user-attachments/assets/d997ac6c-ce94-4fa4-ab34-29b36c7796ea
This commit is contained in:
JimmFly
2024-11-01 03:58:02 +00:00
parent 1f6cce2f5e
commit 10b1f233d9
28 changed files with 553 additions and 181 deletions

View File

@@ -1,12 +1,26 @@
import { ThemeProvider as NextThemeProvider } from 'next-themes';
import { AppThemeService, useService } from '@toeverything/infra';
import { ThemeProvider as NextThemeProvider, useTheme } from 'next-themes';
import type { PropsWithChildren } from 'react';
import { useEffect } from 'react';
const themes = ['dark', 'light'];
export function ThemeObserver() {
const { resolvedTheme } = useTheme();
const service = useService(AppThemeService);
useEffect(() => {
service.appTheme.theme$.next(resolvedTheme);
}, [resolvedTheme, service.appTheme.theme$]);
return null;
}
export const ThemeProvider = ({ children }: PropsWithChildren) => {
return (
<NextThemeProvider themes={themes} enableSystem={true}>
{children}
<ThemeObserver />
</NextThemeProvider>
);
};