Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add 'printed at' timestamp to print view #3836

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 />
</>
);
};
Loading