2025-01-24 16:22:14 -08:00
|
|
|
import { Stack, Box, 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-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 }) => {
|
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 && (
|
|
|
|
|
<>
|
|
|
|
|
<span
|
|
|
|
|
style={{
|
|
|
|
|
content: '""',
|
|
|
|
|
width: "4px",
|
|
|
|
|
height: "4px",
|
|
|
|
|
borderRadius: "50%",
|
|
|
|
|
backgroundColor: "gray",
|
|
|
|
|
opacity: 0.8,
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<Typography
|
|
|
|
|
component="span"
|
|
|
|
|
sx={{
|
|
|
|
|
color: percentageColor,
|
|
|
|
|
fontWeight: 500,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{percentage}%
|
|
|
|
|
</Typography>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</Stack>
|
|
|
|
|
<span style={{ opacity: 0.6 }}>{url}</span>
|
|
|
|
|
</Stack>
|
2025-01-24 13:09:05 -08:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Host.propTypes = {
|
|
|
|
|
title: PropTypes.string,
|
|
|
|
|
percentageColor: PropTypes.string,
|
|
|
|
|
percentage: PropTypes.string,
|
|
|
|
|
url: PropTypes.string,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default Host;
|