-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRating.tsx
More file actions
57 lines (50 loc) · 1.09 KB
/
Copy pathRating.tsx
File metadata and controls
57 lines (50 loc) · 1.09 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
import React from 'react'
import MuiRating, {RatingProps} from '@mui/material/Rating'
import StarIcon from '@mui/icons-material/Star'
import styled from 'styled-components'
import Flex from './Flex'
import Text from './Text'
type Props = {
className?: string
customSize?: string
} & RatingProps
const Rating = ({
className,
name,
value,
readOnly,
customSize,
precision,
...props
}: Props) => {
if (readOnly && !value) {
return (
<Flex gap="6px">
<FilledStar />
<Text size="large" color="accent">
-
</Text>
</Flex>
)
}
return (
<StyledRating
className={className}
name={name}
precision={precision || 0.5}
value={value}
readOnly={readOnly}
icon={<FilledStar style={{fontSize: customSize}} />}
emptyIcon={<EmptyStar style={{fontSize: customSize}} />}
{...props}
/>
)
}
const FilledStar = styled(StarIcon)`
color: var(--color-accent) !important;
`
const EmptyStar = styled(StarIcon)`
color: #dbcdf8 !important;
`
const StyledRating = styled(MuiRating)``
export default Rating