recipe author and stars and a bit of cleanup
This commit is contained in:
parent
c47dac9986
commit
6f43d17ddd
21 changed files with 361 additions and 207 deletions
26
frontend/src/components/StarRating.tsx
Normal file
26
frontend/src/components/StarRating.tsx
Normal file
|
@ -0,0 +1,26 @@
|
|||
interface StarRatingProps {
|
||||
rating: number;
|
||||
onRatingChange: (newRating: number) => void;
|
||||
}
|
||||
|
||||
const StarRating = ({ rating, onRatingChange }: StarRatingProps) => {
|
||||
|
||||
return (
|
||||
<div>
|
||||
{[...Array(5)].map((star, index) => {
|
||||
index += 1;
|
||||
return (
|
||||
<span
|
||||
key={index}
|
||||
onClick={() => onRatingChange(index)}
|
||||
style={{ color: index <= rating ? 'gold' : 'gray', fontSize: '2rem', cursor: 'pointer' }}
|
||||
>
|
||||
★
|
||||
</span>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default StarRating;
|
Loading…
Add table
Add a link
Reference in a new issue