diff --git a/client/modules/IDE/components/SketchList.jsx b/client/modules/IDE/components/SketchList.jsx index 3846fe278..967934a86 100644 --- a/client/modules/IDE/components/SketchList.jsx +++ b/client/modules/IDE/components/SketchList.jsx @@ -29,6 +29,7 @@ const SketchList = ({ mobile }) => { const [isInitialDataLoad, setIsInitialDataLoad] = useState(true); + const [currentPage, setCurrentPage] = useState(1); const [sketchToAddToCollection, setSketchToAddToCollection] = useState(null); const { t } = useTranslation(); @@ -118,6 +119,19 @@ const SketchList = ({ [sorting, getButtonLabel, toggleDirectionForField, t] ); + const pageNumbers = []; + let sketchesPerPage = 5; + if (mobile) { + sketchesPerPage = 7; + } + const totalSketches = sketches.length; + const indexOfLastSketch = currentPage * sketchesPerPage; + const indexOfFirstSketch = indexOfLastSketch - sketchesPerPage; + const TotalPages = Math.ceil(totalSketches / sketchesPerPage); + for (let i = 1; i <= TotalPages; i += 1) { + pageNumbers.push(i); + } + return (
@@ -149,20 +163,68 @@ const SketchList = ({ - {sketches.map((sketch) => ( - setSketchToAddToCollection(sketch)} - t={t} - /> - ))} + {sketches + .slice(indexOfFirstSketch, indexOfLastSketch) + .map((sketch) => ( + setSketchToAddToCollection(sketch)} + t={t} + /> + ))} )} +
+
    +
  • + +
  • +
  • + +
  • +
  • + ....... +
  • +
  • + +
  • +
  • +  of  +
  • +
  • + +
  • +
  • + +
  • +
+
{sketchToAddToCollection && ( li { + margin: 0 2px; + + .page-link { + @include themify() { + color: #ed225d; + font-weight: 800; + padding: 0 10px; + border: 1px solid #fbd2de; + } + } + } + } +} + +.pagination-ul > li button:hover { + @include themify() { + background-color: #f9bcce; + } +} + .sketches-table { width: 100%;