Skip to content

Commit

Permalink
feat: add 'printed at' timestamp to print view (#3836)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamdelion authored Oct 22, 2024
1 parent 005ce94 commit c377521
Showing 1 changed file with 36 additions and 9 deletions.
45 changes: 36 additions & 9 deletions editor.planx.uk/src/components/PrintButton.tsx
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 />
</>
);
};

0 comments on commit c377521

Please sign in to comment.