Create simple and complexe pagination easily with this webcomponent
- Demo
- Install
- Get Started
- Listen for changes
- Javascript API
- SASS API
- Sugar Web Components Documentation
- Browsers support
- Code linting
- Contribute
- Who are Coffeekraken?
- Licence
npm install coffeekraken-s-pagination-component --save
First, import the component into your javascript file like so:
import SPaginationComponent from "coffeekraken-s-pagination-component"
Then simply use it inside your html like so:
<s-pagination
pages="50"
current="10"
limit="5"
href="/comments/%d"
></s-pagination>
Optionally you can generate a base css for your pagination like so:
@import "node_modules/coffeekraken-s-pagination-component/index";
@include s-pagination-classes($colors: default primary secondary);
This use the sugar colors system
This component has two "modes". The first is the one where you define an href
property. By doing this, each links in the pagination will be plain old html links. Here's an example:
<s-pagination
pages="50"
current="10"
limit="5"
href="/comments/%d"
></s-pagination>
In this example, each links would be something like so:
- comments/1
- comments/2
- comments/3
- comments/4
- etc...
The second mode is when you do not define an href
property. You have then two ways to listen for changes in the pagination component. Here's how:
$pagination.addEventListener("change", e => {
// e.detail.newPage
// e.detail.previousPage
// do whatever you need to here...
})
$pagination.setProp({
onchange: (newPage, previousPage) => {
// do whatever you need to here...
}
})
IE / Edge | Firefox | Chrome | Safari |
---|---|---|---|
*IE11+ | last 2 versions | last 2 versions | last 2 versions |
- This component use the Proxy feature that is not natively supported by IE11. You'll need to load a polyfill in order to make it work properly.
As browsers are automatically updated, we will keep as reference the last two versions of each but this component can work on older ones as well.
The webcomponent API (custom elements, shadowDOM, etc...) is not supported in some older browsers like IE10, etc... In order to make them work, you will need to integrate the corresponding polyfill.
This package uses some code linting rules. Here's the list:
- StandardJS for javascript files
-
Stylelint with stylelint-config-standard for
scss
files
Your commits will not been accepted if the code style is not respected!
This is an open source project and will ever be! You are more that welcomed to contribute to his development and make it more awesome every day. To do so, you have several possibilities:
We try to be some cool guys that build some cool tools to make our (and yours hopefully) every day life better.
The code is available under the MIT license. This mean that you can use, modify, or do whatever you want with it. This mean also that it is shipped to you for free, so don't be a hater and if you find some issues, etc... feel free to contribute instead of sharing your frustrations on social networks like an asshole...