djchie / react-native-star-rating

A React Native component for generating and displaying interactive star ratings
833 stars 202 forks source link

Use icon sets exported from IcoMoon #57

Open rodrigopk opened 6 years ago

rodrigopk commented 6 years ago

The react-native-vector-icons has a method createIconSetFromIcoMoon, which creates an icon sets using an IcoMoon json configuration file. I would like to propose that the StarRating and StarButton components had an optional prop to receive a IcoMoon configuration json, so that the user is able to use his own icon set if needed. Below follows an example to illustrate how we could use a prop for loading a custom icon set from a config json:

// star-button.js
import { createIconSetFromIcoMoon } from 'react-native-vector-icons';
.
.
.
  iconSetFromProps() {
    const {
      iconSet,
      icoMoonJson
    } = this.props;
    if (icoMoonJson) {
      return createIconSetFromIcoMoon(icoMoonJson);
    } else {
      return iconSets[iconSet];
    }
  }
rodrigopk commented 6 years ago

I created a PR (#58) to suggest those changes

nadirHomeFriend commented 5 years ago

any updates ?

djchie commented 5 years ago

I just merged this in, I'll be pushing out a new build soon. Thanks again @rodrigopk!

djchie commented 5 years ago

@rodrigopk @nadirHomeFriend Actually this just got me thinking. I think it might be better to give more power to the developer if I moved the responsibility of setting an Icon set outside of the component? I'm thinking of just having the iconSet prop just be an Icon set. That way, people can just use createIconSet, createIconSetFromFontello, createIconSetFromIcoMoon, or the standard sets provided by react-native-vector-icons outside of the component rather than be restricted to the props within it. Thoughts?