balinterdi / ember-cli-star-rating

An Ember CLI addon for using stars to manage ratings
MIT License
26 stars 5 forks source link

Be agnostic about css classes (and thus about icon libraries) #19

Open balinterdi opened 6 years ago

balinterdi commented 6 years ago

The component now applies the appropriate glyphicon classes which makes it work with Bootstrap out-of-the-box.

The setting is overridable through fullClassNames and emptyClassNames but it'd be much better to not apply any css classes by default and have the caller provide the classes.

https://github.com/balinterdi/ember-cli-star-rating/issues/10 can help with providing out-of-the-box components for Font Awesome, Glyphicon, etc.

balinterdi commented 5 years ago

A tentative API for the component would look like this:

{{#star-rating
  item=song
  rating=song.rating
  on-click=(action "updateRating" song) as |stars|}}
  {{stars.full-stars class="glyphicon glyphico-star"}}
  {{stars.empty-stars class="glyphicon glyphicon-o-star"}}
{{/star-rating}}

The full-stars and empty-stars would still render the right amount of stars from each but the API would be more flexible and elegant and wouldn't be tied to one specific icon library (even if allowing overwriting the classes)