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

feather-pager

v1.1.0

Published

This is a light-weight paginator, detached entirely from the data, and solely focused on paginating.

Downloads

6

Readme

Feather Pager

This is a light-weight paginator, detached entirely from the data, and solely focused on paginating. Too many of the paginators out there want to see, or even manipulate, the data. That's not what paging is about, and this simplifies that to the bare necessities. All you need to know is what page you are on and what page you want to go to.

Go to jsfiddle to see a working example.

Basic Implementation

Given:

<ul id="pager"></ul>

Attaching the pager

These are the only settings that a new pager can be instantiated with. You can override the text of the Previous and Next buttons and set the initial amount of pages.

$("#pager").pager({
    pages: 5, //required
    previous: "<< Previous", //optional
	next: "Next >>" //optional
});

Updating the Page count

In some cases you may want to update the page count and can do so with this method:

$("#pager").pager("setPages", 15);

Knowing which Page the User selected

All you need to know from the pager is which page the user wants to see. How many records per page, or any other data relevant to retrieve the data from the server is not needed to be known by the pager. This event is raised everytime a page is navigated to in the pager and it simply returns the page number that was selected.

$("#pager").on("page.change", function (e, page) {
	//Run ajax/fetch call to retrieve data.
});

Basic SCSS Structure for Styling

NOTE: A class named page is automatically added to the pagination container for css targeting purposes.

Here is a simple bit of SCSS you can use to get started styling the page "buttons". The page "buttons" (including ellipsis, but not 'previous' or 'next') are also assigned a class called "page". This was implemented to be able to manipulate them directly (e.g. with a media query if the screen size gets too small).

.pager li {
    display: inline;
    margin-right: 5px;
    color: black;
    cursor: pointer;
    border: 1px solid black;
    border-radius: 3px;
    padding: 2px 10px;

    &.active {
        color: orange;
    }

    &.disabled {
        cursor: not-allowed;
    }

    &.ellipses {
        cursor: default;
        border: none;
    }
}

@media (max-width: 480px) {
    .pager li.page {
        display: none;
    }
}