1.0.1 • Published 6 years ago

material-ui-icon-ratings v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

material-ui-icon-ratings

A simple solution to displaying and selecting ratings

NPM JavaScript Style Guide

Install

npm install --save material-ui-icon-ratings

Usage

import React, { Component } from 'react'
import Rating from 'material-ui-icon-ratings'

export default class App extends Component {
  constructor(props){
    super(props);
    this.state = {
      rating: 0
    }
    this.handleChange = this.handleChange.bind(this);
  }
  handleChange(rating){
    this.setState({
      rating
    })
  }
  render () {
    return (
      <div>
        <Rating 
          onChange={this.handleChange}
          iconStyles={{color: 'red', width: '100%'}}
          toolTipText={(rating) => { return `You have selected ${rating}`}}
          />
      </div>
    )
  }
}

Properties

NameTypeDefaultDescription
readOnlyBooleanfalseUsed for display purposes only
maxNumber5Number of icons to display
iconStylesobject{color: '#E5C100', width: '100%'}Styles Applied to the icon element
initialValueNumber0The rating initialy displayed
enableToolTipBooleantrueWhether to show a tooltip when the selection is made
toolTipTextString or Function(rating) => { return `Selected Rating: ${rating}`Either a string or a function. If its a funciton, function receives rating param
iconFullReact.Node\The icon used for the full star
iconEmptyReact.Node\The icon used for the empty star
iconHalfFullReact.Node\The icon use for half star. Half star only appears if the initialValue is a decimal. Selecting half is not supported. Any decimal from between numbers will display as a half star.

Events

NameReturn ParamsDescription
onChangeratingFired when a selection is made. Returns selected rating

Contributing

Please submit submit bug in the Issues tab and pull requests would be very welcome.

License

MIT © jackpilowsky