5.0.0 • Published 1 year ago

sx-paginate v5.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

sx-paginate

NPM JavaScript Style Guide

Screenshot 2022-12-29 at 5 18 48 AM

DEMO - https://stackblitz.com/edit/react-hctxyq?file=src/App.js

Install

npm install --save sx-paginate

Usage

import React, { useState, useEffect } from 'react'

import { SxPaginate } from 'sx-paginate'
import 'sx-paginate/dist/index.css'

const App = () => {
  const [posts, setPosts] = useState([])
  const [paginatedPosts, setPaginatedPosts] = useState([])

  const onPaginate = (pageNumber: number) => {
    console.log(pageNumber)
  }

  useEffect(() => {
    (async () => {
      const res = await fetch('https://dummyjson.com/posts')
      const data = await res.json()
      setPosts(data.posts)
    })()
  }, [])

  useEffect(() => {
    console.log(paginatedPosts)
  }, [paginatedPosts])

  return (
    <>
      {paginatedPosts.map((post: any) => (
        <div key={post.id}>{post.title}</div>
      ))}

      <SxPaginate
        recordsPerPage={10}
        onPaginate={onPaginate}
        records={posts}
        setRecords={setPaginatedPosts as any}
        activeBtnStyle={{ background: 'coral' }}
      />
    </>
  )
}

export default App

Options

OptionsDescription
recordsPerPageRecords display on the page eg. 10
recordsArray of recrods
onPaginatefuncton takes paginated page number as an arguemnent (pageNumber) => {console.log(pageNumber)}
setRecordsfunction to get paginated records
buttonStyle ?CSS Properties
activeBtnStyle ?CSS Properties
ellipses?{Boolean} show ellipses for long pagination
activeColor{String} color value to chnage the background color of active page

License

MIT © suboor123

5.0.0

1 year ago

4.0.3

1 year ago

4.0.2

1 year ago

4.0.1

1 year ago

4.0.0

1 year ago

3.0.2

1 year ago

3.0.0

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago