Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

angular1-star-rating

BioPhoton1.4kMIT1.2.11TypeScript support: included

Angular1 Star Rating is a Angular1.5 component written in typescript, based on css only techniques written in scss

Rating, Stars, Star Rating, Star-Rating, Starrating, Icon, SVG, CSS, Pure CSS, CSS only, JavaScript, Angular, Angular Component, Angular1, Angular1 Component, Angular1.5, Angular1.5 Component, Typescript

readme

Angular1 Star Rating ⭐⭐⭐⭐⭐

⭐ Angular 1.5 Component written in typescript, based on css only techniques. ⭐

License Bower Version NPM Version
Standard Version
Build Status NPM

NPM Package Quality

Angular1 Star Rating is a >1.5 Angular component written in typescript.
It is based on css-star-rating, a fully featured and customizable css only star rating component written in scss.

Angular1-Star-Rating

DEMO

Css Angular1 (>=1.5) Angular (>=2)
Css Star Rating Angular1 Star Rating Angular Star Rating

Features

This module implements all Features from CSS-STAR-RATING. It also provides callbacks for all calculation functions used in the component as well as all possible event emitters.

  • <input checked="" disabled="" type="checkbox"> id - The html id attribute of the star rating
  • <input checked="" disabled="" type="checkbox"> rating - The actual Star rating
  • <input checked="" disabled="" type="checkbox"> showHalfStars - To display half stars or not
  • <input checked="" disabled="" type="checkbox"> showHoverStars - To display hover state on stars or not
  • <input checked="" disabled="" type="checkbox"> numOfStars - The max number of stars you can rate
  • <input checked="" disabled="" type="checkbox"> size - The different sizes of the component
  • <input checked="" disabled="" type="checkbox"> space - The space between stars
  • <input checked="" disabled="" type="checkbox"> staticColor - A static color for the stars
  • <input checked="" disabled="" type="checkbox"> disabled - Component is in disabled mode
  • <input checked="" disabled="" type="checkbox"> starType - Stars can be displayed as svg, character or icon-font like fontawesome, glyphicons or ionicons
  • <input checked="" disabled="" type="checkbox"> labelText - The value of the label text
  • <input checked="" disabled="" type="checkbox"> labelHidden - If the label is visible or not
  • <input checked="" disabled="" type="checkbox"> labelPosition - The position of the label
  • <input checked="" disabled="" type="checkbox"> speed - The duration of the animation
  • <input checked="" disabled="" type="checkbox"> direction - The direction of the component i.e. right to left
  • <input checked="" disabled="" type="checkbox"> readOnly - Click event is disabled
  • <input checked="" disabled="" type="checkbox"> getColor - Custom function to calculate the color for a rating
  • <input checked="" disabled="" type="checkbox"> getHalfStarVisible - Custom function to calculate value for displaying half stars or not
  • <input checked="" disabled="" type="checkbox"> onClick - Event emitter for onClick action
  • <input checked="" disabled="" type="checkbox"> onRatingChange - Event emitter for onRatingChange event

Browser support

IE Firefox Chrome Safari Opera
> 11 > 50 > 55 > 10 > 41

Install

*Get Angular1 Star Rating:

  • clone & build this repository
  • download as .zip
  • via npm: by running $ npm install angular1-star-rating from your console
  • via bower: by running $ bower install angular1-star-rating from your console
  • via cdn: by adding the git-cdn reference in your index.html
    <script src="https://cdn.rawgit.com/BioPhoton/angular1-star-rating/v1.2.4/dist/index.js"></script>

Load library as minified js file

<script src="[bower or npm folder or git-cdn path]/angular1-star-rating/dist/index.js"></script>

Inject it into angular

angular.module('myApp', ['star-rating'])

Use it

<star-rating-comp rating="'3.0'"></star-rating-comp>

Component Properties

Input (< bindings)

id: string (Optional)
The html id attribute of the star rating
Default: undefined

<star-rating-comp id="'my-id'"></star-rating-comp>

rating: number (Optional)
The actual star rating value
Default: 0

<star-rating-comp rating="3"></star-rating-comp>

showHalfStars: boolean (Optional) To show half stars or not
Options: true, false
Default: false

<star-rating-comp show-half-stars="true"></star-rating-comp>

showHoverStars: boolean (Optional) To show hover state on stars or not
Options: true, false
Default: false

<star-rating-comp show-hover-stars="true"></star-rating-comp>

numOfStars: number (Optional)
The possible number of stars to choose from
Default: 5

<star-rating-comp num-of-stars="6"></star-rating-comp>

label-text: string (Optional)
The label text next to the stars.
Default: undefined

<star-rating-comp label-text="'My text!'"></star-rating-comp>

labelPosition: starRatingPosition (Optional)
The position of the label
Options: top, right, bottom, left
Default: left

<star-rating-comp label-position="'top'"></star-rating-comp>

space: starRatingStarSpace (Optional)
If the start use the whole space or not. Options: no, between, around Default: no

<star-rating-comp space="'around'"></star-rating-comp>

size: starRatingSizes (Optional)
The height and width of the stars.
Options: small, medium, large
Default: ok

<star-rating-comp size="'small'"></star-rating-comp>

color: starRatingColors (Optional)
Possible color names for the stars.
Options: default, negative, ok, positive
Default: undefined

<star-rating-comp color="'positive'"></star-rating-comp>

disabled: boolean (Optional)
The click callback is disabled, colors are transparent
Default: false

<star-rating-comp disabled="true"></star-rating-comp>

direction: string (Optional)
The direction of the stars and label.
Options: rtl, ltr
Default: rtl

<star-rating-comp direction="'ltr'"></star-rating-comp>

readOnly: boolean (Optional)
The click callback is disabled
Default: false

<star-rating-comp read-only="true"></star-rating-comp>

speed: starRatingSpeed (Optional)
The duration of the animation in ms.
Options: immediately, noticeable, slow
Default: noticeable

<star-rating-comp speed="'slow'"></star-rating-comp>

starType: starRatingStarTypes (Optional)
The type of start resource to use.
Options: svg, icon, custom-icon Default: svg

<star-rating-comp star-type="'icon'"></star-rating-comp>

getColor: Function (Optional)
Calculation of the color by rating.
Params: rating, numOfStars, staticColor
Return: colorName as string

<star-rating-comp get-color="parentCtrl.getColor(rating, numOfStars, staticColor)"></star-rating-comp>

getHalfStarVisible: Function (Optional)
Calculation for adding the "half" class or not, depending on the rating value.
Params: rating
Return: boolean

<star-rating-comp get-half-star-visible="parentCtrl.getHalfStarVisible(rating)" rating="3.1"></star-rating-comp>
function getHalfStarVisible(rating) {
    var absDiff = Math.abs(rating % 1);

    if(absDiff == 0.1) {
        return false;
    }

    return absDiff > 0;
}

Output (& bindings)

onClick: Function (Optional)
Callback function for star click event Params: $event

<star-rating-comp on-click="parentCtrl.onClick($event)"></star-rating-comp>
function onClick($event) {
    parent.clickCount = parent.clickCount + 1;
}

onRatingChange: Function (Optional)
Callback function for rating update event Params: $event

<star-rating-comp on-rating-change="parentCtrl.onRatingChange($event)"></star-rating-comp>
function onRatingChange($event) {
    parent.rating = $event.rating;
}

changelog

1.2.11 (2017-04-08)

Bug Fixes

  • chore: updated dependencies and build scripts (f25bc1a)
  • defaults: provide defaults for numOfStars (e225096)
  • packages: updates dependencies (111314f)
  • svg mode: remove svg's if not in use (891d565)
  • syntax: change let to const (d4eb749)
  • template: refactored class names (ee2270f), closes #58

Features

  • helper function: implement basic helper function for ionic release (212932c)
  • hover: finished hover implementation (a1c5341), closes #55
  • hover: start implement hover into component (819171b)
  • labelHidden: finished labelHidden implementation (dcb0da5)

