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

vue-poll

v0.1.9

Published

A Vue JS poll component

Downloads

467

Readme

Vue-poll

A Twitter-like vote component, made with Vue.js 2

DEMO

Prerequisites

Installing

Using npm:

$ npm install vue-poll

Using cdn:

<script src="https://unpkg.com/vue-poll/dist/vue-poll.min.js"></script>

Example (NPM)

Define vue-poll component markup inside your custom component.

For example in your my-poll.vue:

<template>
    <div>
        <vue-poll v-bind="options" @addvote="addVote"/>
    </div>
</template>

<script> 
    
    import VuePoll from 'vue-poll'
    
    export default {        
        data() {
            return {
                options: {
                    question: 'What\'s your favourite <strong>JS</strong> framework?',
                    answers: [
                        { value: 1, text: 'Vue', votes: 53 },
                        { value: 2, text: 'React', votes: 35 },
                        { value: 3, text: 'Angular', votes: 30 },
                        { value: 4, text: 'Other', votes: 10 } 
                    ]
                }
            }
        },
        components: {
            VuePoll
        },
        methods: {
            addVote(obj){
                console.log('You voted ' + obj.value + '!');
            }
        }
    }
</script>

Example (CDN)

<body>
    <div id="app">
        <vue-poll v-bind="options" @addvote="addVote"/>
    </div>

    <script src="https://unpkg.com/vue-poll/dist/vue-poll.min.js"></script>
    <script> 

        Vue.use(VuePoll);

        new Vue({
            el: '#app'
            data: function() {
                return {
                    options: {
                        question: 'What\'s your favourite <strong>JS</strong> framework?',
                        answers: [
                            { value: 1, text: 'Vue', votes: 53 },
                            { value: 2, text: 'React', votes: 35 },
                            { value: 3, text: 'Angular', votes: 30 },
                            { value: 4, text: 'Other', votes: 10 } 
                        ]
                    }
                }
            },
            methods: {
                addVote: function(obj){
                    console.log('You voted ' + obj.value + '!');
                }
            }
        });
    </script>
</body>

Options

  • question (required) (string-html)

    The question of the poll.

  • answers (required) (array)

    An array of the answers of the poll.

    value (required) (integer) A unique value for each answer

    text (required) (string-html) Answer's text

    votes (required) (integer) Answer's votes

    selected (required when multiple is true) (boolean) Selected state of the answer

    custom_class (optional) (string) Custom css class for the answer element

  • showResults (optional) (boolean) (default: false)

    Set this to true to skip the voting and show the results of the poll

  • finalResults (optional) (boolean) (default: false)

    Set this to true to skip the voting and show the results of the poll. Winner will be highlighted

  • multiple (optional) (boolean) (default: false)

    Set this to true for multiple voting

  • submitButtonText (optional) (string) (default: Submit)

    Text of the multiple voting submit button

  • customId (optional) (number)

    A custom id that will be returned on the addvote method

Methods

  • addvote (returns object)

    Callback on add vote. It returns an object that includes: answer's value, answer's votes, total poll's votes and the custom id

License

MIT license