Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ngx-bar-rating

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-bar-rating

Angular Bar Rating

  • 0.9.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.9K
decreased by-2.97%
Maintainers
1
Weekly downloads
 
Created
Source

Angular Bar Rating

npm npm Build Status npm

Table of Contents

Installation

Install it with npm

npm install --save ngx-bar-rating

SystemJS

If you are using SystemJS, you should also adjust your configuration to point to the UMD bundle.

In your systemjs config file, map needs to tell the System loader where to look for ngx-bar-rating:

map: {
  'ngx-bar-rating': 'node_modules/ngx-bar-rating/bundles/ngx-bar-rating.umd.js',
}

Here is a working plunkr

Basic usage:

Import BarRatingModule in the root module

import { BarRatingModule } from "ngx-bar-rating";

@NgModule({
  imports: [
    // ...
    BarRatingModule
  ]
})

In your template

<bar-rating [(rate)]="rate" [max]="5"></bar-rating>

Rating options (inputs):

Movie rating example
<bar-rating [(rate)]="rate" [max]="4" [theme]="'movie'" [titles]="['Bad', 'Mediocre' , 'Good', 'Awesome']"></bar-rating>

It can be used with angular forms and reactive forms, for example:

<form #form="ngForm">
  <bar-rating name="rating" [(ngModel)]="formRating" [max]="4" required disabled></bar-rating>
</form>
<p>form is valid: {{ form.valid ? 'true' : 'false' }}</p>
<pre>{{ formRating }}</pre>

Predefined themes

Import rating theme using in the global style style.css

  • pure css stars (default)
@import '~ngx-bar-rating/themes/br-default-theme';
  • bootstrap stars
@import '~ngx-bar-rating/themes/br-bootstrap-theme';
  • fontawesome stars
@import '~ngx-bar-rating/themes/br-fontawesome-theme';
  • fontawesome-o stars
@import '~ngx-bar-rating/themes/br-fontawesome-o-theme';
  • horizontal bars
@import '~ngx-bar-rating/themes/br-horizontal-theme';
  • vertical bars
@import '~ngx-bar-rating/themes/br-vertical-theme';
  • custom svg stars
@import '~ngx-bar-rating/themes/br-custom-stars-theme';
  • movie rating
@import '~ngx-bar-rating/themes/br-movie-theme';
  • square rating
@import '~ngx-bar-rating/themes/br-square-theme';

Custom Style

You can extend or create your own theme using these classes

.br {

  // rating wrapper

  .br-units {

    // units container
  }

  .br-unit {

    // units (stars)

    &.br-active{

      // hovered units (stars)
    } 
    &.br-selected {

      // selected units (stars)
    }
  }

  &.br-readonly {

    .br-active, .br-selected {
      
      // selected or active in read
    }
  }

  .br-text {
    
    // Rate text
  }
}

You can also do the same for forms classes such as untouched, touched, dirty, invalid, valid ...etc

If you have a nice rating style you would like to share, propuse your theme and I will include it in the package.

Issues

If you identify any errors in this component, or have an idea for an improvement, please open an issue. I am excited to see what the community thinks of this project, and I would love your input!

Author

Murhaf Sousli

Keywords

FAQs

Package last updated on 15 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc