Files
Checkmate/client/src/Components/v1/Host/index.jsx
T

73 lines
1.8 KiB
React
Raw Normal View History

2025-01-27 13:17:23 -08:00
import { Stack, Typography } from "@mui/material";
2025-01-24 13:09:05 -08:00
import PropTypes from "prop-types";
2025-01-24 16:22:14 -08:00
import { useTheme } from "@emotion/react";
2025-09-27 14:54:55 -07:00
import Dot from "../Dot/index.jsx";
2025-11-12 09:58:38 -06:00
import { StatusLabel } from "@/Components/v1/Label/index.jsx";
2025-01-24 13:09:05 -08:00
/**
* Host component.
* This subcomponent receives a params object and displays the host details.
*
* @component
* @param {Object} params - An object containing the following properties:
* @param {string} params.url - The URL of the host.
* @param {string} params.title - The name of the host.
* @param {string} params.percentageColor - The color of the percentage text.
* @param {number} params.percentage - The percentage to display.
* @returns {React.ElementType} Returns a div element with the host details.
*/
2025-11-12 09:58:38 -06:00
const Host = ({ url, title, percentageColor, percentage, showURL, status }) => {
2025-01-24 16:22:14 -08:00
const theme = useTheme();
2025-01-24 13:09:05 -08:00
return (
2025-01-24 16:22:14 -08:00
<Stack>
<Stack
direction="row"
2025-01-24 13:09:05 -08:00
position="relative"
2025-01-24 16:22:14 -08:00
alignItems="center"
2025-11-12 09:58:38 -06:00
gap={theme.spacing(5)}
2025-01-24 13:09:05 -08:00
>
2025-11-12 09:58:38 -06:00
<Typography
variant="h6"
sx={{
fontWeight: 600,
}}
>
{title}
</Typography>
2025-11-12 10:54:55 -06:00
{percentageColor && percentage && (
2025-01-24 16:22:14 -08:00
<>
2025-01-27 13:17:23 -08:00
<Dot />
2025-01-24 16:22:14 -08:00
<Typography
2025-11-12 09:58:38 -06:00
variant="h6"
2025-01-24 16:22:14 -08:00
sx={{
2025-11-12 09:58:38 -06:00
fontWeight: 600,
2025-01-24 16:22:14 -08:00
color: percentageColor,
}}
>
{percentage}%
</Typography>
2025-11-12 10:54:55 -06:00
{status && (
<StatusLabel
status={status}
text={status}
customStyles={{ textTransform: "capitalize" }}
/>
)}
2025-01-24 16:22:14 -08:00
</>
)}
</Stack>
{showURL && <span style={{ opacity: 0.6 }}>{url}</span>}
2025-01-24 16:22:14 -08:00
</Stack>
2025-01-24 13:09:05 -08:00
);
};
Host.propTypes = {
title: PropTypes.string,
percentageColor: PropTypes.string,
percentage: PropTypes.string,
url: PropTypes.string,
showURL: PropTypes.bool,
2025-11-12 09:58:38 -06:00
status: PropTypes.string,
2025-01-24 13:09:05 -08:00
};
export default Host;