Repository URL to install this package:
|
Version:
0.9.5 ▾
|
import React from 'react'
import { Star } from './Star'
import { StarListProps } from './typings'
class StarList extends React.PureComponent<StarListProps> {
static defaultProps = {
value: 0,
isNumberPrefix: false,
isNumberSuffix: false,
}
/**
* @todo split up
*/
render() {
const { value } = this.props
// fill an empty array, map it
const stars = new Array(5)
// go through our total (5), fill it
let addingNumber = 5
for (let index = 0; index < 5; index++) {
// was value >= index ? value : index but that would be 0,1,2,3,4,5
// if value > index, it's not empty
const percent = value >= index ? value : 0
const star = Star.from(percent, this.props, addingNumber)
addingNumber -= 1
stars.push(star)
}
/**
* @note logic was backwards
* .reverse()
*/
return stars
}
}
export { StarList }
export default StarList