Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
@kolking/react-native-rating
Advanced tools
An interactive rating component for React Native that can display ratings using stars, hearts, emojis, or custom symbols.
An interactive rating component for React Native, which can display ratings using stars, hearts, emojis, or custom symbols of your choice. The component leverages the PanResponder
and Animated
APIs to create high-performing animations. It is written in TypeScript and has zero dependencies. Whether you’re building a review-based app, a rating system, or any application that requires user feedback, React Native Rating will be an invaluable addition to your toolkit.
yarn add @kolking/react-native-rating
npm i @kolking/react-native-rating
import React, { useCallback, useState } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { Rating } from '@kolking/react-native-rating';
const App = () => {
const [rating, setRating] = useState(0);
const handleChange = useCallback(
(value: number) => setRating(Math.round((rating + value) * 5) / 10),
[rating],
);
return (
<View style={styles.root}>
<Rating size={40} rating={rating} onChange={handleChange} />
<Text style={styles.text}>Rated {rating} out of 5</Text>
</View>
);
};
const styles = StyleSheet.create({
root: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
text: {
fontSize: 17,
marginTop: 20,
},
});
export default App;
Prop | Type | Default | Description |
---|---|---|---|
variant | Variants | stars | Pre-defined design variant, see variants section below |
rating | number | 0 | Decimal rating value |
size | number | 30 | Width and height of the rating symbol |
scale | number | 1.3 | Scaling factor for the snap animation, set it to 1 to turn animation off |
spacing | number | size * (scale - 1) | Distance between symbols, calculated based on the scale prop if no value is provided |
maxRating | number | 5 | Maximum rating value and the total number of symbols |
disabled | boolean | false | Set true to disable user interaction |
baseColor | string | variant default | Color of the "empty" symbols |
fillColor | string | variant default | Color of the "filled" symbols |
touchColor | string | variant default | Color of the symbols during interaction |
baseSymbol | SymbolSource | variant default | An image (or array of images) for the "empty" rating |
fillSymbol | SymbolSource | variant default | An image (or array of images) for the "filled" rating |
style | ViewStyle | Style object applied to the wrapping View | |
onMove | (rating: number) => void | A function called during pan gesture | |
onChange | (rating: number) => void | A function called when touch released |
To achieve a customized appearance for the component, you have the flexibility to define your own symbols using the baseSymbol
and fillSymbol
props. The SymbolSource
type is defined as ImageSourcePropType | ImageSourcePropType[]
, allowing you to pass either a single image source or an array of images. It is important to note that when passing an array, its length must match the maxRating
value to ensure proper functionality.
There are five pre-defined design variants available for selection. All of the variants are designed to support both light and dark color schemes. In addition, you have the flexibility to override any of the variant props with your own custom values.
stars
Preview | baseSymbol | fillSymbol | baseColor | fillColor | touchColor |
---|---|---|---|---|---|
#D1D1D6 light#3A3A3C dark | #FF9500 light#FF9F0A dark | #FF3B30 light#FF453A dark |
stars-outline
Preview | baseSymbol | fillSymbol | baseColor | fillColor | touchColor |
---|---|---|---|---|---|
#C7C7CC light#48484A dark | #FF9500 light#FF9F0A dark | #FF3B30 light#FF453A dark |
hearts
Preview | baseSymbol | fillSymbol | baseColor | fillColor | touchColor |
---|---|---|---|---|---|
#D1D1D6 light#3A3A3C dark | #FF2D55 light#FF375F dark | #D70015 light#D70015 dark |
hearts-outline
Preview | baseSymbol | fillSymbol | baseColor | fillColor | touchColor |
---|---|---|---|---|---|
#C7C7CC light#48484A dark | #FF2D55 light#FF375F dark | #D70015 light#D70015 dark |
emoji
Preview | baseSymbol |
---|---|
MIT
FAQs
An interactive rating component for React Native that can display ratings using stars, hearts, emojis, or custom symbols.
The npm package @kolking/react-native-rating receives a total of 1,432 weekly downloads. As such, @kolking/react-native-rating popularity was classified as popular.
We found that @kolking/react-native-rating demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.