fix: force light theme during PDF generation to avoid dark background
This commit is contained in:
@@ -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 = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user