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

v-simple-paginate

v2.0.0

Published

A simple pagination component for Vue.js

Downloads

95

Readme

v-simple-paginate

NPM

npm version Build Status

Vue.js (v2.x +) component for make pagination without default styles. This allows you to style the component as you wish.

Demo

Installation

NPM

$ npm i v-simple-paginate

YARN

$ yarn add v-simple-paginate

CDN

<!-- use the latest release -->
<script src="https://unpkg.com/v-simple-paginate@latest"></script>
<!-- or use the specify version -->
<script src="https://unpkg.com/[email protected]"></script>

Register the component

Global

  • ES5
var Vue = require('vue');
var Paginate = require('v-simple-paginate');
Vue.component('paginate', Paginate);
  • ES6+
import Vue from 'vue';
import Paginate from 'v-simple-paginate';
Vue.component('paginate', Paginate);

Local

import Paginate from 'v-simple-paginate';

export default {
    components: { Paginate }
}

Usage

Basic Usage

<paginate
  :value="currentPage"
  :per-page="perPage"
  :total="total"
  @input="callback()"
/>

Note: In vue template, camelCase and kebab-case are both supported. For example, you can either use prop page-count or pageCount. They are leading to the same result.

So this is also available

<paginate
  v-model="currentPage"
  :perPage="perPage"
  :total="total"
/>

Example

<template>
  <paginate
    :value="currentPage"
    :per-page="perPage"
    :total="total"
    @input="callback"
  />
</template>

<script>
export default {
  data: () => ({
    total: 500,
    perPage: 10,
    currentPage: 1,
  }),

  methods: {
    callback (pageNumber) => {
      console.log(pageNumber);
      ...
      this.currentPage = pageNumber;
    }
  }
}
</script>

<style lang="css">
.active {
    background-color: red;
}

.hide {
    display: none;
}
</style>

Props

| Name                                        | Type | Required | Description | | ----------------- | :--- | :--- | :--- | | value | Number | true | Current page. | | perPage | Number | true | Number of items per page. | | total | Number | true | Total items. | | pageRange | Number | false | The range of visible elements around the active page. Default: 2 | | showPrevNext | Boolean | false | Will the previous and next buttons be visible. Default: true | | activeClass | String | false | CSS class name for active page element. Default: 'active' | | btnHideClass | String | false | CSS class name for active page element. Default: 'active' | | classes | Object | false | An object with CSS classes to customization the component. |

About props classes

| Name                          | Description | | ----------------- | :--- | | wrapperClass | CSS class name for wrapper the component. | | itemClass | CSS class name for all items (buttons and break view). | | btnClass | CSS class name for buttons class. | | breakViewClass | CSS class name for break view. | | prevNextClass | CSS class name for previous and next buttons. |

Default:

{
  wrapperClass: 'v-simple-pagination',
  itemClass: '',
  btnClass: '',
  breakViewClass: '',
  prevNextClass: '',
}

Slots

| Name                                      | Description | | --- | --- | | prevContent | Previous button | | nextContent | Next button | | breakViewContent | Break view indicator |

Example

<paginate
  :value="currentPage"
  :perPage="perPage"
  :total="total"
  @input="callback"
>
  <template v-slot:prevPage>PREV</template>

  <template v-slot:nextPage>NEXT</template>

  <template v-slot:breakView>...</template>
</paginate>

Emit

Emit: input is a callback with the param page number to update the current page.

License

MIT