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-rate-it

v2.1.0

Published

A highly customisable rating component for Vue 2.x.

Downloads

1,672

Readme

Vue-rate-it - Extensible Rating Component for Vue.js 2

Build Status

Vue-rate-it is an extensible, highly customisable rating system for Vue.js 2. It includes four built-in rating components for rating with stars, hearts, images or any Font Awesome glyph.

Features

  • Rate with Stars, Hearts, Images or any Font Awesome glyph.
  • Extensible - Create your own SVG raters by extending the included components.
  • Includes port of nerly 700 font awesome glyphs to use as rating items.
  • Customisable rating increments - Use any increment you want from 0.01 onwards.
  • Customisable styles - Change colours, borders, sizes and spacing.
  • Create read-only ratings.
  • Uses scalable SVG images.
  • Supports v-model for easy syncing (vue 2.2+)
  • Supports RTL (right-to-left)

Check out the detailed docs with examples on the vue-rate-it Github Pages

Getting Started

Below you can see the simple markup required to create a rating component:

Stars

star-rating.png

Try on JSFiddle

<star-rating></star-rating>

Hearts

heart-rating.png

Try on JSFiddle

<heart-rating></heart-rating>

Images

image-rating.png

Try on JSFiddle

<image-rating src="/images/vueLogo.png"></image-rating>

Font Awesome Thumbs-up Glyph

fa-thumbs-up.png

Try on JSFiddle

<fa-rating v-bind:glyph="thumbsUp"></fa-rating>

Note: The fa-rating component requires you to first register the font-awesome glyph you want to use in your Vue instance, which is why this example uses v-bind (see: font-awesome rating component docs)

Setup

NPM

It is recommended that you install vue-rate-it via npm:

npm install vue-rate-it

Once installed you can import the rating components like so:

import {StarRating} from 'vue-rate-it';
import {HeartRating} from 'vue-rate-it';
import {FaRating} from 'vue-rate-it';
import {ImageRating} from 'vue-rate-it';

You may also import all of the components at once, however, you will still need to register each component individually:

import Raters from 'vue-rate-it';

Registering the Rating Components

Global Registration

You can register your raters globally by doing the following:

import Raters from 'vue-star-rating';
Vue.component('star-rating', Raters.StarRating);
Vue.component('heart-rating', Raters.HeartRating);
Vue.component('fa-rating', Raters.FaRating);
Vue.component('image-rating', Raters.ImageRating);

Local Registration

You can register your raters in the components that you want to use them in by doing the following:

import {StarRating} from 'vue-rate-it';

export default{
  components:{
    StarRating
  }
}

You can find details about all the available props, events and options on the docs github pages

Using the CDN

It is recommended that you use vue-rate-it via NPM, however, each rating component does have a dist file available via unpkg. To use the raters via CDN simply include the following in your web page. These components are registered automatically:

Star Rating

<link rel="stylesheet" href="https://unpkg.com/vue-rate-it/dist/cdn/star-rating.min.js">

Heart Rating

<link rel="stylesheet" href="https://unpkg.com/vue-rate-it/dist/cdn/heart-rating.min.js">

Fa Rating (Font-awesome)

<link rel="stylesheet" href="https://unpkg.com/vue-rate-it/dist/cdn/fa-rating.min.js">

Note: The fa-rating component CDN is intended for demonstrative purposes only. It contains an entire port of font-awesome glyphs which makes it more than 700kB in size. It is strongly recommended that you use this component via NPM where you can specify the glyphs that you want to import.

Image Rating

<link rel="stylesheet" href="https://unpkg.com/vue-rate-it/dist/cdn/image-rating.min.js">

All Features

You may also include all features and raters via CDN by doing:

<link rel="stylesheet" href="https://unpkg.com/vue-rate-it/dist/cdn/vue-rate-it.min.js">

Note: This CDN file is intended for demonstrative purposes only. It contains an entire port of font-awesome glyphs which makes it more than 700kB in size. It is strongly recommended that you use NPM where you can specify any glyphs that you want to import.

Registering the Raters

When importing all features via CDN, the raters are not automatically registered, so you will need to register them yourself by doing:

Vue.component('star-rating', VueRateIt.StarRating);
Vue.component('heart-rating', VueRateIt.HeartRating);
Vue.component('image-rating', VueRateIt.ImageRating);
Vue.component('fa-rating', VueRateIt.FaRating);

You may also register them in your view model:

new Vue({
  el: "#app",
  components:{
    'star-rating': VueRateIt.StarRating
  }
});

You can find details about all the available props, events and options on the docs github pages

Syncing Ratings between Parent and Child

The first thing you will want to do is sync your ratings between the parent and the rating component. If you are using Vue 2.2 and above the simplest way to sync the rating is to use v-model:

Basic Markup

<heart-rating v-model="rating"></heart-rating>

Complete Example

<template>
  <div>
    <heart-rating v-model="rating"></heart-rating>
    <div>Currently Selected: {{rating}}</div>
    <div><a href="#" @click.prevent="rating = 0">Reset Rating</a></div> 
  </div>
</template>

<script type="text/javascript">   
import {HeartRating} from 'vue-rate-it';

export default{
  components: {
    HeartRating
  },
  data(){
    return {
      rating: 3
    }
  }
}
</script>

Syncing Ratings in Vue 2.1 and below

It isn't possible to use v-model on the component in Vue.js 2.1 and below, however, the following is the equivalent of the v-model example above:

Basic Markup

<heart-rating @rating-selected="rating = $event" :rating="rating"></heart-rating>

Complete Example

<template>
  <div>
    <heart-rating @rating-selected="rating = $event" :rating="rating"></heart-rating>
    <div>Currently Selected: {{rating}}</div>
    <div><a href="#" @click.prevent="rating = 0">Reset Rating</a></div> 
  </div>
</template>

<script type="text/javascript">   
import {HeartRating} from 'vue-rate-it';

export default{
  components: {
    HeartRating
  },
  data(){
    return {
      rating: 3
    }
  }
}
</script>

What Next

Once you have everything up and running, you can check out the detailed docs on the vue-rate-it docs github pages