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

material-ui-v1-pagination

v1.0.0

Published

An easy to use and customizable pagination component for material ui.

Downloads

6

Readme

material-ui-pagination

Build Status

An easy to use and customizable pagination component for material ui.

Play with this demo to see how it works.

Demonstration

Notice


Because some upstream modification about the click event made to the material-ui repo, I have to make some changes in response.

You can check what I have done in issue16.

  • Now for the newest version, you can install by npm install material-ui-pagination@next.
  • Otherwise go with the stable version by npm install mateiral-ui-pagination.

Quick Start


  • npm install material-ui-pagination
  • import Pagination from 'material-ui-pagination';

Usage


material-ui-pagination exposes one module called, Pagination, which accepts a few props:

Option | Description
---------------------|----------------------------------------------- total | Total number of pages display | Number of pages you want to show in the panel current | Current page selected onChange | Handles the change event of selected page: function(value: integer) => void styleRoot | Styles for root element styleFirstPageLink | Styles for FirstPageLink. If not provided, a NavigationFirstPage from Material UI will be rendered as default, otherwise <div> with styles will show up instead styleLastPageLink | Styles for LastPageLink. If not provided, a NavigationLastPage from Material UI will be rendered as default, otherwise <div> with styles will show up instead styleButton | Styles for page number button. If not provided, a FlatButton from Material UI will be rendered as default, otherwise <div> with styles will show up instead stylePrimary | Styles for active page element. Requires the styleButton

Run Local Demo


  • git clone https://github.com/lo-tp/material-ui-pagination
  • npm install
  • npm run dev-server
  • visit http://localhost:7890/

Run test


  • git clone https://github.com/lo-tp/material-ui-pagination
  • npm install
  • npm run test

Code Example


import React from 'react';
import ReactDOM from 'react-dom';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import injectTapEventPlugin from 'react-tap-event-plugin';
import Pagination from 'material-ui-pagination';

injectTapEventPlugin();

class App extends React.Component {
  constructor(props) {
    super(props);
    this.setTotal = this.setTotal.bind(this);
    this.setDisplay = this.setDisplay.bind(this);
    this.state = {
      total: 20,
      display: 7,
      number: 7,
    };
  }

  setTotal(event, total) {
    // eslint-disable-next-line no-param-reassign
    total = total.trim();
    if (total.match(/^\d*$/)) {
      if (total !== '') {
        // eslint-disable-next-line no-param-reassign
        total = parseInt(total, 10);
      } else {
        // eslint-disable-next-line no-param-reassign
        total = 0;
      }

      this.setState({ total });
    }
  }

  setDisplay(event, display) {
    // eslint-disable-next-line no-param-reassign
    display = display.trim();
    if (display.match(/^\d*$/)) {
      if (display !== '') {
        // eslint-disable-next-line no-param-reassign
        display = parseInt(display, 10);
      } else {
        // eslint-disable-next-line no-param-reassign
        display = 0;
      }

      this.setState({ display });
    }
  }

  render() {
    return (
      <div
        style = { {
          width: 500,
          margin: '0 auto',
        } }
      >
        <h3 >
          Now you are at
          <em
            style = { { color: 'red' } }
          >
            {` ${this.state.number} ` }
          </em>
          page
        </h3>
        <Pagination
          total = { this.state.total }
          current = { this.state.number }
          display = { this.state.display }
          onChange = { number => this.setState({ number }) }
        />
      </div>
    );
  }
}

ReactDOM.render(
  <MuiThemeProvider >
    <App />
  </MuiThemeProvider>,
  document.getElementById('root')
);