- } />
+ } />
{/* Accordion component */}
} />
- {/* Random color generator */}
+ {/* Random color generator */}
} />
{/* Star Rating */}
} />
diff --git a/src/pages/starRating.jsx b/src/pages/starRating.jsx
index 49774d8..7c4debe 100644
--- a/src/pages/starRating.jsx
+++ b/src/pages/starRating.jsx
@@ -1,9 +1,45 @@
-export default function StarRating() {
+import PropTypes from "prop-types";
+import { useState } from "react";
+import { FaStar } from "react-icons/fa"; // Correct import for FaStar
+
+function StarRating({ numOfStars = 5 }) {
+ const [rating, setRating] = useState(0);
+ const [hover, setHover] = useState(0);
+
+ function handleClick(getCurrentLIndex) {
+ setRating(getCurrentLIndex)
+ }
+ function handleMouseEnter(getCurrentLIndex) {
+ setHover(getCurrentLIndex)
+ }
+ function handleMouseLeave() {
+ setHover(rating)
+ }
+
return (
+ {[...Array(numOfStars)].map((_, index) => {
+ index += 1;
+ return (
+ handleClick(index)}
+ onMouseMove={() => handleMouseEnter(index)}
+ onMouseLeave={() => handleMouseLeave(index)}
+ size={40}
+ />
+ );
+ })}
);
}
+
+StarRating.propTypes = {
+ numOfStars: PropTypes.number,
+};
+
+export default StarRating