All Projects → NdYAG → React Rater

NdYAG / React Rater

Licence: bsd-3-clause
⭐️ Interative & customizable star rater

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Rater

Ion Phaser
A web component to use Phaser Framework with Angular, React, Vue, etc 🎮
Stars: ✭ 152 (-15.56%)
Mutual labels:  react-component
Reactopt
A CLI React performance optimization tool that identifies potential unnecessary re-rendering
Stars: ✭ 1,975 (+997.22%)
Mutual labels:  react-component
Video React
A web video player built for the HTML5 world using React library.
Stars: ✭ 2,227 (+1137.22%)
Mutual labels:  react-component
React Useragent
Integrate user-agent detection in an idiomatic React way
Stars: ✭ 154 (-14.44%)
Mutual labels:  react-component
React Tiny Virtual List
A tiny but mighty 3kb list virtualization library, with zero dependencies 💪 Supports variable heights/widths, sticky items, scrolling to index, and more!
Stars: ✭ 2,057 (+1042.78%)
Mutual labels:  react-component
React Tradingview Widget
React component for rendering the TradingView Advanced Real-Time Chart Widget.
Stars: ✭ 170 (-5.56%)
Mutual labels:  react-component
React Items Carousel
Items Carousel Built with react-motion and styled-components
Stars: ✭ 150 (-16.67%)
Mutual labels:  react-component
React Credit Cards
Beautiful credit cards for your payment forms
Stars: ✭ 2,239 (+1143.89%)
Mutual labels:  react-component
Miniprogram
猫眼电影/Taro/微信小程序/React
Stars: ✭ 163 (-9.44%)
Mutual labels:  react-component
React Component Echarts
React component echarts. 组件式百度图表。
Stars: ✭ 175 (-2.78%)
Mutual labels:  react-component
React Touch Carousel
Ultra-customizable carousel framework for React.JS
Stars: ✭ 158 (-12.22%)
Mutual labels:  react-component
React Paginate
A ReactJS component that creates a pagination
Stars: ✭ 2,169 (+1105%)
Mutual labels:  react-component
Cassette
📼 A flexible media player component library for React that requires no up-front config
Stars: ✭ 171 (-5%)
Mutual labels:  react-component
React Ds
🔥 React Drag To Select component (tiny, touch friendly, and no dependencies!)
Stars: ✭ 153 (-15%)
Mutual labels:  react-component
React Awesome Slider
React content transition slider. Awesome Slider is a 60fps, light weight, performant component that renders an animated set of production ready UI general purpose sliders with fullpage transition support for NextJS and GatsbyJS. 🖥️ 📱
Stars: ✭ 2,343 (+1201.67%)
Mutual labels:  react-component
React Layer Stack
Layering system for React. Useful for popover/modals/tooltip/dnd application
Stars: ✭ 152 (-15.56%)
Mutual labels:  react-component
React Terminal Component
Terminal emulator component for React. Emulate a terminal/console with autocomplete, commands, a file-system and themes.
Stars: ✭ 169 (-6.11%)
Mutual labels:  react-component
React Sticky El
Stars: ✭ 179 (-0.56%)
Mutual labels:  react-component
React Translated
A dead simple way to add complex translations (i18n) in a React (DOM/Native) project 🌎🌍🌏
Stars: ✭ 176 (-2.22%)
Mutual labels:  react-component
Animate Css Styled Components
simple port of animate css for styled-components
Stars: ✭ 173 (-3.89%)
Mutual labels:  react-component

React-rater

Star rater Build Status

rating

Check out our new demo!

Install

npm install react-rater
import Rater from 'react-rater'
import 'react-rater/lib/react-rater.css'

// ...
render() {
  return (<Rater total={5} rating={2} />)
}

API

<Rater total={} rating={} interactive={} onRate={} onRating={} />

All attributes are optional.

  • total: Number, default 5
  • rating: Number, default 0
  • interactive: Boolean, default true. Create a read-only rater by setting this attribute to false.
  • onRate: function({ rating }). Callback to retrieve rating value. Called after rated.
  • onRating: function({ rating }). Callback to retrieve rating value. Called during rating (mouse moving between stars).
  • onCancelRate: function({ rating }). Called when mouse moves out from rater.

From version 5.0.0, callback is split into onRate & onRating & onCancelRate. onRate is called when mouse click, while onRating is called when mouse moves between star components and onCancelRate is called when mouse leaves rater. Usually you only need onRate.

Read-only mode

Set interactive={false} to create a read-only rater.

In read-only mode, rating could contain a fractional part like 3.6. (Thanks to @devmtnaing)

Callback

onRate & onRating

(rating is passed with the React's SyntheticEvent)

{
  rating: Number
  ...syntheticEvent
}

Styling

The CSS way

$react-rater-link: #ccc !default; // color of star not rated
$react-rater-hover: #666 !default; // color of star on hover
$react-rater-active: #000 !default; // color of star rated

The JS way

<Rater /> will repeat its children until counts reach total. https://github.com/NdYAG/react-rater/blob/master/src/index.js#L69

In this way you can define your own 'star' component (src/star.js).

<Rater total={5}>
  <Heart />
</Rater>

and style it based on these props:

{
  isActive: PropTypes.bool,
  isActiveHalf: PropTypes.bool,
  willBeActive: PropTypes.bool,
  isDisabled: PropTypes.bool
}

Real world example

Valentine's Day:

valentine

Abilu judge system for Douban Music:

Abilu judge system for Douban Muisc

License

BSD.

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].