Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate progress antd to MUI #1815

Merged
merged 1 commit into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Metrics/MetricsOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const MetricsOverview = ({ stats }) => {
) : (
t("metrics:empytOverview")
)}
<ReviewStats stats={stats} countInTitle={true} type="line" />
<ReviewStats stats={stats} countInTitle={true} />
</Col>
</Row>
);
Expand Down
93 changes: 68 additions & 25 deletions src/components/Metrics/ReviewProgress.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
import React from "react";
import { Progress, ProgressProps } from "antd";
import {
Grid,
LinearProgress,
CircularProgress,
linearProgressClasses,
circularProgressClasses
} from "@mui/material";
import styled from "styled-components";
import ReviewColors from "../../constants/reviewColors";
import colors from "../../styles/colors";
import StatsReviewColors from "../../constants/statsReviewColors";
import { useTranslation } from "next-i18next";

const ReviewProgress = ({ reviews, statsProps }) => {
const { t } = useTranslation();

return reviews.map((review) => {
const BorderLinearProgress = styled(LinearProgress)(() => ({
[`& .${linearProgressClasses.bar}`]: {
borderRadius: 10,
backgroundColor: ReviewColors[review._id] || colors.black,
},
}));

const getStyle = (reviewId) => {
const defaultStyle: ProgressProps = {
strokeWidth: statsProps.strokeWidth || 18,
width: statsProps.width || 80,
strokeLinecap: statsProps.type === "circle" ? "square" : "round",
trailColor: colors.neutralTertiary,
};

return {
...defaultStyle,
strokeColor: StatsReviewColors[reviewId] || colors.black,
};
};
const BorderCircularProgress = styled(CircularProgress)(() => ({
[`& .${circularProgressClasses.circle}`]: {
color: ReviewColors[review._id] || colors.black,
},
}));

return reviews.map((review) => {
const format =
statsProps.format === "count" ? () => review.count : null;
return (
<div
style={
Expand Down Expand Up @@ -52,13 +55,53 @@ const ReviewProgress = ({ reviews, statsProps }) => {
{statsProps.countInTitle && `${review.count} `}
{t(`claimReviewForm:${review._id}`)}
</span>
<Progress
percent={review.percentage}
type={statsProps.type}
format={format}
{...getStyle(review._id)}
/>
</div>
{statsProps.type === "circle" ?
<Grid container position="relative" display="inline-flex" justifyContent="center"
alignItems="center">
<CircularProgress
variant="determinate"
value={100}
size={statsProps.size}
thickness={8}
sx={{ color: colors.neutralTertiary, position: "absolute" }}
/>
<BorderCircularProgress
variant="determinate"
value={review.percentage}
size={statsProps.size}
thickness={8}
/>
<p
style={{
fontSize: statsProps.size === 30 ? "10px" : "14px",
position: "absolute",
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)",
}}
>
{review.count}
</p>
</Grid>
:
<Grid container alignItems="center">
<Grid item xs={11}>
<BorderLinearProgress
variant="determinate"
value={review.percentage}
sx={{ height: 18, borderRadius: 10 }}
/>
</Grid>
<Grid item xs={1}>
<p
style={{ fontSize: "12px", margin: 0, padding: "0px 10px" }}
>
{review.percentage}%
</p>
</Grid>
</Grid>
}
</div >
);
});
};
Expand Down
5 changes: 1 addition & 4 deletions src/components/Personality/PersonalityCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,7 @@ const PersonalityCard = ({
<ReviewStats
stats={personality.stats}
type="circle"
format="count"
width={summarized && 30}
showInfo={!summarized}
strokeWidth="16"
size={summarized ? 30 : 80}
/>
</Grid>
</Grid>
Expand Down
Loading