Git Product home page Git Product logo

material-ui-rating's Introduction

Material-UI Rating

JavaScript Style Guide Build Status

Example

Installation

Stable channel

npm install material-ui-rating@next

Usage

import Rating from 'material-ui-rating'

<Rating
  value={3}
  max={5}
  onChange={(value) => console.log(`Rated with value ${value}`)}
/>

Material Rating Properties

Name Type Default Description
classes* object Useful to extend the style applied to components. The accepted keys are listed below.
component elementType div The component used for the root node. Either a string to use a DOM element or a component.
disabled bool false Disables the rating and gray it out if set to true.
disableHover bool false Disable hover effects if set to true.
iconFilled node This is the icon to be used as an icon in value range.
iconFilledRenderer func Overrides filled icon renderer.
iconHoveredRenderer func Overrides hovered icon renderer.
iconHovered node This is the icon to be used as an hovered icon.
iconNormal node This is the icon to be used as an normal icon.
iconNormalRenderer func Overrides normal icon renderer.
max number 5 The max value of the rating bar.
onChange func Fired when a value is clicked.
readOnly bool false Don't allow input if set to true.
value number 0 The value of the rating bar.

* required property

CSS API

You can override all the class names injected by Material-UI-Rating thanks to the classes property. This property accepts the following keys:

  • root - Applied to the root div element
  • iconButton - Applied to the IconButton component
  • icon - Applied to the SvgIcon component
  • disabled - Applied to the IconButton component when disabled prop is true
  • readOnly - Applied to the IconButton component when readOnly prop is true

RTL support

Following Material-UI's conventions, this package respects theme.direction.rtl, so right-to-left support works out-of-the-box.

License

The files included in this repository are licensed under the MIT license.

material-ui-rating's People

Contributors

davejm avatar goferito avatar goldylucks avatar goodsted-dev avatar greenkeeper[bot] avatar jmcneese avatar lemaik avatar lisa-tw avatar ogbeche77 avatar oliviertassinari avatar petero-dk avatar saschb2b avatar tyanas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

material-ui-rating's Issues

whether you will add "Half ratings, sizes, and accessibility" functionality to the library?

I wanted to use your library as a customizable solution because our design expects it, and we cannot use the original package from the material ui library.
And so I created the component based on this file but with fixing type and re-work from Classic React Component to Functional Component, maybe it help to use in future, but I can't use it without the above mentioned functionality. =(
https://github.com/TeamWertarbyte/material-ui-rating/blob/master/src/components/Rating/Rating.js

Link to the library with hooks
https://drive.google.com/file/d/1jVOePLPnqDwnzofa7BCIBgOve099SNKf/view?usp=sharing

PS: I mean full support how the original component does it
https://material-ui.com/api/rating/#rating-api

Support for half-stars

This is a feature request.
Some other star rating components have ability to render rating to half-star precision, like so:
example

It would be nice to have this ability together with material-ui integration in one component.

Missing Dependency: classnames

material-ui-rating depends on the classnames package but it's not listed as a dependency in package.json. Unless I'm missing something it should be added.

react warning: nativeColor prop

hey guys great job with the package!

I'm using react 16.8.6 and I'm getting a warning (attached console screenshot). I'm PRing a fix, let me know if it's ok :)

image

PR - pass component as props

following the MUI conventions, I'd like to pass <Rating component="span" />

I have a use case in which <Rating /> is nested within a <p /> element, and I get a dom violation.

Shall I prepare a PR?

I can also add an example in Rating.md, and for story book I'd love some guidance since I've never done that before.

Warning: React does not recognize the `iconHovered` prop on a DOM element

See image below.

# cat client/node_modules/material-ui-rating/package.json | grep version      
"version": "4.1.0",
Here's my Rating component, there's no `iconHovered` in there
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import MuiRating from 'material-ui-rating'
import { withStyles } from '@material-ui/core'

class Rating extends Component {
  static propTypes = {
    classes: PropTypes.object.isRequired,
    value: PropTypes.number.isRequired,
    muiRatingClasses: PropTypes.object,
    readOnly: PropTypes.bool,
  }

  static defaultProps = {
    muiRatingClasses: {},
    readOnly: true,
  }

  render() {
    const {
      classes,
      value,
      muiRatingClasses,
      readOnly,
      ...restOfProps
    } = this.props
    return (
      <MuiRating
        classes={{
          root: classes.starsRoot,
          icon: classes.star,
          iconButton: classes.starButton,
          ...muiRatingClasses,
        }}
        value={value}
        readOnly
        {...restOfProps}
      />
    )
  }
}

const HEIGHT = 20

const styles = () => ({
  starsRoot: {
    display: 'flex',
    alignItems: 'center',
    height: HEIGHT,
  },
  starButton: {
    padding: 0,
    margin: 0,
    transform: 'scaleX(-1)',
    '& > span': {
      height: HEIGHT,
    },
  },
  star: {
    height: HEIGHT,
    width: 16,
  },
})

export default withStyles(styles)(Rating)

can you look into it? thanks!

image

Starts are still buttons in readOnly

Then, if the style is changed to have the stars smaller and closer to each other (because they don't need to be clicked, and look better in the design), google's test will consider that those button elements are too close, and the page is not mobile friendly.

disable hover effect

It would be great to be able to disable the hover effect. Is there a way to achieve this now? If not, I'd be happy to create a pull request.

PR - rtl support

I actually do this already in my project by setting transform: 'translateX(180deg)'. I can PR here it here as well :)

Build don't have index.d.ts

After add file of type index.d.ts, the file all the same don't send in package. I think problem in system build.
Maybe can you use tsdx with great support typescript?

PR - prettier / eslint

while working on #28 accidentally formatted many of the files automatically through prettier. I see there's no prettier nor eslint in the project. I can add it with the config of your choice, i.e. semistandard.

I think it will make it easier to maintain/extend.

Thoughts?

Errors with Material UI V 1.4.3

I have the problem ./node_modules/material-ui-rating/lib/components/Rating/Rating.js Module not found: Can't resolve 'material-ui/IconButton' in I changed some lines on Rating.js (updated material-ui calls to @material-ui/core/) and then a new error comes:
TypeError: Cannot read property 'orange500' of undefined

I'm using material-ui-rating V 2.0.0

onChange() never triggered

I'm using this with webpack and material-ui and the component shows up, the max and value properties work as expected, but the onChange function is never triggered. I have tried on Firefox and Chrome for Ubuntu.

Half star rating icon off center

I added a rating in my react project with precision set to 0.5. "averageRating" is a state that is evaluated on render. Image shows how the star is a bit off. Did I do anything wrong or is this a bug?

image

<Rating precision={0.5} name="averageRating" value={averageRating} />

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.