0.0.12 • Published 5 years ago

sly-rc-paginator v0.0.12

Weekly downloads
62
License
-
Repository
github
Last release
5 years ago

Installation

$ npm install sly-rc-paginator --save

paginator image

This paginator component assumes that you have styles for a paginator with the following structure

<ul>
    <li>
	    <a></a>
    </li>
</ul>

Also the paginator truncates the list pages to just 10.

Usage

import  React, {  Component  }  from  "react";

import  Paginator  from  "sly-rc-paginator";

class  App  extends  Component  {

    constructor()  {
	    super();
	    this.state  =  {
			meta:  { // demo meta data from API
			    totalItems:  100,
			    currentPage:  1,
				itemsPerPage:  5
			}
		};
	}
    onPageChange(currentPage)  {
	  this.setState(prevSate => {
	    return {
		  posts: json, // do stuff with json
		     meta: { // update meta data
					...prevSate.meta,
					currentPage
				}
	    };
	  });
    }
    render()  {
	    const  pagintorOptions  =  {
		    ulClassName:  "pagination",
		    liClassName:  "page-item",
		    activeClassName:  "active",
		    disabledClassName:  "disabled"
	    };
    return  (
	    <div  className="App">
		    {/*Show posts*/}
		    <Paginator
			    meta={this.state.meta}
			    options={pagintorOptions}
			    onPageChange={this.onPageChange.bind(this)}
		    />
	    </div>
	   );
    }
}
export  default  App;

Props

nametyperequireddescription
metaobjectYESmeta data that with the following keys totalItems, currentPage , itemsPerPage
meta.totalItemsnumberYEStotal number of rows to be paginated
meta.currentPagenumberYEScurrent page being viewed
meta.itemsPerPagenumberYESnumber of items per page
optionsobjectYESthe paginator's options with the following keys ulClassName, liClassName, activeClassName, disabledClassName
options.ulClassNamestringYESclass name for the ul tag
options.liClassNamestringYESclass name for the li tag
options.activeClassNamestringYESclass name for the current page to be applied to the li tag
options.disabledClassNamestringYESclass name for the disabled links to be applied to the li tag
options.anchorClassNamestringNOclass name for the a tags
onPageChangefunctionYESthe function that gets called when a page is clicked. It returns the currentPage as a number
firstComponentcomponent or stringNOcustom component for the link to the first page e.g "<<"
lastComponentcomponent or stringNOcustom component for the link to the last page e.g ">>"
prevComponentcomponent or stringNOcustom component for the link to the previous page e.g "<"
nextComponentcomponent or stringNOcustom component for the link to the next page e.g ">"
showFirstbooleanNOcondition to show link to first page
showLastbooleanNOcondition to show link to last page
0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago