Skip to content

Commit 490e4ed

Browse files
Hardik500Laurie T. Malau
authored and
Laurie T. Malau
committed
Changed the styling of pagination navigation buttons
1 parent dab947e commit 490e4ed

File tree

2 files changed

+57
-25
lines changed

2 files changed

+57
-25
lines changed

components/dashboard/src/Pagination/Pagination.tsx

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import { getPaginationNumbers } from "./getPagination";
8-
import Arrow from "../components/Arrow";
8+
import PaginationNavigationButton from "./PaginationNavigationButton";
99

1010
interface PaginationProps {
1111
totalNumberOfPages: number;
@@ -40,18 +40,12 @@ function Pagination(props: PaginationProps) {
4040
return (
4141
<nav className="mt-16 mb-16">
4242
<ul className="flex justify-center items-center space-x-4">
43-
<li
44-
className={`font-semibold text-gray-300 ${
45-
currentPage === 1
46-
? "disabled dark:text-gray-500"
47-
: "cursor-pointer dark:text-gray-400 text-gray-500"
48-
}`}
49-
>
50-
<span onClick={prevPage}>
51-
<Arrow direction={"left"} />
52-
Previous
53-
</span>
54-
</li>
43+
<PaginationNavigationButton
44+
isDisabled={currentPage === 1}
45+
onClick={prevPage}
46+
label={"Previous"}
47+
arrowReversed={false}
48+
/>
5549
{calculatedPagination.map((pn, i) => {
5650
if (pn === "...") {
5751
return <li className={getClassnames(pn)}>&#8230;</li>;
@@ -62,18 +56,12 @@ function Pagination(props: PaginationProps) {
6256
</li>
6357
);
6458
})}
65-
<li
66-
className={`font-semibold text-gray-300 ${
67-
currentPage === totalNumberOfPages
68-
? "disabled dark:text-gray-500"
69-
: "cursor-pointer dark:text-gray-400 text-gray-500"
70-
}`}
71-
>
72-
<span onClick={nextPage}>
73-
Next
74-
<Arrow direction={"right"} />
75-
</span>
76-
</li>
59+
<PaginationNavigationButton
60+
isDisabled={currentPage === totalNumberOfPages}
61+
onClick={nextPage}
62+
label={"Next"}
63+
arrowReversed={true}
64+
/>
7765
</ul>
7866
</nav>
7967
);
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License-AGPL.txt in the project root for license information.
5+
*/
6+
7+
import Arrow from "../components/Arrow";
8+
9+
interface PaginationNavigationButtonProps {
10+
isDisabled: boolean;
11+
label: string;
12+
arrowReversed: boolean;
13+
onClick: () => void;
14+
}
15+
16+
function PaginationNavigationButton(props: PaginationNavigationButtonProps) {
17+
const activeArrowClass = props.isDisabled
18+
? undefined
19+
: "border-gray-500 dark:border-gray-400 group-hover:border-gray-600 dark:group-hover:border-gray-400";
20+
21+
return (
22+
<li
23+
className={`font-semibold text-gray-300 ${
24+
props.isDisabled ? "disabled dark:text-gray-500" : "cursor-pointer dark:text-gray-400 text-gray-500"
25+
}`}
26+
>
27+
<span onClick={props.onClick}>
28+
{props.arrowReversed ? (
29+
<>
30+
{props.label}
31+
<Arrow direction={"right"} customBorderClasses={activeArrowClass} />
32+
</>
33+
) : (
34+
<>
35+
<Arrow direction={"left"} customBorderClasses={activeArrowClass} />
36+
{props.label}
37+
</>
38+
)}
39+
</span>
40+
</li>
41+
);
42+
}
43+
44+
export default PaginationNavigationButton;

0 commit comments

Comments
 (0)