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

56 lines
1.4 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-02-06 15:06:37 -08:00
import Dot from "../Dot";
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.
*/
const Host = ({ url, title, percentageColor, percentage, showURL }) => {
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"
gap={theme.spacing(4)}
2025-01-24 13:09:05 -08:00
>
{title}
2025-01-24 16:22:14 -08:00
{percentageColor && percentage && (
<>
2025-01-27 13:17:23 -08:00
<Dot />
2025-01-24 16:22:14 -08:00
<Typography
component="span"
sx={{
color: percentageColor,
fontWeight: 500,
}}
>
{percentage}%
</Typography>
</>
)}
</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-01-24 13:09:05 -08:00
};
export default Host;