Star rater
npm install react-rater
import Rater from 'react-rater'
// ...
render() {
return (<Rater total={5} rating={2} />)
}
<Rater total={} rating={} limit={} onRate={} />
All attributes are optional.
total
: default 5rating
: default 0limit
: default same astotal
. Sets the maximum rating value available.onRate
:function(rating, lastRating)
. Callback to retrieve rating value.interactive
: defaulttrue
. Create a read-only rater by setting this attribute tofalse
.
Notice: onRate
is called on mousemove/mouseenter/click/mouseleave. Only for click lastRating
has a value.
$react-rater-link: #ccc !default; // color of star not rated
$react-rater-hover: #666 !default; // color of star on hover
$react-rater-active: #000 !default; // color of star rated
<Rater />
will repeat its children until counts reach total
. https://github.com/NdYAG/react-rater/blob/master/src/index.js#L69
In this way you can define your own 'star' component (remember to check out src/star.js).
<Rater total={5}>
<Heart />
</Rater>
Valentine's Day:
Abilu judge system for Douban Music:
BSD.