Skip to content

Commit c20670c

Browse files
committed
Change progress antd to MUI
1 parent 859cd15 commit c20670c

File tree

3 files changed

+70
-30
lines changed

3 files changed

+70
-30
lines changed

src/components/Metrics/MetricsOverview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const MetricsOverview = ({ stats }) => {
4444
) : (
4545
t("metrics:empytOverview")
4646
)}
47-
<ReviewStats stats={stats} countInTitle={true} type="line" />
47+
<ReviewStats stats={stats} countInTitle={true} />
4848
</Col>
4949
</Row>
5050
);

src/components/Metrics/ReviewProgress.tsx

Lines changed: 68 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
11
import React from "react";
2-
import { Progress, ProgressProps } from "antd";
2+
import {
3+
Grid,
4+
LinearProgress,
5+
CircularProgress,
6+
linearProgressClasses,
7+
circularProgressClasses
8+
} from "@mui/material";
9+
import styled from "styled-components";
310
import ReviewColors from "../../constants/reviewColors";
411
import colors from "../../styles/colors";
5-
import StatsReviewColors from "../../constants/statsReviewColors";
612
import { useTranslation } from "next-i18next";
713

814
const ReviewProgress = ({ reviews, statsProps }) => {
915
const { t } = useTranslation();
16+
17+
return reviews.map((review) => {
18+
const BorderLinearProgress = styled(LinearProgress)(() => ({
19+
[`& .${linearProgressClasses.bar}`]: {
20+
borderRadius: 10,
21+
backgroundColor: ReviewColors[review._id] || colors.black,
22+
},
23+
}));
1024

11-
const getStyle = (reviewId) => {
12-
const defaultStyle: ProgressProps = {
13-
strokeWidth: statsProps.strokeWidth || 18,
14-
width: statsProps.width || 80,
15-
strokeLinecap: statsProps.type === "circle" ? "square" : "round",
16-
trailColor: colors.neutralTertiary,
17-
};
18-
19-
return {
20-
...defaultStyle,
21-
strokeColor: StatsReviewColors[reviewId] || colors.black,
22-
};
23-
};
25+
const BorderCircularProgress = styled(CircularProgress)(() => ({
26+
[`& .${circularProgressClasses.circle}`]: {
27+
color: ReviewColors[review._id] || colors.black,
28+
},
29+
}));
2430

25-
return reviews.map((review) => {
26-
const format =
27-
statsProps.format === "count" ? () => review.count : null;
2831
return (
2932
<div
3033
style={
@@ -52,13 +55,53 @@ const ReviewProgress = ({ reviews, statsProps }) => {
5255
{statsProps.countInTitle && `${review.count} `}
5356
{t(`claimReviewForm:${review._id}`)}
5457
</span>
55-
<Progress
56-
percent={review.percentage}
57-
type={statsProps.type}
58-
format={format}
59-
{...getStyle(review._id)}
60-
/>
61-
</div>
58+
{statsProps.type === "circle" ?
59+
<Grid container position="relative" display="inline-flex" justifyContent="center"
60+
alignItems="center">
61+
<CircularProgress
62+
variant="determinate"
63+
value={100}
64+
size={statsProps.size}
65+
thickness={8}
66+
sx={{ color: colors.neutralTertiary, position: "absolute" }}
67+
/>
68+
<BorderCircularProgress
69+
variant="determinate"
70+
value={review.percentage}
71+
size={statsProps.size}
72+
thickness={8}
73+
/>
74+
<p
75+
style={{
76+
fontSize: statsProps.size === 30 ? "10px" : "14px",
77+
position: "absolute",
78+
top: "50%",
79+
left: "50%",
80+
transform: "translate(-50%, -50%)",
81+
}}
82+
>
83+
{review.count}
84+
</p>
85+
</Grid>
86+
:
87+
<Grid container alignItems="center">
88+
<Grid item xs={11}>
89+
<BorderLinearProgress
90+
variant="determinate"
91+
value={review.percentage}
92+
sx={{ height: 18, borderRadius: 10 }}
93+
/>
94+
</Grid>
95+
<Grid item xs={1}>
96+
<p
97+
style={{ fontSize: "12px", margin: 0, padding: "0px 10px" }}
98+
>
99+
{review.percentage}%
100+
</p>
101+
</Grid>
102+
</Grid>
103+
}
104+
</div >
62105
);
63106
});
64107
};

src/components/Personality/PersonalityCard.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,7 @@ const PersonalityCard = ({
208208
<ReviewStats
209209
stats={personality.stats}
210210
type="circle"
211-
format="count"
212-
width={summarized && 30}
213-
showInfo={!summarized}
214-
strokeWidth="16"
211+
size={summarized ? 30 : 80}
215212
/>
216213
</Grid>
217214
</Grid>

0 commit comments

Comments
 (0)