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 2 commits into
base: develop
Choose a base branch
from
Open
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
13 changes: 12 additions & 1 deletion Client/src/Components/Charts/CustomGauge/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ const MAXIMUM_VALUE = 100;
*/
const CustomGauge = ({ progress = 0, radius = 70, strokeWidth = 15, threshold = 50 }) => {
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 +71,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 +80,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 +110,7 @@ const CustomGauge = ({ progress = 0, radius = 70, strokeWidth = 15, threshold =
transform: "translate(-50%, -50%)",
...theme.typography.body2,
fill: theme.typography.body2.color,
fontSize: "20px",
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

That hardcoded font size is making me weak!

Instead of hardcoding the font size, consider using the theme's typography system for better consistency.

- fontSize: "20px",
+ fontSize: theme.typography.h6.fontSize,

Committable suggestion skipped: line range outside the PR's diff.

Copy link
Contributor

Choose a reason for hiding this comment

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

This font size should reference the project's fonts

}}
>
{`${progressWithinRange.toFixed(1)}%`}
Expand Down
101 changes: 79 additions & 22 deletions Client/src/Pages/Infrastructure/Details/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import {
import PropTypes from "prop-types";

const BASE_BOX_PADDING_VERTICAL = 4;
const BASE_BOX_PADDING_HORIZONTAL = 8;
const BASE_BOX_PADDING_HORIZONTAL = 4;
const TYPOGRAPHY_PADDING = 8;
const TEXT_FONT_SIZE = 13;
pratikshelar546 marked this conversation as resolved.
Show resolved Hide resolved
/**
* Converts bytes to gigabytes
* @param {number} bytes - Number of bytes to convert
Expand Down Expand Up @@ -75,11 +76,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 @@ -101,10 +103,25 @@ BaseBox.propTypes = {
* @returns {React.ReactElement} Stat box component
*/
const StatBox = ({ heading, subHeading }) => {
const theme = useTheme();
return (
<BaseBox>
<Typography component="h2">{heading}</Typography>
<Typography>{subHeading}</Typography>
<BaseBox
sx={{
padding: `${theme.spacing(8)} ${theme.spacing(6)}`,
}}
>
<Typography
component="h2"
fontSize={TEXT_FONT_SIZE}
>
{heading}
</Typography>
<Typography
fontSize="16px"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hardcoded values for font size are a no go, please reference font sizes from the theme

fontWeight="600"
>
{subHeading}
</Typography>
</BaseBox>
);
};
Expand All @@ -127,41 +144,66 @@ StatBox.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: TEXT_FONT_SIZE,
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}
/>
<Typography
component="h2"
fontWeight="600"
fontSize={TEXT_FONT_SIZE}
>
{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"}
direction="row"
gap={theme.spacing(2)}
>
<Typography>{metricOne}</Typography>
<Typography>{valueOne}</Typography>
<Typography fontSize={TEXT_FONT_SIZE}>{metricOne} </Typography>
Copy link
Contributor

Choose a reason for hiding this comment

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

Font size should come from project's theme

<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={TEXT_FONT_SIZE}>{metricTwo}</Typography>
<Typography sx={value_style}>{valueTwo}</Typography>
</Stack>
</Box>
</Stack>
Expand Down Expand Up @@ -193,7 +235,7 @@ const InfrastructureDetails = () => {
const [monitor, setMonitor] = useState(null);
const { authToken } = useSelector((state) => state.auth);
const [dateRange, setDateRange] = useState("all");
const { statusColor, determineState } = useUtils();
const { statusColor, 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 @@ -482,27 +524,35 @@ 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">
<Typography alignSelf="center">
Last checked {formatDurationSplit(monitor?.lastChecked).time}{" "}
{formatDurationSplit(monitor?.lastChecked).format} ago
</Typography>
</Stack>

<Stack
direction="row"
flexWrap="wrap"
Expand Down Expand Up @@ -544,8 +594,15 @@ const InfrastructureDetails = () => {
}}
>
{areaChartConfigs.map((config) => {
console.log(config);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be removed


Comment on lines +597 to +598
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove debug console.log statement

Debug statements should not be committed to production code.

Apply this change:

-							console.log(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
16 changes: 16 additions & 0 deletions Client/src/Utils/Theme/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ const typographyLevels = {

/* TODO Review color palette and semantic colors */
const paletteColors = {
transparent: "#00000000",
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we nee to add a transparent color? Background color 'transparent' would solve that, right?

Copy link
Author

Choose a reason for hiding this comment

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

We can accommodate that request. However, I was utilizing a transparent color in the Client/src/Utils/Theme/constants.js file on line 196. If I hadn't done that, the color would be undefined for the dark theme. Is that acceptable?

white: "#FFFFFF",
white200:"#F6F6F6",
Copy link
Contributor

Choose a reason for hiding this comment

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

This is basically the same as gray 100, use that instead

grey25: "#FCFCFC",
Copy link
Contributor

Choose a reason for hiding this comment

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

This is almost the same as gray 90, use that instead

Copy link
Author

Choose a reason for hiding this comment

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

sure

gray50: "#FEFEFE",
gray60: "#FEFDFE",
gray70: "#FDFDFD",
Expand All @@ -35,6 +38,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 @@ -183,6 +187,18 @@ const semanticColors = {
light: paletteColors.gray100,
dark: paletteColors.gray850,
},
stroke: {
light: paletteColors.blueGray50,
dark: paletteColors.gray800,
},
gauge: {
light: paletteColors.grey25,
dark: paletteColors.transparent
},
textcard:{
Copy link
Collaborator

Choose a reason for hiding this comment

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

camelCasing here please 👍

light:paletteColors.white200,
dark:paletteColors.transparent
}
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 @@ -69,7 +69,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 @@ -89,6 +89,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 @@ -95,6 +95,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