All Projects → ekeric13 → react-star-ratings

ekeric13 / react-star-ratings

Licence: BSD-3-Clause License
A customizable svg star rating component for selecting x stars or visualizing x stars

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects
Makefile
30231 projects

Projects that are alternatives of or similar to react-star-ratings

react-ratings-declarative
A customizable rating component for selecting x widgets or visualizing x widgets
Stars: ✭ 41 (-67.97%)
Mutual labels:  input, rating, react-component, svg-icons, star-rating
rater-js
Star rating widget for the browser. Unlimited number of stars. No dependencies. No Jquery required.
Stars: ✭ 66 (-48.44%)
Mutual labels:  rating, star, star-rating-component, star-rating
react-native-rating-element
A simple rating library for react native supporting: decimal points, direction aware icons, custom icon set from Ionicons, custom images and record rating given by users.
Stars: ✭ 19 (-85.16%)
Mutual labels:  ratings, rating, star-rating-component, star-rating
Raty
🌟 Raty - A Star Rating Plugin
Stars: ✭ 2,292 (+1690.63%)
Mutual labels:  rating, star, star-rating
goodreads-toolbox
9 tools for Goodreads.com, for finding people based on the books they’ve read, finding books popular among the people you follow, following new book reviews, etc
Stars: ✭ 56 (-56.25%)
Mutual labels:  ratings, rating
React Intl Tel Input
Rewrite International Telephone Input in React.js. (Looking for maintainers, and PRs & contributors are also welcomed!)
Stars: ✭ 212 (+65.63%)
Mutual labels:  input, react-component
GoAIRatings
Estimate Go AI ratings by real games
Stars: ✭ 118 (-7.81%)
Mutual labels:  ratings, rating
React Telephone Input
React component for entering and validating international telephone numbers
Stars: ✭ 254 (+98.44%)
Mutual labels:  input, react-component
react-svg-icon-generator
Generate React Icon Component from SVG icons to show, resize and recolor them.
Stars: ✭ 65 (-49.22%)
Mutual labels:  react-component, svg-icons
insect
🛠 Highly customisable, minimalistic input x select field for React.
Stars: ✭ 33 (-74.22%)
Mutual labels:  input, react-component
react-crud-icons
57 SVG icons for CRUD applications, packaged as a React component with light & dark themes and tooltip.
Stars: ✭ 19 (-85.16%)
Mutual labels:  react-component, svg-icons
React Code Input
React component for entering and validating PIN code.
Stars: ✭ 207 (+61.72%)
Mutual labels:  input, react-component
React Currency Input Field
React component for an input field
Stars: ✭ 111 (-13.28%)
Mutual labels:  input, react-component
Tagify
🔖 lightweight, efficient Tags input component in Vanilla JS / React / Angular / Vue
Stars: ✭ 2,305 (+1700.78%)
Mutual labels:  input, react-component
average-rating
Calculate average score and rating based on Wilson Score Equation
Stars: ✭ 28 (-78.12%)
Mutual labels:  rating, rating-stars
react-simple-range
🔉 React slider component for inputting a numeric value within a range.
Stars: ✭ 20 (-84.37%)
Mutual labels:  input, react-component
Rateit.js
Rating plugin for jQuery. Fast, Progressive enhancement, touch support, icon-font support, highly customizable, unobtrusive JavaScript (using HTML5 data-* attributes), RTL support, supports as many stars as you'd like, and also any step size.
Stars: ✭ 146 (+14.06%)
Mutual labels:  rating, star
mighty-input
Text input for modern web
Stars: ✭ 20 (-84.37%)
Mutual labels:  input, react-component
vue-star-rating
⭐ A simple star rating component for vue apps
Stars: ✭ 30 (-76.56%)
Mutual labels:  star-rating-component, star-rating
rating
Rating stars component
Stars: ✭ 28 (-78.12%)
Mutual labels:  ratings, rating

React Star Ratings

Customizable react star ratings. SVG stars that show aggregate star ratings to the hundreths decimal point.

Install

npm install --save react-star-ratings

Heads up

I made a better version (in my opinion at least) of this repo right here: react-ratings-declarative

It is a lot more extendable and customizable.

Demo

codepen playground of similar project

Demo Example Image

Usage

import StarRatings from './react-star-ratings';

class Foo extends Component {
    changeRating( newRating, name ) {
      this.setState({
        rating: newRating
      });
    }

