fix: force light theme during PDF generation to avoid dark background

This commit is contained in:
2026-06-23 17:26:04 +00:00
parent f14a8b0528
commit 5d5d2266f8
+18
View File
@@ -23,6 +23,24 @@ export const ThemeProvider: React.FC<{ children: ReactNode }> = ({ children }) =
root.classList.remove('light', 'dark'); root.classList.remove('light', 'dark');
root.classList.add(theme); root.classList.add(theme);
localStorage.setItem('theme', 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]); }, [theme]);
const toggleTheme = () => { const toggleTheme = () => {