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

goten-react-paginator

v0.0.4

Published

GotenTextField is a React component that facilitates the implementation of a common paginator

Downloads

26

Readme

Goten Paginator for React

When we have some items we want to show, we usually create:

  • A Searcher, which provides the filters for searching items.
  • A List, which shows the result of said search.

For small data, this should be fine. But when working with bigger sets we get:

  • Heavy payloads.
  • Endless scrolling.
  • Huge requirements on our backend and database.

We need a Paginator.

Installation

npm install -s goten-react-paginator

Requirements

  • Your API's response or source of data must include the total elements, offset and limit.
  • Your Searcher must have a method that executes the search (whatever that means in your application).
    • The search method should have two parameters: offset and limit.
    • Example,
    search(offset, limit) {
        getFromApi('/myApiURL', {offset, limit})
    }
  • You can also pass a function as a prop (searchMethod) to GotenPaginator, to avoid using functions from your Searcher.

Usage

const GotenPaginator = require('goten-react-paginator') //ES5

import { GotenPaginator } from 'goten-react-paginator' //ES6

Wrap your Searcher and List components

<GotenPaginator
  totalElements={/*totalElements - a Redux variable, a state, or some other data controlling entity*/}
  offset={/*offset*/}
  limit={/*limit*/}
>
    <YourSearcher/>
    <YourList/>
</GotenPaginator>

Example of use

without goten-react-paginator

render() {
    return (
      <div className="App">
          <YourSearcher/>
          <YourList/>
      </div>
    );
  }

with goten-react-paginator

render() {
    return (
      <div className="App">
        <GotenPaginator
          totalElements={this.state.totalElements}
          offset={this.state.offset}
          limit={this.state.limit}
          buttonClassName={{
            active: "btn btn-success",
            default: "btn btn-warning",
          }}
        >
          <YourSearcher/>
          <YourList/>
        </GotenPaginator>
      </div>
    );
  }

GotenPaginator's parameters

|Prop name | Type | Description | |---|---|---| | totalElements (Required)| number | Total elements. To compute the maximum number of pages | | offset (Required)| number | Offset for working out the current page | | limit (Required)| number | Amount of elements to show| | searchMethod (Optional)| function | You can pass any function (that receives two parameters, offset and limit) to GotenPaginator. This replaces the option of using the Searcher's method | | searcherMethodName (Optional)| string | When not using the searchMethod prop, you can pass a string to specify which method from Searcher the GotenPaginator should use to search. If none passed, it defaults to 'search' | | buttonClassName (Optional)| object | this object has two styles properties active for selected page and default for the others buttons. |

Contributions

To contribute to this package, we use the following workflow:

  • Add an issue with related tags to describe the contribution (is it a bug? a feature request?).
  • Branch your solution from develop, naming it like #<issue_number>-<descriptive_name>.
  • Send a pull request and wait for approval/corrections.