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

fixes: fixes UI of infrastructure details page UI #1291 #1361

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
5,271 changes: 1,484 additions & 3,787 deletions Client/package-lock.json

Large diffs are not rendered by default.

19 changes: 16 additions & 3 deletions Client/src/Components/Charts/CustomGauge/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const MAXIMUM_VALUE = 100;
* @param {number} [props.radius=60] - Radius of the gauge circle
* @param {number} [props.strokeWidth=15] - Width of the gauge stroke
* @param {number} [props.threshold=50] - Threshold for color change
*
* @param {number} [props.percentageFontSize] - percentage font size
*
* @example
* <CustomGauge
* progress={75}
Expand All @@ -27,8 +28,17 @@ const MAXIMUM_VALUE = 100;
*
* @returns {React.ReactElement} Rendered CustomGauge component
*/
const CustomGauge = ({ progress = 0, radius = 70, strokeWidth = 15, threshold = 50 }) => {
const CustomGauge = ({ progress = 0, radius = 70, strokeWidth = 15, threshold = 50,percentageFontSize=12 }) => {
const theme = useTheme();
const BOX_STYLE = {
borderRadius: "50%",
boxShadow: "0px 2px 4px -3px #20202040",
padding:"6px",
alignItems:"center",
display:"flex",
backgroundColor:theme.palette.background.main
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Styling must be consistent throughout the app, the theme should be used to apply styles to something like this


// Calculate the length of the stroke for the circle
const { circumference, totalSize, strokeLength } = useMemo(
() => ({
Expand Down Expand Up @@ -62,6 +72,7 @@ const CustomGauge = ({ progress = 0, radius = 70, strokeWidth = 15, threshold =
className="radial-chart"
width={radius}
height={radius}
sx={BOX_STYLE}
>
<svg
viewBox={`0 0 ${totalSize} ${totalSize}`}
Expand All @@ -70,7 +81,7 @@ const CustomGauge = ({ progress = 0, radius = 70, strokeWidth = 15, threshold =
>
<circle
className="radial-chart-base"
stroke={theme.palette.background.fill}
stroke={theme.palette.background.stroke}
strokeWidth={strokeWidth}
fill="none"
cx={totalSize / 2} // Center the circle
Expand Down Expand Up @@ -100,6 +111,7 @@ const CustomGauge = ({ progress = 0, radius = 70, strokeWidth = 15, threshold =
transform: "translate(-50%, -50%)",
...theme.typography.body2,
fill: theme.typography.body2.color,
fontSize: percentageFontSize,
}}
>
{`${progressWithinRange.toFixed(1)}%`}
Expand All @@ -115,4 +127,5 @@ CustomGauge.propTypes = {
radius: PropTypes.number,
strokeWidth: PropTypes.number,
threshold: PropTypes.number,
percentageFontSize:PropTypes.number,
};
76 changes: 58 additions & 18 deletions Client/src/Pages/Infrastructure/Details/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import PropTypes from "prop-types";
import StatBox from "../../../Components/StatBox";

const BASE_BOX_PADDING_VERTICAL = 4;
const BASE_BOX_PADDING_HORIZONTAL = 8;
const BASE_BOX_PADDING_HORIZONTAL = 4;
const TYPOGRAPHY_PADDING = 8;
/**
* Converts bytes to gigabytes
Expand Down Expand Up @@ -107,11 +107,12 @@ const BaseBox = ({ children, sx = {} }) => {
height: "100%",
padding: `${theme.spacing(BASE_BOX_PADDING_VERTICAL)} ${theme.spacing(BASE_BOX_PADDING_HORIZONTAL)}`,
minWidth: 200,
width: 225,
width: 200,
backgroundColor: theme.palette.background.main,
border: 1,
borderStyle: "solid",
borderColor: theme.palette.border.light,
borderRadius: theme.spacing(2),
...sx,
}}
>
Expand All @@ -138,41 +139,68 @@ BaseBox.propTypes = {
*/
const GaugeBox = ({ value, heading, metricOne, valueOne, metricTwo, valueTwo }) => {
const theme = useTheme();

const value_style = {
width: " 80px",
textAlign: "end",
borderRadius: "4px",
padding: "3px",
backgroundColor: theme.palette.background.textCard,
fontSize: 12,
fontWeight: "600"
};
return (
<BaseBox>
<Stack
direction="column"
gap={theme.spacing(2)}
alignItems="center"
>
<CustomGauge
progress={value}
radius={100}
color={theme.palette.primary.main}
/>
<Typography component="h2">{heading}</Typography>
<Stack
alignItems="center"
width="100%"
gap={theme.spacing(8)}
padding={`${theme.spacing(14)} ${theme.spacing(5)} ${theme.spacing(7)} ${theme.spacing(5)}`}
borderRadius={`${theme.spacing(4)} ${theme.spacing(4)} ${theme.spacing(0)} ${theme.spacing(0)}`}
sx={{ backgroundColor: `${theme.palette.background.gauge}` }}
>
<CustomGauge
progress={value}
radius={120}
color={theme.palette.primary.main}
percentageFontSize={20}
/>
<Typography
component="h2"
fontWeight="600"
fontSize={13}
>
{heading}
</Typography>
</Stack>
<Box
sx={{
width: "100%",
borderTop: `1px solid ${theme.palette.border.light}`,
padding: `${theme.spacing(6)} ${theme.spacing(3)} ${theme.spacing(3)} ${theme.spacing(3)}`,
}}
>
<Stack
justifyContent={"space-between"}
alignItems={"center"}
direction="row"
gap={theme.spacing(2)}
>
<Typography>{metricOne}</Typography>
<Typography>{valueOne}</Typography>
<Typography fontSize={13}>{metricOne} </Typography>
<Typography sx={value_style}>{valueOne}</Typography>
</Stack>
<Stack
justifyContent={"space-between"}
direction="row"
marginTop={theme.spacing(3)}
gap={theme.spacing(2)}
>
<Typography>{metricTwo}</Typography>
<Typography>{valueTwo}</Typography>
<Typography fontSize={13}>{metricTwo}</Typography>
<Typography sx={value_style}>{valueTwo}</Typography>
</Stack>
</Box>
</Stack>
Expand Down Expand Up @@ -206,7 +234,7 @@ const InfrastructureDetails = () => {
const [monitor, setMonitor] = useState(null);
const { authToken } = useSelector((state) => state.auth);
const [dateRange, setDateRange] = useState("day");
const { statusColor, statusStyles, determineState } = useUtils();
const { statusColor, statusStyles, determineState,statusMsg } = useUtils();
// These calculations are needed because ResponsiveContainer
// doesn't take padding of parent/siblings into account
// when calculating height.
Expand Down Expand Up @@ -531,20 +559,27 @@ const InfrastructureDetails = () => {
<Stack
direction="row"
gap={theme.spacing(8)}
alignItems="center"
>
<Box>
<PulseDot color={statusColor[determineState(monitor)]} />
</Box>
<Typography
alignSelf="end"
alignSelf="center"
component="h1"
variant="h1"
>
{monitor.name}
</Typography>
<Typography alignSelf="end">{monitor.url || "..."}</Typography>
<Typography alignSelf="center">{monitor.url || "..."}</Typography>
<Box sx={{ flexGrow: 1 }} />
<Typography alignSelf="end">
<Typography
alignSelf="center"
color={statusColor[determineState(monitor)]}
>
{statusMsg[determineState(monitor)]}
</Typography>
<Typography alignSelf="center">
Checking every {formatDurationRounded(monitor?.interval)}
</Typography>
<Typography alignSelf="end">
Expand Down Expand Up @@ -638,7 +673,12 @@ const InfrastructureDetails = () => {
>
{areaChartConfigs.map((config) => {
return (
<BaseBox key={`${config.type}-${config.diskIndex ?? ""}`}>
<BaseBox
key={`${config.type}-${config.diskIndex ?? ""}`}
sx={{
padding: `${theme.spacing(8)} ${theme.spacing(6)}`,
}}
>
<Typography
component="h2"
padding={theme.spacing(8)}
Expand Down
4 changes: 0 additions & 4 deletions Client/src/Pages/Uptime/utils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,21 @@ const useUtils = () => {
backgroundColor: theme.palette.success.dark,
background: `linear-gradient(340deg, ${theme.palette.success.dark} -60%, ${theme.palette.success.light} 35%)`,
borderColor: theme.palette.success.light,
"& h2": { color: theme.palette.success.main },
},
down: {
backgroundColor: theme.palette.error.dark,
background: `linear-gradient(340deg, ${theme.palette.error.light} -60%, ${theme.palette.error.dark} 35%)`,
borderColor: theme.palette.error.light,
"& h2": { color: theme.palette.error.main },
},
paused: {
backgroundColor: theme.palette.warning.dark,
background: `linear-gradient(340deg, ${theme.palette.warning.light} -60%, ${theme.palette.warning.dark} 35%)`,
borderColor: theme.palette.warning.light,
"& h2": { color: theme.palette.warning.main },
},
pending: {
backgroundColor: theme.palette.warning.light,
background: `linear-gradient(340deg, ${theme.palette.warning.dark} -60%, ${theme.palette.warning.light} 35%)`,
borderColor: theme.palette.warning.dark,
"& h2": { color: theme.palette.warning.main },
},
};
const pagespeedStyles = {
Expand Down
11 changes: 11 additions & 0 deletions Client/src/Utils/Theme/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const paletteColors = {
gray880: "#0C0C0E",
gray890: "#09090B",
blueGray20: "#E8F0FE",
blueGray50: "#CDE2FF",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please confirm color choices with @marcelluscaio

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a print of the element where this color is being applied? For the other colors, please use the ones that already exist, and instead of creating new references, use an existing reference for that color. The idea is that here we are not aware of where the color is being called (so avoid calling them 'stroke' or gauge. We currently have those in the code base, but we are increasingly dropping that approach

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
On Red arrow grey25: "#FCFCFC",
On Black arrow blueGray50: "#CDE2FF",
On Yellow arrow white200:"#F6F6F6",
(this colors are mentioned in figma design)

if i used color which you mentioned then UI will look like this
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you fix the alignment issue here ?

398573263-2339cd47-4d24-4f8c-afd6-e3bac72b1c5e

blueGray150: "#667085",
blueGray200: "#475467",
blueGray400: "#344054",
Expand Down Expand Up @@ -190,6 +191,16 @@ const semanticColors = {
light: paletteColors.gray100,
dark: paletteColors.gray850,
},
stroke: {
light: paletteColors.blueGray50,
dark: paletteColors.gray800,
},
gauge: {
light: paletteColors.gray90
},
textCard:{
light:paletteColors.gray100
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again to be confirmed with @marcelluscaio

},
text: {
primary: {
Expand Down
6 changes: 5 additions & 1 deletion Client/src/Utils/Theme/darkTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const palette = {
line: border.light.dark,
fill: background.accent.dark,
grid: other.grid.dark,
autofill: secondary.main.dark,
autofill: secondary.main.dark
},
gradient: {
color1,
Expand All @@ -93,6 +93,10 @@ const palette = {
alt: background.alt.dark,
fill: background.fill.dark,
accent: background.accent.dark,
stroke: background.stroke.dark,
gauge: background.gauge.dark,
textCard: background.textCard.dark

},
border: {
light: border.light.dark,
Expand Down
3 changes: 3 additions & 0 deletions Client/src/Utils/Theme/lightTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ const palette = {
alt: background.alt.light,
fill: background.fill.light,
accent: background.accent.light,
stroke: background.stroke.light,
gauge: background.gauge.light,
textCard:background.textCard.light
},
border: {
light: border.light.light,
Expand Down
Loading