    render() {
      // rating = 2;
      return (
        <StarRatings
          rating={this.state.rating}
          starRatedColor="blue"
          changeRating={this.changeRating}
          numberOfStars={6}
          name='rating'
        />
      );
    }
}


class Bar extends Component {
  render() {
    // aggregateRating = 2.35;
    return (
      <StarRatings
        rating={2.403}
        starDimension="40px"
        starSpacing="15px"
      />
    );
  }
}

API v2

Prop Type Default Description Example
rating number 0 The user's rating. Number of stars to highlight. 3
numberOfStars number 5 The max number of stars to choose from or to display 6
changeRating function ()=>{} Callback that will be passed the new rating a user selects const setNewRating = (rating) => this.props.dispatch( fooActions.setRating(rating) )
starRatedColor string 'rgb(109, 122, 130)' Color of stars that the user has rated black
starEmptyColor string 'rgb(203, 211, 227)' Color of stars that the use hasn't rated grey
starHoverColor string 'rgb(230, 67, 47)' Color of star when hovering over it in selection mode yellow
starDimension string '50px' The width and height of the star 15px
starSpacing string '7px' The spacing between the stars 0
gradientPathName string '' gradientPathname needed if app's path is not at the root /app/
ignoreInlineStyles boolean false ignore all the inline styles and write your own css using the provided classes true
svgIconPath string 'm25,1 6,17h18l-14,11 5,17-15-10-15,10 5-17-14-11h18z' Set a path that describes the svg shape 'm25,1 6,17h18l-14,11 5,17-15-10-15,10 5-17-14-11h18z'
svgIconViewBox string '0 0 51 48' Set the view box for a custom svg path you might have '0 0 51 48'
name string '' Component's unique identification. Can be used when more than one star rating components are used 'rating'

API v1

Prop Type Default Description Example
rating number 0 The user's rating. Number of stars to highlight. 3
numOfStars number 5 The max number of stars to choose from or to display 6
changeRating function ()=>{} Callback that will be passed the new rating a user selects const setNewRating = (rating) => this.props.dispatch( fooActions.setRating(rating) )
isSelectable boolean false Determines whether user can select a new rating or whether the stars are just for display true
isAggregateRating boolean true Determines whether stars' will show a fraction of a star (.5 stars) false
starSelectingHoverColor string 'rgb(230, 67, 47)' Color of star when hovering over it in selection mode yellow
starRatedColor string 'rgb(109, 122, 130)' Color of stars that the user has rated black
starEmptyColor string 'rgb(203, 211, 227)' Color of stars that the use hasn't rated grey
starWidthAndHeight string '50px' The width and height of the star 15px
starSpacing string '7px' The spacing between the stars 0
gradientPathName string '' gradientPathname needed if app's path is not at the root /app/
ignoreInlineStyles boolean false ignore all the inline styles and write your own css using the provided classes true
svgIconPath string 'm25,1 6,17h18l-14,11 5,17-15-10-15,10 5-17-14-11h18z' Set a path that describes the svg shape 'm25,1 6,17h18l-14,11 5,17-15-10-15,10 5-17-14-11h18z'
svgIconViewBox string '0 0 51 48' Set the view box for a custom svg path you might have '0 0 51 48'

Browser Support

Supports Chrome, firefox, safari, edge, and ie 9+. The star is SVG, so this library fails for any browser that doesn't support svg.

Potential Gradient Path Name Issue

I use the css property fill: 'url(#starGrad<randomNum>)'; to fill in just a percentage of a star. It has some weird bugs depending on the pathname of the app. Normally SPA's have window.location.pathname === '/', but if you append window.location.origin with the pathname of say app, so that window.location.pathname === '/app/', then you need a gradientPathName of '/app/'.

Here is a stackoverflow post that I found that was related to this issue: http://stackoverflow.com/questions/36774188/svg-internal-url-links-and-iframes-on-wirecloud

Try Example And Contribute

To try out the example in this repo: First clone this repo. And then using a complicated build set up stolen from TJ you run make start and go to port 5000. I actually used a forked version of that with slight changes that makes it easier to build multiple files. The only change I made pertains to how the babel cli is used

If you want to contribute: Make changes in the src folder. And then run make build. And of course test by running make start. The make build command compiles react and es6 stuff using babel from src/ into build/. (make start currently broken. instead cd in test folder and run npm run start)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].