{"id":13403689,"url":"https://github.com/ekeric13/react-star-ratings","last_synced_at":"2025-04-05T02:08:48.912Z","repository":{"id":19527316,"uuid":"87256291","full_name":"ekeric13/react-star-ratings","owner":"ekeric13","description":"A customizable svg star rating component for selecting x stars or visualizing x stars","archived":false,"fork":false,"pushed_at":"2023-04-14T21:21:22.000Z","size":683,"stargazers_count":149,"open_issues_count":43,"forks_count":43,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-14T06:20:51.554Z","etag":null,"topics":["component","input","rating","rating-stars","ratings","react","react-component","react-star-rating-component","star","star-rating","star-rating-component","svg","svg-icons"],"latest_commit_sha":null,"homepage":"https://codepen.io/ekeric13/project/full/DkJYpA/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ekeric13.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-04-05T02:21:41.000Z","updated_at":"2024-03-09T00:24:14.000Z","dependencies_parsed_at":"2023-01-13T20:25:52.309Z","dependency_job_id":"23c6c4ad-03a1-404f-b10e-562c420a3dcc","html_url":"https://github.com/ekeric13/react-star-ratings","commit_stats":{"total_commits":46,"total_committers":2,"mean_commits":23.0,"dds":0.06521739130434778,"last_synced_commit":"07add0e61bf77fb94a9613587e31bffa9f46364e"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekeric13%2Freact-star-ratings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekeric13%2Freact-star-ratings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekeric13%2Freact-star-ratings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekeric13%2Freact-star-ratings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ekeric13","download_url":"https://codeload.github.com/ekeric13/react-star-ratings/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276164,"owners_count":20912288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["component","input","rating","rating-stars","ratings","react","react-component","react-star-rating-component","star","star-rating","star-rating-component","svg","svg-icons"],"created_at":"2024-07-30T19:01:33.331Z","updated_at":"2025-04-05T02:08:48.891Z","avatar_url":"https://github.com/ekeric13.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# React Star Ratings\n\n\u003e Customizable react star ratings. SVG stars that show aggregate star ratings to the hundreths decimal point.\n\n## [Install](https://www.npmjs.com/package/react-star-ratings)\n\n```shell\nnpm install --save react-star-ratings\n```\n\n## Heads up\n\nI made a better version (in my opinion at least) of this repo right here: [react-ratings-declarative](https://github.com/ekeric13/react-ratings-declarative)\n\nIt is a lot more extendable and customizable.\n\n## Demo\n\n### [codepen playground of similar project](https://codepen.io/ekeric13/project/full/DkJYpA/)\n\n\n### Demo Example Image\n\n![](http://i.imgur.com/a8eWxhd.png)\n\n## Usage\n\n```js\nimport StarRatings from './react-star-ratings';\n\nclass Foo extends Component {\n    changeRating( newRating, name ) {\n      this.setState({\n        rating: newRating\n      });\n    }\n\n    render() {\n      // rating = 2;\n      return (\n        \u003cStarRatings\n          rating={this.state.rating}\n          starRatedColor=\"blue\"\n          changeRating={this.changeRating}\n          numberOfStars={6}\n          name='rating'\n        /\u003e\n      );\n    }\n}\n\n\nclass Bar extends Component {\n  render() {\n    // aggregateRating = 2.35;\n    return (\n      \u003cStarRatings\n        rating={2.403}\n        starDimension=\"40px\"\n        starSpacing=\"15px\"\n      /\u003e\n    );\n  }\n}\n```\n\n## API v2\n\n| Prop | Type | Default | Description | Example |\n| ---- | ---- | ------- | ----------- | ------- |\n| rating | number | 0 | The user's rating. Number of stars to highlight. | `3` |\n| numberOfStars | number | 5 | The max number of stars to choose from or to display | `6` |\n| changeRating | function | ()=\u003e{} | Callback that will be passed the new rating a user selects | `const setNewRating = (rating) =\u003e this.props.dispatch( fooActions.setRating(rating) )` |\n| starRatedColor | string | 'rgb(109, 122, 130)' | Color of stars that the user has rated | `black` |\n| starEmptyColor | string | 'rgb(203, 211, 227)' | Color of stars that the use hasn't rated | `grey` |\n| starHoverColor | string | 'rgb(230, 67, 47)' | Color of star when hovering over it in selection mode | `yellow` |\n| starDimension | string | '50px' | The width and height of the star | `15px` |\n| starSpacing | string | '7px' | The spacing between the stars | `0` |\n| gradientPathName | string | '' | gradientPathname needed if app's path is not at the root | `/app/` |\n| ignoreInlineStyles | boolean | false | ignore all the inline styles and write your own css using the provided classes | `true` | \n| 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' |\n| svgIconViewBox | string | '0 0 51 48' | Set the view box for a custom svg path you might have | '0 0 51 48' |\n| name | string | '' | Component's unique identification. Can be used when more than one star rating components are used | 'rating' |\n\n## API v1\n\n| Prop | Type | Default | Description | Example |\n| ---- | ---- | ------- | ----------- | ------- |\n| rating | number | 0 | The user's rating. Number of stars to highlight. | `3` |\n| numOfStars | number | 5 | The max number of stars to choose from or to display | `6` |\n| changeRating | function | ()=\u003e{} | Callback that will be passed the new rating a user selects | `const setNewRating = (rating) =\u003e this.props.dispatch( fooActions.setRating(rating) )` |\n| isSelectable | boolean | false | Determines whether user can select a new rating or whether the stars are just for display | `true` |\n| isAggregateRating | boolean | true | Determines whether stars' will show a fraction of a star (.5 stars) | `false` |\n| starSelectingHoverColor | string | 'rgb(230, 67, 47)' | Color of star when hovering over it in selection mode | `yellow` |\n| starRatedColor | string | 'rgb(109, 122, 130)' | Color of stars that the user has rated | `black` |\n| starEmptyColor | string | 'rgb(203, 211, 227)' | Color of stars that the use hasn't rated | `grey` |\n| starWidthAndHeight | string | '50px' | The width and height of the star | `15px` |\n| starSpacing | string | '7px' | The spacing between the stars | `0` |\n| gradientPathName | string | '' | gradientPathname needed if app's path is not at the root | `/app/` |\n| ignoreInlineStyles | boolean | false | ignore all the inline styles and write your own css using the provided classes | `true` | \n| 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' |\n| svgIconViewBox | string | '0 0 51 48' | Set the view box for a custom svg path you might have | '0 0 51 48' |\n\n\n## Browser Support\n\nSupports Chrome, firefox, safari, edge, and ie 9+.\nThe star is SVG, so this library fails for any browser that doesn't support svg.\n\n\n### Potential Gradient Path Name Issue\n\nI use the css property `fill: 'url(#starGrad\u003crandomNum\u003e)';` 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/'`.\n\nHere 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\n\n## Try Example And Contribute\n\nTo try out the example in this repo: First clone this repo. And then using [a complicated build set up stolen from TJ](https://github.com/tj/react-fatigue-dev) 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.](https://github.com/ekeric13/react-fatigue-dev) The only change I made pertains to how the [babel cli](http://babeljs.io/docs/usage/cli/) is used\n\nIf you want to contribute: Make changes in the src folder. And then run `make build`. And of course test by running `make start`. \nThe `make build` command compiles react and es6 stuff using babel from `src/` into `build/`.\n(`make start` currently broken. instead cd in test folder and run `npm run start`)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fekeric13%2Freact-star-ratings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fekeric13%2Freact-star-ratings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fekeric13%2Freact-star-ratings/lists"}