forked from vaibhavsharma420/HacktoberFest2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStarRating
More file actions
66 lines (53 loc) · 1.45 KB
/
Copy pathStarRating
File metadata and controls
66 lines (53 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import React from 'react'
import {AiOutlineStar, AiFillStar} from "react-icons/ai";
import {BsStarHalf} from 'react-icons/bs';
import { TbNumbers } from 'react-icons/tb';
import styled from 'styled-components';
const Star = ({stars, reviews}) => {
//<AiFillStar/> <AiOutlineStar/> <BsStarHalf/>
const ratingStar= Array.from({length:5},(elem, index)=>{
let number= index+0.5;
return(
<>
<span key={index}>
{stars>= index+1
? <AiFillStar className='icon'/>
: stars>= number
? <BsStarHalf className='icon'/>
:<AiOutlineStar className='icon'/>
}
</span>
</>
)
})
return(
<>
<Wrapper>
<div className='icon-style'>
{ratingStar}
<p>({reviews} customer reviews)</p>
</div>
</Wrapper>
</>
);
}
const Wrapper= styled.section`
.icon-style {
display: flex;
gap: 0.2rem;
align-items: center;
justify-content: flex-start;
.icon {
font-size: 2rem;
color: orange;
}
.empty-icon {
font-size: 2.6rem;
}
p {
margin: 0;
padding-left: 1.2rem;
}
}
`;
export default Star;