Skip to content

Commit 64f5bc4

Browse files
authored
(fix) Billing app shouldn't generate global CSS rules (#830)
1 parent f43cc15 commit 64f5bc4

2 files changed

Lines changed: 21 additions & 8 deletions

File tree

src/invoice/invoice.component.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,26 @@ interface InvoiceDetailsProps {
3333
value: string | number;
3434
}
3535

36+
/** Styles injected into the print iframe that react-to-print builds. */
37+
const printPageStyle = `
38+
@page {
39+
/* Remove the browser's default header (title) and footer (url) */
40+
margin: 0;
41+
}
42+
43+
@media print {
44+
html,
45+
body {
46+
display: block !important;
47+
background-color: #ffffff !important;
48+
/* Tell browsers to print background colors */
49+
color-adjust: exact;
50+
print-color-adjust: exact;
51+
-webkit-print-color-adjust: exact;
52+
}
53+
}
54+
`;
55+
3656
const Invoice: React.FC = () => {
3757
const { t } = useTranslation();
3858
const { data } = useDefaultFacility();
@@ -135,6 +155,7 @@ const Invoice: React.FC = () => {
135155
const handlePrint = useReactToPrint({
136156
contentRef: componentRef,
137157
documentTitle: `Invoice ${bill?.receiptNumber} - ${patient?.name?.[0]?.given?.join(' ')} ${patient?.name?.[0].family}`,
158+
pageStyle: printPageStyle,
138159
onBeforePrint: handleOnBeforeGetContent,
139160
onAfterPrint: handleAfterPrint,
140161
preserveAfterPrint: false,

src/invoice/invoice.scss

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,3 @@
9898
display: block !important;
9999
}
100100
}
101-
102-
@media print {
103-
html,
104-
body {
105-
display: block !important;
106-
background-color: colors.$white !important;
107-
}
108-
}

0 commit comments

Comments
 (0)