npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sly-rc-paginator

v0.0.12

Published

A paginator component for react

Downloads

169

Readme

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

| name | type | required | description | | ------------------------- | ------------------- | -------- | -------------------------------------------------------------------------------------------------------------------- | | meta | object | YES | meta data that with the following keys totalItems, currentPage , itemsPerPage | | meta.totalItems | number | YES | total number of rows to be paginated | | meta.currentPage | number | YES | current page being viewed | | meta.itemsPerPage | number | YES | number of items per page | | options | object | YES | the paginator's options with the following keys ulClassName, liClassName, activeClassName, disabledClassName | | options.ulClassName | string | YES | class name for the ul tag | | options.liClassName | string | YES | class name for the li tag | | options.activeClassName | string | YES | class name for the current page to be applied to the li tag | | options.disabledClassName | string | YES | class name for the disabled links to be applied to the li tag | | options.anchorClassName | string | NO | class name for the a tags | | onPageChange | function | YES | the function that gets called when a page is clicked. It returns the currentPage as a number | | firstComponent | component or string | NO | custom component for the link to the first page e.g "<<" | | lastComponent | component or string | NO | custom component for the link to the last page e.g ">>" | | prevComponent | component or string | NO | custom component for the link to the previous page e.g "<" | | nextComponent | component or string | NO | custom component for the link to the next page e.g ">" | | showFirst | boolean | NO | condition to show link to first page | | showLast | boolean | NO | condition to show link to last page |