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

@zakerxa/vue-laravel-pagination

v0.0.7

Published

Vue Laravel Pagination with onSides.

Downloads

5

Readme

Vue Laravel Pagination

Welcome Back

Hi Everyone,My name is Zin Min Htet and here is my Facebook account.

Here is Live Demo -->

Installation

npm i @zakerxa/vue-laravel-pagination

Setup

1 - Import the vue component locally in the script Tag

<script>
 import { VuePagination } from '@zakerxa/vue-laravel-pagination';

  export default {
    components:{
      VuePagination
    }
  }
</script>

OR Global registration in your main.js

 import { VuePagination } from '@zakerxa/vue-laravel-pagination';
 const app = createApp(App);
 app.component("vue-pagination", VuePagination);

2 - In your Vue Template

<template>
    <vue-pagination @event="vuePaginate" :meta-data="paginations" :onSides="1"></vue-pagination>
</template>

3 - In your script Tag

<script>
export default {
    data(){
      return {
          endpoint    : 'https://developers.zakerxa.com/api/paginations?page=',
          perPage     : [2],/* default path => '&per_page=' (Or) change [2,'&UrPath='] */
          paginations : {},
          userData    : []
      },
    },
    created(){
      this.startInit();
    },
    methods:{
      vuePaginate(e){
        this.startInit(e[0]+e[1]);
      },
      startInit(e){
        this.getPaginateWithUsers(e??(this.perPage[1]??'&per_page=')+this.perPage[0]).then(res=>this.insertData(res));
      },
      insertData(res){
        // Get user data to render in template
        this.userData = res.data;
        // Get Pag data from DB & Assign value.
        this.paginations = {
           current_page : res.current_page,
           last_page : res.last_page,
           prev_page_url : res.prev_page_url,
           next_page_url : res.next_page_url,
           per_page      : this.perPage
        }
      },
      getPaginateWithUsers(url){
        return fetch(this.endpoint+url, {
          method: 'GET',
          headers: {'Content-Type': 'Application/json'}
          })
        .then(res => res.json())
        .then(res => res)
        .catch(err => err);
        /* You can also request with Axios */
        return  axios.get(this.endpoint+url,{
          headers: {'Content-Type': 'Application/json'}
        })
        .then(res => res.data)
        .catch(err => err);
      },
    }
}

</script>

Explanation of usage

1.vuePagnation methods can listen child PageNumber & PerPage to the template.

  <vue-pagination @event="vuePaginate"></vue-pagination>

  vuePaginate(e){
    <!-- Array parameter value will be response -->
     e[0] = 1;
     e[1] = '&perpage=2';

    <!-- Call server request methods & insert the url -->
     this.getPaginateAndUserData(e[0]+e[1]).then(res=> this.insertData(res))
  }

2.We need to assign response value to paginations.

<vue-pagination :meta-data="paginations"></vue-pagination>

this.paginations = {
   current_page  : res.current_page,
   last_page     : res.last_page,
   prev_page_url : res.prev_page_url,
   next_page_url : res.next_page_url,
   per_page      : this.perPage
}

3.On each sides pagination number will be show.

<vue-pagination :onSides="1"></vue-pagination>
<<,1,...,4,5,6,...,20,>>

Or

<vue-pagination :onSides="2"></vue-pagination>
<<,1,...,10,11,12,13,14,...,20,>>

4.You can also change the style of css customize

:style="style"

this.style: {
  color : 'rgb(106, 106, 114)',
  activeColor : '#333',
  background : '#fff',
  activeBackground : 'rgb(214, 247, 255)',
  fontFamily : 'sans-serif',
  hover: 'rgb(214, 247, 255) 1px -1px 5px inset',
  border: '0.5px solid rgb(209, 237, 251)',
  borderBar : '1px solid rgb(209, 237, 251)',
  next : '&raquo;',
  prev : '&laquo;'
},

That's all what you need

In your template

 <template>
  <!-- CSS only -->
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
  <div id="app" class="container-fluid">

     <div class="row">

      <div class="col-12 pt-3 text-center">
        <h3 class="pb-3">Vue Laravel Pagination</h3>
        <vue-pagination class="mb-2"  @event="vuePaginate" :meta-data="paginations" :onSides="1"></vue-pagination>
      </div>

      <div v-show="userData" v-for="(d,i) in userData" :key="i" class="col-12 col-md-6 mt-2">
        <div class="card shadow">
          <div class="card-body" style="min-height:130px;">
            <h5 class="card-title">{{ d.id +' - '+ d.title }}</h5>
            <h6 class="card-subtitle mb-2 text-muted">{{ d.created_at }}</h6>
            <p class="card-text">{{ d.slug }}</p>
          </div>
        </div>
      </div>

     </div>

  </div>
</template>

In your script tab

<script>
  import { VuePagination } from '@zakerxa/vue-laravel-pagination';
  import { defineComponent } from 'vue';
  export default defineComponent({
    name: 'ServeDev',
    data () {
        return {
          endpoint    : 'http://developers.zakerxa.com/api/paginations?page=',
          perPage     : [2,'&per_page=' /* default path => '&per_page=' (Or) change [2,'&UrPath='] */],
          userData    : [],
          paginations : {}
        }
      },
      components:{
        VuePagination
      },
      created(){
        this.startInit();
      },
      methods: {
        vuePaginate(e){
          this.startInit(e[0]+e[1]);
        },
        startInit(e){
          this.getPaginateWithUsers(e??(this.perPage[1]??'&per_page=')+this.perPage[0]).then(res=>this.insertData(res));
        },
        insertData(res){
          this.userData = res.data;
          this.paginations = {
             current_page : res.current_page,
             last_page : res.last_page,
             prev_page_url : res.prev_page_url,
             next_page_url : res.next_page_url,
             per_page      : this.perPage
          }
        },
        getPaginateWithUsers(url){
          return fetch(this.endpoint+url, {
            method: 'GET',
            headers: {'Content-Type': 'Application/json'}
            })
          .then(res => res.json())
          .then(res => res)
          .catch(err => err);
        }
      }
  });
  </script>