1.2.10 (2017-04-07)

Bug Fixes

  • chore: updated dependencies and build scripts (f25bc1a)
  • defaults: provide defaults for numOfStars (e225096)
  • packages: updates dependencies (111314f)
  • svg mode: remove svg's if not in use (891d565)
  • syntax: change let to const (d4eb749)
  • template: refactored class names (ee2270f), closes #58

Features

  • hover: finished hover implementation (a1c5341), closes #55
  • hover: start implement hover into component (819171b)
  • labelHidden: finished labelHidden implementation (dcb0da5)

1.2.9 (2017-02-25)

Bug Fixes

  • defaults: provide defaults for numOfStars (e225096)

1.2.9 (2017-02-25)

Bug Fixes

  • defaults: provide defaults for numOfStars (e225096)

1.2.8 (2017-02-25)

Bug Fixes

  • angular warning: changed bundling process to exclude external dependencies. #51 (ecc01e7)
  • build: rebuild (6d491c0)
  • build: updated dist and example (037813d)
  • events: fixed onRatingUpdated error (f788d95), closes #44
  • example: create js example (8930056)
  • example: use dist.index.js (f2ece08)
  • readme: updated readme (4024afd)

1.2.7 (2017-02-20)

Bug Fixes

  • eventemitter is not a function: implement checks (2455844)
  • version bump: bumped version to 1.2.7 (62ffffb)

1.2.6 (2017-02-20)

Bug Fixes

  • build: updated bower json (85b5554)
  • version bump: bumped version to 1.2.6 (398aa49)

1.2.5 (2017-01-22)

Bug Fixes

  • build: rebuild project, edit comments (0b611ae)
  • updated binding: renamed onUpdate to onRatingChange (6e59266)
  • updated binding: renamed onUpdate to onRatingChange (889901b)
  • updated paths: updated repo path and links (b51dec6)

1.2.4 (2017-01-13)

Bug Fixes

  • build: rebuild project (f0ebc77)
  • half stars: set half star visible (f840614)
  • half stars: fix setHalfstar call (b07e5d1)
  • imports: refactored imports (0461f00)
  • rebuild: rebuild src and example (1105965)

1.2.3 (2017-01-13)

Bug Fixes

  • changelog: updated changelog (5b0cf9b)
  • docs: fix cdn and plunker link (d5c1d4c)
  • docs: fix plunker link (e03abc8)

1.2.2 (2017-01-12)

1.2.1 (2017-01-12)

Bug Fixes

  • build: build project (e6c7e9f)
  • example: updated example (ada0aeb)
  • example: updated example (6ddd4f6)
  • example: updated example (9ee88a3)
  • property color: refactored set color (a003b6d)

1.2.0 (2016-12-23)

Bug Fixes

Features

  • new bindings: implement new bindings (0df2441)

1.1.0 (2016-12-21)

Bug Fixes

Features

  • controller: start implement getter and setter #38 (e91541c)
  • example: implement new props (f410e9e)
  • example: implement new props (e6cc7b1)
  • examples: migrate to component ui-routing (cb709ca)
  • examples: migrate to component ui-routing (2e23ab7)
  • refactoring: setter getter, names, structure (ce44cc1)
  • update bindings: updated spread (now space) and color bindings (0d2fe70)
  • update dependencies: update css-star-rating to latest version (88a80f0)
  • update example: update demo pages (6d216a1)
  • update example: updated spread (now space) and color bindings (3619141)
  • update tests: for new bindings (4b0570d)
  • update tests: for new bindings (e3ec99b)

1.0.14 (2016-12-08)

Bug Fixes

  • codeclimate: changed zml config (ec64685)
  • component: changed order of props (bb5c31b)
  • readme: updated readme (93ddeb0)
  • readme: updated readme (87021ea)
  • resources: added images (49ee7e2)

1.0.13 (2016-11-29)

Bug Fixes

  • bindings: change & binding to > of getColor and getHalfStarVisible (6d49256)
  • build: rebuild project (9e6ee9d)

