Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
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