mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
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:
@@ -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>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user