Resolve printing in dark mode and print orientation.
This commit is contained in:
@@ -197,6 +197,6 @@
|
||||
"1.4.1": {
|
||||
"title": "Release Notes for 1.4.1",
|
||||
"date": "07/04/2025",
|
||||
"notes": "Improvements:\r\n* Increased performance of scenario manager.\r\n* Report lines will now display better on smaller screens."
|
||||
"notes": "Improvements:\r\n* Increased performance of scenario manager.\r\n* Report lines will now display better on smaller screens.\r\n* Job RPS printouts will now display in landscape mode and ignore dark mode styling."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,53 @@ export default function JobsDetailDescriptionMolecule({ loading, job, jobDetailR
|
||||
return job?.joblines?.find((jl) => !jl.ignore && jl.quantity > 1);
|
||||
}, [job]);
|
||||
|
||||
// Store original theme state
|
||||
const originalThemeRef = useRef(null);
|
||||
|
||||
const handlePrint = useReactToPrint({
|
||||
contentRef: jobDetailRef,
|
||||
bodyClass: "audit-container-print"
|
||||
bodyClass: "audit-container-print",
|
||||
onBeforeGetContent: () => {
|
||||
// Store original theme state
|
||||
originalThemeRef.current = {
|
||||
dataTheme: document.documentElement.getAttribute('data-theme'),
|
||||
bodyClasses: Array.from(document.body.classList),
|
||||
htmlClasses: Array.from(document.documentElement.classList),
|
||||
};
|
||||
|
||||
// Force light mode for printing
|
||||
document.documentElement.setAttribute('data-theme', 'light');
|
||||
document.body.classList.remove('dark', 'ant-dark');
|
||||
document.documentElement.classList.remove('dark', 'ant-dark');
|
||||
|
||||
// Set light mode CSS variables for Ant Design
|
||||
document.documentElement.style.setProperty('--ant-color-bg-base', '#ffffff');
|
||||
document.documentElement.style.setProperty('--ant-color-text', '#000000');
|
||||
document.documentElement.style.setProperty('--ant-color-text-secondary', 'rgba(0, 0, 0, 0.65)');
|
||||
document.documentElement.style.setProperty('--ant-color-border', '#d9d9d9');
|
||||
},
|
||||
onAfterPrint: () => {
|
||||
// Restore original theme after printing
|
||||
if (originalThemeRef.current) {
|
||||
const { dataTheme, bodyClasses, htmlClasses } = originalThemeRef.current;
|
||||
|
||||
if (dataTheme) {
|
||||
document.documentElement.setAttribute('data-theme', dataTheme);
|
||||
} else {
|
||||
document.documentElement.removeAttribute('data-theme');
|
||||
}
|
||||
|
||||
// Restore original classes
|
||||
document.body.className = bodyClasses.join(' ');
|
||||
document.documentElement.className = htmlClasses.join(' ');
|
||||
}
|
||||
|
||||
// Reset CSS variables
|
||||
document.documentElement.style.removeProperty('--ant-color-bg-base');
|
||||
document.documentElement.style.removeProperty('--ant-color-text');
|
||||
document.documentElement.style.removeProperty('--ant-color-text-secondary');
|
||||
document.documentElement.style.removeProperty('--ant-color-border');
|
||||
}
|
||||
});
|
||||
|
||||
if (loading) return <Skeleton active />;
|
||||
|
||||
@@ -59,6 +59,13 @@ export function JobsDetailOrganism({ selectedJobId, setSelectedJobTargetPc }) {
|
||||
|
||||
return (
|
||||
<div ref={jobDetailRef} className="jobs-detail-container">
|
||||
<style type="text/css" media="print">
|
||||
{
|
||||
"\
|
||||
@page { size: landscape; }\
|
||||
"
|
||||
}
|
||||
</style>
|
||||
<Card>
|
||||
<JobsDetailDescriptionMolecule
|
||||
loading={loading}
|
||||
|
||||
@@ -12,3 +12,47 @@ code {
|
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
|
||||
monospace;
|
||||
}
|
||||
|
||||
/* Print styles - force light mode */
|
||||
@media print {
|
||||
body.audit-container-print,
|
||||
body.audit-container-print * {
|
||||
background-color: white !important;
|
||||
color: black !important;
|
||||
border-color: #d9d9d9 !important;
|
||||
}
|
||||
|
||||
/* Override Ant Design dark mode styles for print */
|
||||
body.audit-container-print .ant-descriptions-item-label,
|
||||
body.audit-container-print .ant-descriptions-item-content {
|
||||
color: black !important;
|
||||
}
|
||||
|
||||
body.audit-container-print .ant-page-header-heading-title {
|
||||
color: black !important;
|
||||
}
|
||||
|
||||
body.audit-container-print .ant-page-header-heading-sub-title {
|
||||
color: rgba(0, 0, 0, 0.45) !important;
|
||||
}
|
||||
|
||||
body.audit-container-print .ant-alert {
|
||||
background-color: #fff2f0 !important;
|
||||
border-color: #ffccc7 !important;
|
||||
}
|
||||
|
||||
body.audit-container-print .ant-alert-warning {
|
||||
background-color: #fffbe6 !important;
|
||||
border-color: #ffe58f !important;
|
||||
}
|
||||
|
||||
body.audit-container-print .ant-btn {
|
||||
background-color: white !important;
|
||||
border-color: #d9d9d9 !important;
|
||||
color: black !important;
|
||||
}
|
||||
|
||||
body.audit-container-print .ant-tooltip {
|
||||
color: black !important;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user