To use it, you just need to find element, and then pass it to the class.
- Via npm
npm i @dz8540/custom-rating
- Manually - all you need is in the "Dist" folder.
<link href="/Your-path/customRating.min.css" rel="stylesheet">
<script src="/Your-path/CustomRating.min.js"></script>
<div class="Rating" data-name="Component name">
<input type="hidden" name="" data-id="input" value="">
<button class="Rating__star" data-value="5">
<span class="Rating__icon Rating__icon--default">☆</span>
<span class="Rating__icon Rating__icon--active">★</span>
</button>
<button class="Rating__star" data-value="4">
<span class="Rating__icon Rating__icon--default">☆</span>
<span class="Rating__icon Rating__icon--active">★</span>
</button>
<button class="Rating__star" data-value="3">
<span class="Rating__icon Rating__icon--default">☆</span>
<span class="Rating__icon Rating__icon--active">★</span>
</button>
<button class="Rating__star" data-value="2">
<span class="Rating__icon Rating__icon--default">☆</span>
<span class="Rating__icon Rating__icon--active">★</span>
</button>
<button class="Rating__star" data-value="1">
<span class="Rating__icon Rating__icon--default">☆</span>
<span class="Rating__icon Rating__icon--active">★</span>
</button>
</div>
let element = document.querySelector(element);
new Rating(element);
- Don't remove all default classes.
- Don't remove all default datalist attributes.
- Pass your values to 'data-value' attributes from button tag.
- Values must be assigned from bottom to top in ascending order.
- Component maintains 'data-name' attribute, for you can set component name.
That's all! Enjoy this (∩^o^)⊃━☆