@dz8540/custom-rating
v1.0.0
Published
DZ's component rating library.
Downloads
5
Readme
DZ Custom-rating
To use it, you just need to find element, and then pass it to the class.
Installation
- 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>
Example
HTML
<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>
JS
let element = document.querySelector(element);
new Rating(element);
Instruction:
- 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.
End
That's all! Enjoy this (∩^o^)⊃━☆