From 305b3278547792bd817eb7d8a344ebc470be0f45 Mon Sep 17 00:00:00 2001 From: sjaanus Date: Thu, 7 Nov 2024 11:16:34 +0200 Subject: [PATCH] feat: health widget --- .../Project/ProjectStatus/ProjectHealth.tsx | 93 +++++++++++++++++++ .../ProjectStatus/ProjectStatusModal.tsx | 3 +- 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 frontend/src/component/project/Project/ProjectStatus/ProjectHealth.tsx diff --git a/frontend/src/component/project/Project/ProjectStatus/ProjectHealth.tsx b/frontend/src/component/project/Project/ProjectStatus/ProjectHealth.tsx new file mode 100644 index 000000000000..b039138aa003 --- /dev/null +++ b/frontend/src/component/project/Project/ProjectStatus/ProjectHealth.tsx @@ -0,0 +1,93 @@ +import type React from 'react'; +import { useTheme, Typography } from '@mui/material'; +import { styled } from '@mui/system'; +import { Link } from 'react-router-dom'; +import useUiConfig from '../../../../hooks/api/getters/useUiConfig/useUiConfig'; + +interface ProjectHealthProps { + health: number; +} + +const HealthContainer = styled('div')(({ theme }) => ({ + backgroundColor: theme.palette.envAccordion.expanded, + padding: theme.spacing(3), + borderRadius: theme.shape.borderRadiusExtraLarge, + minWidth: '300px', + fontSize: theme.spacing(1.75), +})); + +const ChartRow = styled('div')(({ theme }) => ({ + display: 'flex', + alignItems: 'center', +})); + +const StyledSVG = styled('svg')({ + width: 200, + height: 100, +}); + +const DescriptionText = styled(Typography)(({ theme }) => ({ + color: theme.palette.text.secondary, +})); + +export const ProjectHealth: React.FC = ({ health }) => { + const { isOss } = useUiConfig(); + const theme = useTheme(); + const radius = 40; + const strokeWidth = 13; + const circumference = 2 * Math.PI * radius; + + const gapLength = 0.3; + const filledLength = 1 - gapLength; + const offset = 0.75 - gapLength / 2; + const healthLength = (health / 100) * circumference * 0.7; + + return ( + + + + + + + {health}% + + + + On average, your project health has remained at {health}% + the last 4 weeks + + + + Remember to archive your stale feature flags to keep the project + health growing + + {isOss() && View health over time} + + ); +}; diff --git a/frontend/src/component/project/Project/ProjectStatus/ProjectStatusModal.tsx b/frontend/src/component/project/Project/ProjectStatus/ProjectStatusModal.tsx index aa35be2dbcb6..bb0c0d5b038a 100644 --- a/frontend/src/component/project/Project/ProjectStatus/ProjectStatusModal.tsx +++ b/frontend/src/component/project/Project/ProjectStatus/ProjectStatusModal.tsx @@ -2,6 +2,7 @@ import { styled } from '@mui/material'; import { SidebarModal } from 'component/common/SidebarModal/SidebarModal'; import { ProjectResources } from './ProjectResources'; import { ProjectActivity } from './ProjectActivity'; +import { ProjectHealth } from './ProjectHealth'; const ModalContentContainer = styled('div')(({ theme }) => ({ minHeight: '100vh', @@ -35,7 +36,7 @@ export const ProjectStatusModal = ({ open, close }: Props) => { -
Health widget placeholder
+