-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add 'printed at' timestamp to print view (#3836)
- Loading branch information
Showing
1 changed file
with
36 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,44 @@ | ||
import PrintIcon from "@mui/icons-material/Print"; | ||
import Button from "@mui/material/Button"; | ||
import { styled } from "@mui/material/styles"; | ||
import Typography from "@mui/material/Typography"; | ||
import React from "react"; | ||
|
||
const StyledPrintButton = styled(Button)(() => ({ | ||
"@media print": { | ||
display: "none", | ||
}, | ||
})); | ||
|
||
const StyledTimestamp = styled(Typography)(() => ({ | ||
display: "none", | ||
"@media print": { | ||
display: "block", | ||
}, | ||
})); | ||
|
||
const PrintedAt = () => { | ||
return ( | ||
<StyledTimestamp> | ||
Printed at {new Date().toLocaleString("en-GB")} | ||
</StyledTimestamp> | ||
); | ||
}; | ||
|
||
export const PrintButton = () => { | ||
return ( | ||
<Button | ||
variant="contained" | ||
color="secondary" | ||
startIcon={<PrintIcon />} | ||
size="large" | ||
onClick={() => window.print()} | ||
> | ||
Print this page | ||
</Button> | ||
<> | ||
<StyledPrintButton | ||
variant="contained" | ||
color="secondary" | ||
startIcon={<PrintIcon />} | ||
size="large" | ||
onClick={() => window.print()} | ||
> | ||
Print this page | ||
</StyledPrintButton> | ||
|
||
<PrintedAt /> | ||
</> | ||
); | ||
}; |