Sha256: c44619c2bc95109f7e97edd2787853a2079775be834bd5f0618218a9be435638

Contents?: true

Size: 1.49 KB

Versions: 218

Compression:

Stored size: 1.49 KB

Contents

import React, { useState } from "react";
import { Table, Pagination } from 'playbook-ui'


import { data } from "./data";

const PaginationPageChange = (props) => {

  const [activePage, setActivePage] = useState(1);
  const rowsPerPage = 3;
  const totalPages = Math.ceil(data.length / rowsPerPage);

  const onPageChange = (pageNumber) => {
    setActivePage(pageNumber);
  };

  const currentData = data.slice(
    (activePage - 1) * rowsPerPage,
    activePage * rowsPerPage
  );


    return (
      <div className="App">
      <Table 
          marginBottom="xs"
          responsive="none" 
          size="sm" 
          {...props}
      >
        <Table.Head>
          <Table.Row>
            <Table.Header>{"Column 1"}</Table.Header>
            <Table.Header>{"Column 2"}</Table.Header>
            <Table.Header>{"Column 3"}</Table.Header>
            <Table.Header>{"Column 4"}</Table.Header>
            <Table.Header>{"Column 5"}</Table.Header>
          </Table.Row>
        </Table.Head>
        <Table.Body>
          {currentData.map((row, index) => (
            <Table.Row key={index}>
              {row.map((cell, cellIndex) => (
                <Table.Cell key={cellIndex}>{cell}</Table.Cell>
              ))}
            </Table.Row>
          ))}
        </Table.Body>
      </Table>
 
      <Pagination
          current={1}
          onChange={onPageChange}
          range={5}
          total={totalPages}
          {...props}
      />
    </div>
    )
}

export default PaginationPageChange

Version data entries

218 entries across 218 versions & 2 rubygems

Version Path
playbook_ui_docs-14.5.0.pre.rc.7 app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change.jsx
playbook_ui-14.5.0.pre.rc.7 app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change.jsx
playbook_ui_docs-14.5.0.pre.rc.6 app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change.jsx
playbook_ui-14.5.0.pre.rc.6 app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change.jsx
playbook_ui_docs-14.5.0.pre.rc.5 app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change.jsx
playbook_ui-14.5.0.pre.rc.5 app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change.jsx
playbook_ui_docs-14.5.0.pre.rc.4 app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change.jsx
playbook_ui-14.5.0.pre.rc.4 app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change.jsx
playbook_ui_docs-14.5.0.pre.rc.3 app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change.jsx
playbook_ui-14.5.0.pre.rc.3 app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change.jsx
playbook_ui_docs-14.5.0.pre.rc.2 app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change.jsx
playbook_ui-14.5.0.pre.rc.2 app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change.jsx
playbook_ui_docs-14.4.0.pre.alpha.PBNTR490multilevelselect3832 app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change.jsx
playbook_ui-14.4.0.pre.alpha.PBNTR490multilevelselect3832 app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change.jsx
playbook_ui_docs-14.4.0.pre.alpha.PLAY1546highchartsbump3831 app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change.jsx
playbook_ui-14.4.0.pre.alpha.PLAY1546highchartsbump3831 app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change.jsx
playbook_ui_docs-14.4.0.pre.alpha.dependabotnpmandyarntiptapextensionparagraph2723830 app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change.jsx
playbook_ui-14.4.0.pre.alpha.dependabotnpmandyarntiptapextensionparagraph2723830 app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change.jsx
playbook_ui_docs-14.4.0.pre.alpha.dependabotnpmandyarntiptapextensionlink2723828 app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change.jsx
playbook_ui-14.4.0.pre.alpha.dependabotnpmandyarntiptapextensionlink2723828 app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change.jsx