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

sm-pagination

v0.1.2

Published

mithril semantic-ui pagination widget

Downloads

28

Readme

sm-pagination

Basic pagination for mithril and semantic, it can also be used with bootstrap (3+)

It requires mithril and semantic-ui-menu

Pagination file can be used with any common.js it is expect for mithril to be in global (m variable) or it will attempt to load it with require('mithril'), webpack its recommended

Example

Demo

Demo

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.10.3/semantic.min.css">
    <script src="bower_components/mithril/mithril.js"></script>
    <script src="Pagination.js"></script>
</head>
<body>
    
    <script src="test.js"></script>
</body>
</html>

function list(data) {
    return m('.ui.segment.sixteen.wide.column', [
        m('ul.ui.bulleted.list', data.map(function (item) {
            return m('li', {
                key: item.id
            }, item.name);
        }))
    ]);
}

function table(data) {
    return m('.ui.sixteen.wide.column', [
        m('table.ui.table', [
            m('tbody', data.map(function (item) {
                return m('tr', {
                    key: item.id
                }, [
                    m('td', item.id),
                    m('td', item.name)
                ]);
            }))
        ])
    ]);
}

module.controller = function () {
    module.vm.init();
    this.pagination = m.component(Pagination, {
        data: module.vm.data,
        rowsperpage: module.vm.rowsperpage,
        pagerender: list,
        wrapperclass: 'column'
    });
    this.paginationCtrl = new this.pagination.controller();
};

module.vm = {};
module.vm.init = function () {
    this.data = array;
    this.rowsperpage = 10;
    this.page = m.prop(3);
};


module.view = function (ctrl) {
    return m('.ui.grid.page.one.column', [
        m('h1', 'Pagination'),
        m.component(Pagination, {
            data: module.vm.data,
            rowsperpage: module.vm.rowsperpage,
            pagerender: list,
            wrapperclass: 'column',
            page: module.vm.page
        }),
        m.component(Pagination, {
            data: module.vm.data,
            rowsperpage: module.vm.rowsperpage,
            pagerender: table,
            wrapperclass: 'column'
        }),
        m('.row', [
            m('.column', [
                m('br')
            ])
        ]),
        ctrl.pagination.view(ctrl.paginationCtrl),
        m('.row', [
            m('.column', [
                m('button.ui.button', {
                    onclick: function () {
                        module.vm.data.splice(30, 10);
                        ctrl.paginationCtrl.goToPage(4);
                        module.vm.page(4);
                    }
                }, 'go to page 3')
            ])
        ])
    ]);
};

m.mount(window.document.body, module);

Attributes

It accepts the following properties

  • data, array of data to paginate
  • rowsperpage, # of rows to show each page
  • pagerender, page render function
  • wrapperclass, class to add to parent div
  • page, m.prop value of the current page
  • class object map with:
    • activeClass, applied to the active icons, defaults active
    • itemClass, applied to non icon items, defaults icon
    • leftIconClass, applied to the left arrow icon item, defaults left arrow icon
    • rightIconClass, applied to the right arrow icon item, defaults right arrow icon
    • iconItemClass, applied to the icon item items, defaults icon item,
    • disabledClass, applied to disaled items, defaults disabled
    • menuClass, applied to the menu pagination parent div, defaults ui pagination menu small

Bootstrap

To make it look good with bootstrap just pass the followin classes, tested with bootstrap 3+

classes: {
    leftIconClass: 'glyphicon glyphicon-arrow-left',
    rightIconClass: 'glyphicon glyphicon-arrow-right'
}