st-paginate v0.0.6
st-paginate
A standard web component port of AdeleD's ReactPaginate.
Component
Usage
HTML
<st-paginate
page-range-displayed="4"
margin-pages-displayed="4"
container-class-name="pagination"
active-class-name="active"
previous-label-text="Previous Label"
next-label-text="Next Label"
break-label-text=".*."
id="pagination-comp"
page-count="20"></st-paginate>
JavaScript
document
.getElementById('pagination-comp')
.addEventListener('pageChange', function (e) {
console.log(e.detail.selected + 1); // see `pageChange` above for more information
});
Examples
Check out the GitHub pages link for ReactJS and AngularJS examples.
Why?
I wanted to see if I could take a ReactJS component package and re-create it as Standard Web Component using Stencil, this is the result of that idea. I had used ReactPaginate recently on a ReactJS project and thought it would be a good candidate. Nothing more, nothing less.
Stencil
Stencil is a compiler for building fast web apps using Web Components.
Stencil combines the best concepts of the most popular frontend frameworks into a compile-time rather than run-time tool. Stencil takes TypeScript, JSX, a tiny virtual DOM layer, efficient one-way data binding, an asynchronous rendering pipeline (similar to React Fiber), and lazy-loading out of the box, and generates 100% standards-based Web Components that run in any browser supporting the Custom Elements v1 spec.
Stencil components are just Web Components, so they work in any major framework or with no framework at all.
Using this component
Script tag
- Put a script tag similar to this
<script src='https://unpkg.com/st-paginate@0.0.2/dist/stpaginate.js'></script>
in the head of your index.html - Then you can use the element anywhere in your template, JSX, html etc
Node Modules
- Run
npm install st-paginate --save
- Put a script tag similar to this
<script src='node_modules/st-paginate/dist/stpaginate.js'></script>
in the head of your index.html - Then you can use the element anywhere in your template, JSX, html etc
In a stencil-starter app
- Run
npm install st-paginate --save
- Add
{ name: 'st-paginate' }
to your collections - Then you can use the element anywhere in your template, JSX, html etc