Giter Site home page Giter Site logo

ge3kusa / react-star-rating Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ninjasort/react-star-rating

0.0 2.0 0.0 648 KB

A simple star rating component built with React.

Home Page: http://cameronjroe.com/react-star-rating/

License: MIT License

CSS 0.88% JavaScript 98.95% HTML 0.17%

react-star-rating's Introduction

react-star-rating forthebadge

A simple star rating component built with React.

Install

$ npm install react-star-rating --save

Usage

ES6

import React from 'react';
import StarRating from 'react-star-rating';

class FormComponent extends React.Component {
  render() {
    return (
      <form action="/api" method="POST">
        <StarRating name="airbnb-rating" caption="Rate your stay!" ratingAmount={5} />
        <button type="submit" className="btn btn-submit">Submit Rating</button>
      </form>
    );
  }
}

React.render(<FormComponent />, document.getElementById('star-rating'));

ES5

var React = require('react');
var StarRating = require('react-star-rating');

var FormComponent = React.createClass({
    render: function () {
      return (
        <form action="/api" method="POST">
          <StarRating name="airbnb-rating" caption="Rate your stay!" ratingAmount={5} />
          <button type="submit" className="btn btn-submit">Submit Rating</button>
        </form>
      );
    }
});

React.render(<FormComponent />, document.getElementById('star-rating'));

Options

  • name={string} - name for form input (required)
  • caption={string} - caption for rating (optional)
  • ratingAmount={number} - rating amount (required, default: 5)
  • rating={number} - a set rating between the rating amount (optional)
  • disabled={boolean} - whether to disable the rating from being selected (optional)
  • editing={boolean} - whether the rating is explicitly in editing mode (optional)
  • size={string} - size of stars (optional)
  • onRatingClick={function} - a handler function that gets called onClick of the rating (optional) - gets passed (event, {position, rating, caption, name})

Todo

  • Fix ES6 bug with bundling
  • Add svg stars
  • Re-implement star hovering (kinda janky right now)
  • Double-check touch support works

License

MIT

react-star-rating's People

Watchers

 avatar  avatar

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.