From 5d5d2266f86fe483d25c266d093fa6c57e47fe23 Mon Sep 17 00:00:00 2001 From: admtracksteel Date: Tue, 23 Jun 2026 17:26:04 +0000 Subject: [PATCH] fix: force light theme during PDF generation to avoid dark background --- context/ThemeContext.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 = () => {