diff --git a/context/ThemeContext.tsx b/context/ThemeContext.tsx index 53ccfde..5a5fcbe 100644 --- a/context/ThemeContext.tsx +++ b/context/ThemeContext.tsx @@ -23,6 +23,24 @@ export const ThemeProvider: React.FC<{ children: ReactNode }> = ({ children }) = root.classList.remove('light', 'dark'); root.classList.add(theme); localStorage.setItem('theme', theme); + + const handleBeforePrint = () => { + root.classList.remove('dark'); + root.classList.add('light'); + }; + + const handleAfterPrint = () => { + root.classList.remove('light', 'dark'); + root.classList.add(theme); + }; + + window.addEventListener('beforeprint', handleBeforePrint); + window.addEventListener('afterprint', handleAfterPrint); + + return () => { + window.removeEventListener('beforeprint', handleBeforePrint); + window.removeEventListener('afterprint', handleAfterPrint); + }; }, [theme]); const toggleTheme = () => {