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

MPDX-8392 - Fix print styles #1144

Merged
merged 3 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion src/components/Layouts/Primary/TopBar/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ interface TopBarProps {
onMobileNavOpen?: () => void;
}

const Offset = styled('div')(({ theme }) => theme.mixins.toolbar);
const Offset = styled('div')(({ theme }) => ({
...theme.mixins.toolbar,
'@media print': {
display: 'none',
},
}));

const StyledAppBar = styled(AppBar)(({ theme }) => ({
backgroundColor: theme.palette.cruGrayDark.main,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export const FourteenMonthReport: React.FC<Props> = ({
theme.breakpoints.down('sm'),
);

const isPrint = useMediaQuery('print');

const { data, error } = useFourteenMonthReportQuery({
variables: {
accountListId,
Expand Down Expand Up @@ -117,7 +119,7 @@ export const FourteenMonthReport: React.FC<Props> = ({
) : error ? (
<Notification type="error" message={error.toString()} />
) : currencyTables.length > 0 ? (
<Box display="flex" flexDirection="column" gap={4}>
<Box display="flex" flexDirection="column" gap={isPrint ? 1 : 4}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this looks great! I wonder if you could also make the main header "Contributions By Partner Currency" have less margin/padding so it doesn't take up so much space.

{currencyTables.map(({ currency, orderedContacts, totals }) => (
<Table
key={currency}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ const StickyHeader = styled(Box)(({}) => ({
top: 0,
height: 96,
'@media print': {
paddingTop: '0',
position: 'static',
paddingTop: '1rem',
paddingBottom: '1rem',
height: 'auto',
},
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { styled } from '@mui/material/styles';

export const StyledTableCell = styled(TableCell)(({}) => ({
'@media print': {
padding: '8px',
padding: '4px',
},
}));
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ const NameTypography = styled(Typography, {
},
}));

const StyledLink = styled(Link)({
'@media print': {
color: theme.palette.text.primary,
},
});

const PrintableContainer = styled(TableContainer)({
// First style sets size as landscape
'@media print': {
Expand Down Expand Up @@ -129,13 +135,13 @@ export const FourteenMonthReportTable: React.FC<
<Box display="flex" alignItems="center">
{!isExpanded && <StyledInfoIcon fontSize="small" />}
<NameTypography variant="body1" expanded={isExpanded}>
<Link
<StyledLink
onClick={() => onSelectContact(contact.id)}
onMouseEnter={preloadContactsRightPanel}
underline="hover"
>
{contact.name}
</Link>
</StyledLink>
</NameTypography>
</Box>
{isExpanded && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,24 @@ export interface FourteenMonthReportTableHeadProps {

const YearTableCell = styled(TableCell)(({}) => ({
paddingLeft: 0,
'@media print': {
padding: '0px',
},
}));

const YearTypography = styled(Typography)(({ theme }) => ({
borderLeft: `1px solid ${theme.palette.cruGrayLight.main}`,
'@media print': {
lineHeight: 1,
fontSize: '1rem',
},
}));

const CurrencyTypography = styled(Typography)(() => ({
'@media print': {
lineHeight: 1,
fontSize: '1rem',
},
}));

export const FourteenMonthReportTableHead: FC<
Expand Down Expand Up @@ -69,7 +83,7 @@ export const FourteenMonthReportTableHead: FC<
<TableHead data-testid="SalaryReportTableHead">
<TableRow>
<StyledTableCell>
<Typography variant="h6">{salaryCurrency}</Typography>
<CurrencyTypography variant="h6">{salaryCurrency}</CurrencyTypography>
</StyledTableCell>
{isExpanded && (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ const PrintableTableSortLabel = styled(TableSortLabel)(() => ({
},
}));

const TableCell = styled(StyledTableCell)(() => ({
top: 65,
position: 'sticky',
'@media print': {
position: 'static',
top: 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure where it is in the code, but could you make the name link black instead of blue when printing? That is how it is on the old angular site.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, I updated it.

paddingTop: 0,
paddingBottom: 0,
},
}));

const HeadCellSpan = styled('span')(() => ({
border: 0,
clip: 'rect(0 0 0 0)',
Expand All @@ -54,11 +65,7 @@ export const TableHeadCell: React.FC<FourteenMonthReportTableCellProps> = ({
onClick,
}) => {
return (
<StyledTableCell
align={align}
sortDirection={sortDirection}
style={{ top: 65 }}
>
<TableCell align={align} sortDirection={sortDirection}>
<PrintableTableSortLabel
active={isActive}
direction={direction}
Expand All @@ -71,6 +78,6 @@ export const TableHeadCell: React.FC<FourteenMonthReportTableCellProps> = ({
</HeadCellSpan>
)}
</PrintableTableSortLabel>
</StyledTableCell>
</TableCell>
);
};
Loading