Skip to content

Commit 332c545

Browse files
authored
3222: Update pagination component design (#3223)
* Revise numbered pagination feature * Update typography, spacing, and styles to match update * Refactor and simplify page navigation logic in onPage function * Sort imports and WizardFooter PropTypes * Fix WizardFooter indentation * Apply submit button styling to "ACTION" button
1 parent 1d319aa commit 332c545

5 files changed

Lines changed: 102 additions & 80 deletions

File tree

client/src/components/Button/NavButton.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const NavButton = ({
4141
navDirection,
4242
isVisible,
4343
isDisabled,
44+
className,
4445
color
4546
}) => {
4647
const theme = useTheme();
@@ -51,7 +52,7 @@ const NavButton = ({
5152
return (
5253
<Button
5354
id={id}
54-
className={clsx(classes.navButton, maybeDisabled, maybeHiddenVisibility)}
55+
className={clsx(classes.navButton, maybeDisabled, maybeHiddenVisibility, className)}
5556
data-testid={id}
5657
color={color}
5758
onClick={onClick}
@@ -78,7 +79,8 @@ NavButton.propTypes = {
7879
navDirection: PropTypes.string.isRequired,
7980
isVisible: PropTypes.bool.isRequired,
8081
isDisabled: PropTypes.bool.isRequired,
81-
color: PropTypes.string
82+
color: PropTypes.string,
83+
className: PropTypes.string,
8284
};
8385

8486
export default NavButton;

client/src/components/ProjectWizard/NumberedLink.jsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import clsx from "clsx";
66
const useStyles = createUseStyles(theme => ({
77
link: {
88
fontFamily: "Calibri",
9-
fontWeight: 700,
10-
letterSpacing: "0.05em",
11-
fontSize: "20px",
12-
color: theme.colors.secondary.linkBlue,
9+
fontWeight: 600,
10+
letterSpacing: "0.1em",
11+
fontSize: "23px",
12+
color: theme.colorLADOTBlack,
1313
textDecoration: "none",
1414
cursor: "pointer",
15-
margin: "0.2em", // adding some margin for spacing like the button had
16-
padding: "0.1em 0.3em",
15+
margin: "0.2em 0.1em",
16+
padding: "0.6em 0.8em",
1717
"&[aria-disabled='true'], &[disabled]": {
1818
color: theme.colorGray,
1919
cursor: "default",
@@ -22,9 +22,9 @@ const useStyles = createUseStyles(theme => ({
2222
},
2323
activeLink: {
2424
backgroundColor: theme.colorPrimary,
25-
color: theme.colorBlack,
26-
padding: "8px 12px",
27-
textDecoration: "none",
25+
fontWeight: 700,
26+
fontSize: "25px",
27+
color: theme.colorLADOTBlack,
2828
cursor: "default"
2929
}
3030
}));

client/src/components/ProjectWizard/TdmCalculationWizard.jsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -455,14 +455,16 @@ const TdmCalculationWizard = props => {
455455
};
456456

457457
const onPageChange = pageNo => {
458-
const { page, projectId } = params;
458+
const MIN_PAGE = 0;
459+
const MAX_PAGE = 5;
460+
const { projectId } = params;
459461
const projectIdParam = projectId ? `/${projectId}` : "/0";
460-
if (Number(pageNo) > Number(page)) {
461-
if (handleValidate()) {
462+
463+
if ((typeof pageNo === 'number') &&
464+
(pageNo > MIN_PAGE) &&
465+
(pageNo <= MAX_PAGE) &&
466+
handleValidate()) {
462467
navigate(`/calculation/${pageNo}${projectIdParam}`);
463-
}
464-
} else {
465-
navigate(`/calculation/${pageNo}${projectIdParam}`);
466468
}
467469
};
468470

client/src/components/ProjectWizard/WizardFooter.jsx

Lines changed: 80 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
import React, { useRef, useContext } from "react";
1+
import Popup from "reactjs-popup";
22
import PropTypes from "prop-types";
3-
import NavButton from "../Button/NavButton";
43
import { createUseStyles } from "react-jss";
5-
import Button from "../Button/Button";
64
import { useReactToPrint } from "react-to-print";
7-
import { PdfPrint } from "../PdfPrint/PdfPrint";
5+
import { useRef, useContext } from "react";
6+
7+
import Button from "../Button/Button";
8+
import CalculationsContext from "../../contexts/CalculationsContext";
9+
import NavButton from "../Button/NavButton";
810
import NumberedLink from "./NumberedLink";
9-
import { formatDatetime } from "../../helpers/util";
10-
import UserContext from "../../contexts/UserContext";
11-
import Popup from "reactjs-popup";
1211
import ProjectContextMenu from "../Projects/ProjectContextMenu";
13-
import { useReplaceAriaAttribute } from "hooks/useReplaceAriaAttribute";
12+
import UserContext from "../../contexts/UserContext";
13+
import { PdfPrint } from "../PdfPrint/PdfPrint";
1414
import { formatCalculation } from "../../helpers/Calculations";
15-
import CalculationsContext from "../../contexts/CalculationsContext";
15+
import { formatDatetime } from "../../helpers/util";
16+
import { useReplaceAriaAttribute } from "../../hooks/useReplaceAriaAttribute";
1617

1718
const useStyles = createUseStyles({
1819
allButtonsWrapper: {
@@ -46,14 +47,21 @@ const useStyles = createUseStyles({
4647
},
4748
navButtonGroup: {
4849
display: "flex",
49-
alignItems: "center"
50+
alignItems: "center",
51+
},
52+
navButton: {
53+
margin: "0.5em",
54+
padding: "0.3em 0.4em .05em"
55+
},
56+
numberedLinksGroup: {
57+
display: "flex",
58+
alignItems: "center",
59+
margin: "0.1em 0 0"
60+
},
61+
callToActionButton: {
62+
margin: "0.5em",
63+
padding: "0.8em 1em",
5064
},
51-
numberedNavButton: {
52-
margin: "0.2em",
53-
padding: "0.1em 0.3em",
54-
minHeight: "min-content",
55-
fontSize: "1.5rem"
56-
}
5765
});
5866

5967
const WizardFooter = ({
@@ -128,41 +136,44 @@ const WizardFooter = ({
128136
id="leftNavArrow"
129137
navDirection="previous"
130138
color="colorPrimary"
139+
className={classes.navButton}
131140
isVisible={
132141
page !== 1 &&
133-
!project.dateSnapshotted &&
134-
(!shareView || isAdmin)
142+
!project.dateSnapshotted &&
143+
(!shareView || isAdmin)
135144
}
136145
isDisabled={
137146
(shareView && !isAdmin) ||
138-
!!project.dateSnapshotted ||
139-
Number(page) === 1
147+
!!project.dateSnapshotted ||
148+
Number(page) === 1
140149
}
141150
onClick={() => {
142151
onPageChange(Number(page) - 1);
143152
}}
144153
/>
145154

146-
{showNumberedLinks &&
147-
Array.from({ length: 5 }, (_, i) => i + 1).map(p => (
148-
<NumberedLink
149-
key={`nav-page-${p}`}
150-
id={`nav-page-${p}`}
151-
className={classes.numberedNavButton}
152-
onClick={() => onPageChange(p)}
153-
isActive={p === Number(page)}
154-
disabled={
155-
(shareView && !isAdmin) ||
156-
(p === 4 && projectLevel === 0) ||
157-
(!project.dateSnapshotted &&
158-
p > Number(page) &&
159-
setDisabledForNextNavButton())
160-
}
161-
ariaLabel={`go to page ${p}`}
162-
>
163-
{p}
164-
</NumberedLink>
165-
))}
155+
{showNumberedLinks && (
156+
<div className={classes.numberedLinksGroup}>
157+
{Array.from({ length: 5 }, (_, i) => i + 1).map(p => (
158+
<NumberedLink
159+
key={`nav-page-${p}`}
160+
id={`nav-page-${p}`}
161+
onClick={() => onPageChange(p)}
162+
isActive={p === Number(page)}
163+
disabled={
164+
(shareView && !isAdmin) ||
165+
(p === 4 && projectLevel === 0) ||
166+
(!project.dateSnapshotted &&
167+
p > Number(page) &&
168+
setDisabledForNextNavButton())
169+
}
170+
ariaLabel={`go to page ${p}`}
171+
>
172+
{p}
173+
</NumberedLink>
174+
))}
175+
</div>
176+
)}
166177

167178
{(!shareView || isAdmin) && !project?.id ? (
168179
<div className={classes.pageNumberCounter}>
@@ -174,6 +185,7 @@ const WizardFooter = ({
174185
id="rightNavArrow"
175186
navDirection="next"
176187
color="colorPrimary"
188+
className={classes.navButton}
177189
isVisible={page !== 5}
178190
isDisabled={setDisabledForNextNavButton()}
179191
onClick={() => {
@@ -190,7 +202,11 @@ const WizardFooter = ({
190202
trigger={
191203
// needs element wrapped around Button so reactjs-popup has something to anchor on
192204
<div id={elementId}>
193-
<Button id="action" variant="tertiary">
205+
<Button
206+
id="action"
207+
variant="tertiary"
208+
className={classes.callToActionButton}
209+
>
194210
ACTION
195211
</Button>
196212
</div>
@@ -232,6 +248,7 @@ const WizardFooter = ({
232248
<Button
233249
id="saveButton"
234250
variant="primary"
251+
className={classes.callToActionButton}
235252
disabled={setDisabledSaveButton()}
236253
isDisplayed={setDisplaySaveButton()}
237254
onClick={onSave}
@@ -262,9 +279,9 @@ const WizardFooter = ({
262279
<strong>Status: </strong>
263280
{!formattedDateSnapshotted
264281
? "Draft"
265-
: project.shareCount
266-
? "Shared Snapshot"
267-
: "Snapshot"}
282+
: project.loginId === loggedInUserId
283+
? "Snapshot"
284+
: "Shared Snapshot"}
268285
</div>
269286
{formattedDateSubmitted ? (
270287
<div>
@@ -292,35 +309,35 @@ const WizardFooter = ({
292309

293310
WizardFooter.propTypes = {
294311
classes: PropTypes.any,
295-
rules: PropTypes.any,
296-
page: PropTypes.any,
297-
onPageChange: PropTypes.any,
298-
pageNumber: PropTypes.any,
299-
isFinalPage: PropTypes.bool,
300-
setDisabledForNextNavButton: PropTypes.any,
301-
setDisabledSaveButton: PropTypes.any,
302-
setDisplaySaveButton: PropTypes.any,
303-
onSave: PropTypes.any,
304-
submitModalOpen: PropTypes.any,
305-
handleSubmitModalOpen: PropTypes.any,
306-
handleSubmitModalClose: PropTypes.any,
307-
targetNotReachedModalOpen: PropTypes.any,
308-
showCopyAndEditSnapshot: PropTypes.func,
309-
showSubmitModal: PropTypes.func,
310312
handleCsvModalOpen: PropTypes.func,
311-
handleHideModalOpen: PropTypes.func,
313+
handleDROModalOpenWithPreCheck: PropTypes.func,
312314
handleDeleteModalOpen: PropTypes.func,
315+
handleHideModalOpen: PropTypes.func,
313316
handlePrintPdf: PropTypes.func,
314-
handleSnapshotModalOpen: PropTypes.func,
315317
handleRenameSnapshotModalOpen: PropTypes.func,
316318
handleShareSnapshotModalOpen: PropTypes.func,
317-
handleDROModalOpenWithPreCheck: PropTypes.func,
319+
handleSnapshotModalOpen: PropTypes.func,
320+
handleSubmitModalClose: PropTypes.any,
321+
handleSubmitModalOpen: PropTypes.any,
318322
isDroCommitted: PropTypes.func,
323+
isFinalPage: PropTypes.bool,
319324
isSubmittingSnapshot: PropTypes.object,
320325
onDownload: PropTypes.any,
326+
onPageChange: PropTypes.any,
327+
onSave: PropTypes.any,
328+
page: PropTypes.any,
329+
pageNumber: PropTypes.any,
321330
project: PropTypes.any,
331+
rules: PropTypes.any,
322332
selectProject: PropTypes.any,
323-
shareView: PropTypes.bool
333+
setDisabledForNextNavButton: PropTypes.any,
334+
setDisabledSaveButton: PropTypes.any,
335+
setDisplaySaveButton: PropTypes.any,
336+
shareView: PropTypes.bool,
337+
showCopyAndEditSnapshot: PropTypes.func,
338+
showSubmitModal: PropTypes.func,
339+
submitModalOpen: PropTypes.any,
340+
targetNotReachedModalOpen: PropTypes.any,
324341
};
325342

326343
export default WizardFooter;

client/src/styles/theme.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export const jssTheme = {
44
colorPrimaryDisabled: "#D3E29C", //green tint
55
colorText: "#0F2940", //dark navy
66
colorLADOT: "#002E6D", //navy
7+
colorLADOTBlack: "#231F20", //Medium Black
78
colorGray: "#808080",
89
colorLightGray: "#A0A0A0",
910
colorEarnedPoints: "rgb(255, 168, 4)", //orange

0 commit comments

Comments
 (0)