Files
CHIEFSOFT\ameye 5f95d857d4 first commit
2023-10-14 22:02:57 -04:00

83 lines
1.8 KiB
JavaScript

import React from "react";
import Card from "@mui/material/Card";
import { Typography } from "@mui/material";
import Rating from '@mui/material/Rating';
import Box from '@mui/material/Box';
import StarIcon from '@mui/icons-material/Star';
const labels = {
0.5: 'Useless',
1: 'Useless+',
1.5: 'Poor',
2: 'Poor+',
2.5: 'Ok',
3: 'Ok+',
3.5: 'Good',
4: 'Good+',
4.5: 'Excellent',
5: 'Excellent+',
};
function getLabelText(value) {
return `${value} Star${value !== 1 ? 's' : ''}, ${labels[value]}`;
}
export default function HoverFeedback() {
const [value, setValue] = React.useState(2);
const [hover, setHover] = React.useState(-1);
return (
<>
<Card
sx={{
boxShadow: "none",
borderRadius: "10px",
p: "25px",
mb: "15px",
}}
>
<Typography
as="h3"
sx={{
fontSize: 18,
fontWeight: 500,
mb: '10px'
}}
>
Hover Feedback
</Typography>
<Box
sx={{
width: 200,
display: 'flex',
alignItems: 'center',
}}
>
<Rating
name="hover-feedback"
value={value}
precision={0.5}
getLabelText={getLabelText}
onChange={(event, newValue) => {
setValue(newValue);
}}
onChangeActive={(event, newHover) => {
setHover(newHover);
}}
emptyIcon={<StarIcon style={{ opacity: 0.55 }} fontSize="inherit" />}
/>
{value !== null && (
<Box
className="ml-2"
>
{labels[hover !== -1 ? hover : value]}
</Box>
)}
</Box>
</Card>
</>
);
}