1.0.12 (2016-11-28)

Bug Fixes

  • build: rebuild project (ae41d5a)
  • dependencies: edit dependencies in example folder (44d2870)
  • halfstar callback: fixed half-star callback param (07b1373)

Features

  • dependency update: removed scss files (e23234c)
  • updated dependencies: fixed build, updated packages (4c3fb34)

1.0.10 (2016-11-27)

1.0.9 (2016-11-26)

Bug Fixes

  • bild: rebuild project (82268b3)
  • build: rebuild project (a53f68f)
  • color: display default color if rating is 0 (cee14a8)
  • component: add default color for 0 rating (2090275)
  • refactoring: removed console.log (02efb08)
  • refactoring: removed console.log (0d36f55)
  • scss: added img to animation section (2c1bf4c)
  • scss: fix value modifiers greater then the numOfStars (8be4ff7)

1.0.7 (2016-11-25)

Bug Fixes

Features

  • half-star modifier: implement halfStar callback #25 (1fd589e)
  • half-star modifier: implement scss modifier #25 (49a90e9)
  • half-star modifier: start implement component functionality #25 (383f59c)
  • half-star modifier: test component functionality #25 (9b6d8ce)
  • half-star modifier: test component functionality #25 (f44a2f7)
  • half-star modifier: tested halfStar callback #25 (a135396)

1.0.6 (2016-11-22)

Bug Fixes

  • build: build project (2f11b48)
  • clog: removed config (32ac62d)
  • compile: compiled project (4b3b92d)
  • component: change component name (9aa1049)
  • controller: change variable name (7a520b6)
  • defaults: extend default values (8831b38)
  • example: updated example, changed num serve script (07f3d86)
  • example: use d.ts files (6dccda9)
  • formatting: removed empty line (db1b0ec)
  • gitignore: updated ignore file (0fb3b4c)
  • ng1: added ctrl in index.ts (abc5bf9)
  • styleguide: edit gulp task options (ffc8efb)
  • styleguide: removed imports for now because of styleguide import error (f874c72)
  • typings: fixed typescript error (ae45a51)
  • webpack: reduced config settings (7840e49)

Features

  • bower: released bower lib under angular1-star-rating (91d5ff7), closes #24
  • bower: start implement bower setup (b39455b)
  • css: added a themes file (1418094)
  • css modifier: start implement star-img modifier #23 (e4e8d87)
  • readme: create more content for readme #9 (f192d7a)
  • typing: implement typescript definition files (cd1aaa3)
  • typings: implement typings and sourcemaps (b61c999), closes #22

1.0.5 (2016-10-30)

Features

  • changelog: implement npm script for changelog file (0324329)
  • compress scss and js: compress and strip comments in scss and js (ea12929), closes #20

1.0.4 (2016-10-30)

Bug Fixes

  • assets handling: refactored path's, file handling, removed inline svg (8e18959)
  • renamed: renamed bundle.js to index.js (e2282db)

Features

  • tested as module: tested in other project, refactored build (ec70273)

1.0.3 (2016-10-23)

Bug Fixes

  • app: setup basic project, started example (689cee9)
  • demo: implement default color (df0677a)
  • icon as star: static colors (dc51478)

Features

  • component: polished docs, scss, logic (ab048b8)
  • create examples folder: copy setup (78093e8)
  • create examples folder: refactore old src folder structure #14 (501b8d4)
  • create examples folder: refactored package.json (538ff9b)
  • create examples folder: refactored root src folder (10e8143)
  • create examples folder: refactoring (74b08c7)
  • create examples folder: started task #14 (2e7f4d5)
  • demo: cleanup (9210b13), closes #7
  • demo: implement new features (18dd439)
  • icon as star: implement option fir icon as star (17c89fa), closes #11
  • label-position: implement top and bottom position (378ebe5), closes #10
  • star-type: star implementing star types (d4ecf4a)
  • testing: progress setup unit tests (00a98cc)
  • unit testing: fix webpack integration (6b9921a)