npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-star-rating-svg

v1.2.0

Published

A React Native component for generating and displaying interactive star ratings

Downloads

3

Readme

npm version

NPM

React Native Star Rating Component (with SVG support)

This is basically react-native-star-rating, but it looks like it's not being maintained, so I forked it and published to fit my needs (SVG support)

A React Native component for generating and displaying interactive star ratings. Compatible with both iOS and Android.

Table of Contents

Installation

  1. install react-native-star-rating and its dependeices
npm install react-native-star-rating --save

or

yarn add react-native-star-rating
  1. link react-native-vector-icons
    please refer to react-native-vector-icons installation guide

Usage

Props

| Prop | Type | Description | Required | Default | | --------------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------- | ------------- | | activeOpacity | number | Number between 0 a 1 to determine the opacity of the button. | No | 0.2 | | animation | string | Add an animation to the stars when upon selection. Refer to react-native-animatable for the different animation types. | No | undefined | | buttonStyle | ViewPropTypes.style | Style of the button containing the star. | No | {} | | containerStyle | ViewPropTypes.style | Style of the element containing the star rating component. | No | {} | | disabled | bool | Sets the interactivity of the star buttons. | No | false | | emptyStar | string or image object | The name of the icon to represent an empty star. Refer to react-native-vector-icons. Also can be a image object, both {uri:xxx.xxx} and require('xx/xx/xx.xxx'). | No | star-o | | emptyStarColor | string | Color of an empty star. | No | gray | | fullStar | string or image object | The name of the icon to represent a full star. Refer to react-native-vector-icons. Also can be a image object, both {uri:xxx.xxx} and require('xx/xx/xx.xxx'). | No | star | | fullStarColor | string | Color of a filled star. | No | black | | halfStar | string or image object | The name of the icon to represent an half star. Refer to react-native-vector-icons. Also can be a image object, both {uri:xxx.xxx} and require('xx/xx/xx.xxx'). | No | star-half-o | | halfStarColor | string | Color of a half-filled star. Defaults to fullStarColor. | No | undefined | | halfStarEnabled | bool | Sets ability to select half stars | No | false | | iconSet | string | The name of the icon set the star image belongs to. Refer to react-native-vector-icons. | No | FontAwesome | | maxStars | number | The maximum number of stars possible. | No | 5 | | rating | number | The current rating to show. | No | 0 | | reversed | bool | Renders stars from right to left | No | false | | selectedStar | function | A function to handle star button presses. | Yes | () => {} | | starSize | number | Size of the star. | No | 40 | | starStyle | ViewPropTypes.style | Style to apply to the star. | No | {} |

For the emptyStar, fullStar, halfStar, and iconSet props, please refer to the react-native-vector-icons package for the valid string names for the star icons. When selecting the icon string names, you must remember to remove the font family name before the first hyphen. For example, if you want to use the ion-ios-star from the Ionicon font set, you would set the fullStar prop to ios-star and the iconSet to Ionicons.

For the animation prop, please refer to the react-native-animatable package for valid string names for the different animations available.

General Star Example

The following example will render 3.5 stars out of 5 stars using the star-o for the empty star icon, star-half-o for the half star icon, and star for the full star icon from the FontAwesome icon set in black color.

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

class GeneralStarExample extends Component {
  constructor(props) {
    super(props);
    this.state = {
      starCount: 3.5,
    };
  }

  onStarRatingPress(rating) {
    this.setState({
      starCount: rating,
    });
  }

  render() {
    return (
      <StarRating
        disabled={false}
        maxStars={5}
        rating={this.state.starCount}
        selectedStar={(rating) => this.onStarRatingPress(rating)}
      />
    );
  }
}

export default GeneralStarExample;

Custom Star Case

The following example will render 2.5 stars out of 7 stars using the ios-star-outline for the empty star icon, ios-star-half for the half star icon, and ios-star for the full star icon from the Ionicons icon set in red color.

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

class CustomStarExample extends Component {
  constructor(props) {
    super(props);
    this.state = {
      starCount: 2.5,
    };
  }

  onStarRatingPress(rating) {
    this.setState({
      starCount: rating,
    });
  }

  render() {
    return (
      <StarRating
        disabled={false}
        emptyStar={'ios-star-outline'}
        fullStar={'ios-star'}
        halfStar={'ios-star-half'}
        iconSet={'Ionicons'}
        maxStars={7}
        rating={this.state.starCount}
        selectedStar={(rating) => this.onStarRatingPress(rating)}
        fullStarColor={'red'}
      />
    );
  }
}

export default CustomStarExample;

Running the ExampleApp (WIP)

Navigate to the root of the ExampleApp and install the dependencies

cd ExampleApp && npm install

Run the app on the iOS simulator.

npm run ios

Development Setup (WIP)

Be sure to have create-react-native-app installed.

npm install -g create-react-native-app

Create a development app in the root folder.

create-react-native-app DevelopmentApp

Going into the development app and clone this repo.

cd DevelopmentApp && git clone https://github.com/djchie/react-native-star-rating.git

Go into the react-native-star-rating directory and start developing!

cd react-native-star-rating

Roadmap

View the project roadmap here

Contributing

See CONTRIBUTING.md for contribution guidelines.