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

ng-starrating

v1.0.20

Published

[![npm version](https://img.shields.io/badge/npm-v1.0.20-brightgreen.svg)](https://www.npmjs.com/package/ng-starrating/v/1.0.20) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/riteshgandhi/ng-star-rating)

Downloads

4,656

Readme

ng-starrating

npm version License

Simple, highly Customizable and Responsive Star Rating Library built using Angular.

For production, use the files from the dist/ folder.

Demo

Edge browser support: Import webcomponents bundle for Edge browser

<script src="https://cdn.jsdelivr.net/npm/@webcomponents/[email protected]/webcomponents-bundle.min.js"></script>

Why it's better

  • Simple and customizable
  • Light weight. Built using CSS only
  • Responsive
  • Parameterized total number of stars

Installation

Use one of the following methods to add the Star Rating library to your project:

Usage

//app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { RatingModule } from 'ng-starrating';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [ AppComponent ],
  imports: [ BrowserModule, RatingModule ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
<div style="text-align:center">
  <h1>
    ng-starrating demo
  </h1>
  <star-rating value="5" totalstars="5" checkedcolor="red" uncheckedcolor="black" size="24px" readonly="false" (rate)="onRate($event)"></star-rating>
</div>
//app.components.ts
import { Component } from '@angular/core';
import { StarRatingComponent } from 'ng-starrating';

@Component({ 
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})

export class AppComponent {
  constructor() { }

  ngOnInit() { }

  onRate($event:{oldValue:number, newValue:number, starRating:StarRatingComponent}) {
    alert(`Old Value:${$event.oldValue}, 
      New Value: ${$event.newValue}, 
      Checked Color: ${$event.starRating.checkedcolor}, 
      Unchecked Color: ${$event.starRating.uncheckedcolor}`);
  }
}

Options

Here are the default options

checkedcolor: "gold",
uncheckedcolor: "gray",
size: "24px",
value: 0,
readonly: false,
totalstars: 5

totalstars:

Type: Number

Adds the number of stars. Default value is 5

checkedcolor:

Type: String

Checked color for the star. Default color is "gold". You can even use color codes.

uncheckedcolor:

Type: String

Un-checked color for the star. Default color is "gray". You can even use color codes.

size:

Type: String

Size of the Stars in pixels. Default size is 24px.

value:

Type: Number

Value of the Star Rating. Default value is 0. It can be between 0 to 5. It also supports half rating.

readonly:

Type: Boolean

Determines whether the star rating component is readonly.

Events

rate:

Type: EventEmitter

Custom Event, triggers on change of rating value.

Build

Star Rating uses npm to manage package dependencies.

Compatibility

  • All modern browsers

Contributing

All changes should be committed to the files in src/.

Changelog

v1.0.20 - [2020-02-16]

  • Added missing keywords and repository information

v1.0.19,18..16 - [2020-02-16]

  • Fixed issues with Angular 9 upgrade. Star Rating now works with Ivy renderer

v1.0.15 - [2020-02-11]

v1.0.14 - [2020-02-11]

v1.0.13 - [2020-02-11]

  • minor fixes

v1.0.12 - [2020-02-10]

  • Fixed issue with rating not initializing with more than 5 stars when total stars equals 10
  • Upgraded to latest Angular version 9.0.0

v1.0.11 - [2019-12-10]

  • Minor bug fix

v1.0.10 - [2019-12-03]

  • Fixed issue with readonly property

v1.0.9 - [2019-12-02]

  • Added new property "totalstars" to allow parameterization of number of stars

v1.0.8 - Beta [2019-12-02]

  • Added new property "totalstars" to allow parameterization of number of stars

v1.0.7 - [2019-07-20]

  • Upgraded to latest Angular version 8.1.1

v1.0.6 - [2019-01-03]

  • Added custom event "rate"

v1.0.5 - [2018-12-31]

  • Rating can now be only changed by clicking on the star or by manually setting the value property. Mouse hover won't change the rating

v1.0.4 - [2018-12-26]

  • Added demo site

v1.0.3 - [2018-12-26]

  • Removed unwanted packages and updated readme file

v1.0.2 - [2018-12-26]

  • Minor fixes

v1.0.1 - [2018-12-26]

  • Initial release

License

MIT