diff --git a/package-lock.json b/package-lock.json index c40efb685..67c2f6f0e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -80,6 +80,7 @@ "react-router-dom": "^5.2.0", "react-share": "^4.2.0", "react-syntax-highlighter": "^15.4.3", + "react-table": "^7.8.0", "react-table-6": "^6.11.0", "react-tagsinput": "^3.19.0", "redux": "^4.1.2", @@ -11036,6 +11037,19 @@ "react": ">= 0.14.0" } }, + "node_modules/react-table": { + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/react-table/-/react-table-7.8.0.tgz", + "integrity": "sha512-hNaz4ygkZO4bESeFfnfOft73iBUj8K5oKi1EcSHPAibEydfsX2MyU6Z8KCr3mv3C9Kqqh71U+DhZkFvibbnPbA==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "react": "^16.8.3 || ^17.0.0-0 || ^18.0.0" + } + }, "node_modules/react-table-6": { "version": "6.11.0", "resolved": "https://registry.npmjs.org/react-table-6/-/react-table-6-6.11.0.tgz", diff --git a/package.json b/package.json index 3a104f89d..3b23bc9c2 100644 --- a/package.json +++ b/package.json @@ -102,6 +102,7 @@ "react-router-dom": "^5.2.0", "react-share": "^4.2.0", "react-syntax-highlighter": "^15.4.3", + "react-table": "^7.8.0", "react-table-6": "^6.11.0", "react-tagsinput": "^3.19.0", "redux": "^4.1.2", diff --git a/src/components/PaginationControl/PaginationControl.jsx b/src/components/PaginationControl/PaginationControl.jsx new file mode 100644 index 000000000..dcc0bf6ea --- /dev/null +++ b/src/components/PaginationControl/PaginationControl.jsx @@ -0,0 +1,75 @@ +export default function PaginationControl({ + currentPage, + totalPages, + pageSize, + gotoPage, + setPageSize, +}) { + const canPreviousPage = currentPage > 0; + const canNextPage = currentPage < totalPages - 1; + + const previousPage = () => gotoPage(Math.max(currentPage - 1, 0)); + const nextPage = () => gotoPage(Math.min(currentPage + 1, totalPages - 1)); + + return ( +
+ {column.render("Header")} + {column.isSorted ? (column.isSortedDesc ? " ▼" : " ▲") : ""} + | + ))} +
---|
+ {cell.render("Cell")} + | + ); + })} +
{value}
, sortable: true, resizable: false, }, ]; -const challengeColumns = ({ setSelectedComment }) => [ +const CHALLENGE_COLUMNS = [ { id: "challenge_name", Header: "Challenge", accessor: "challengeName", - Cell: ({ value, original }) => { - return ( - - {value} - - ); - }, + Cell: ({ value, original }) => ( + {value} + ), maxWidth: 200, sortable: true, resizable: false, @@ -174,9 +172,9 @@ const challengeColumns = ({ setSelectedComment }) => [ Header: "Date", accessor: "created", Cell: ({ value }) => ( - <> +{value}
, sortable: true, resizable: false, }, diff --git a/src/styles/vendor/react-table.css b/src/styles/vendor/react-table.css index 1844ffad8..59f93e296 100644 --- a/src/styles/vendor/react-table.css +++ b/src/styles/vendor/react-table.css @@ -3,21 +3,20 @@ .ReactTable { @apply mr-border-none mr-text-white; - .rt-table { + table { @apply mr-mb-3; } - .rt-thead { + thead { &.-header { @apply mr-shadow-none mr-border-b mr-border-white-15; } - .rt-tr { + tr { @apply mr-text-left; } - .rt-th, - .rt-tb { + th { @apply mr-outline-none mr-border-none mr-p-4 mr-text-white mr-text-xs mr-font-medium mr-uppercase mr-tracking-wide; line-height: 1rem; @@ -33,7 +32,7 @@ &.-filters { @apply mr-border-none; - .rt-th { + th { @apply mr-border-none mr-pb-0 mr-pt-4; } @@ -47,16 +46,16 @@ } } - .rt-td { + td { @apply mr-p-3 mr-text-sm; } - .rt-tbody { + tbody { .rt-tr-group { @apply mr-border-white-15; } - .rt-td { + td { @apply mr-border-r-0 mr-p-4 mr-leading-normal; } }