UNPKG

react-native-modern-elements

Version:

A modern, customizable UI component library for React Native

19 lines (18 loc) 837 B
import React, { memo } from "react"; import { View, StyleSheet } from "react-native"; import { FontAwesome } from "@expo/vector-icons"; // Using FontAwesome for star icons const StarRating = ({ rating, size = 14, }) => { const maxRating = 5; const normalizedRating = Math.max(0, Math.min(rating, maxRating)); return (React.createElement(View, { style: styles.container }, [...Array(maxRating)].map((_, index) => (React.createElement(FontAwesome, { key: `star-${index}`, name: index < normalizedRating ? "star" : "star-o", size: size, color: index < normalizedRating ? "#E73C17" : "#A0A0A0", style: styles.star }))))); }; const styles = StyleSheet.create({ container: { flexDirection: "row", alignItems: "center", }, star: { marginHorizontal: 2, }, }); export default memo(StarRating);