rationalize host component

This commit is contained in:
Alex Holliday committed 2025-01-24 16:22:14 -08:00
1 parent 0234cab8b5
commit be6d2f25ea
1 file changed
+35 -35
@@ -1,5 +1,6 @@
import { Box, Typography } from "@mui/material"; import { Stack, Box, Typography } from "@mui/material";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { useTheme } from "@emotion/react";
/** /**
* Host component. * Host component.
* This subcomponent receives a params object and displays the host details. * This subcomponent receives a params object and displays the host details.
@@ -13,44 +14,43 @@ import PropTypes from "prop-types";
* @returns {React.ElementType} Returns a div element with the host details. * @returns {React.ElementType} Returns a div element with the host details.
*/ */
const Host = ({ url, title, percentageColor, percentage }) => { const Host = ({ url, title, percentageColor, percentage }) => {
const noTitle = title === undefined || title === url; const theme = useTheme();
console.log(url, title);
return ( return (
<Box className="host"> <Stack>
<Box <Stack
display="inline-block" direction="row"
position="relative" position="relative"
sx={{ alignItems="center"
fontWeight: 500, gap={theme.spacing(4)}
"&:before": {
position: "absolute",
content: `""`,
width: "4px",
height: "4px",
borderRadius: "50%",
backgroundColor: "gray",
opacity: 0.8,
right: "-10px",
top: "42%",
},
}}
> >
{title} {title}
</Box> {percentageColor && percentage && (
{percentageColor && percentage && ( <>
<Typography <span
component="span" style={{
sx={{ content: '""',
color: percentageColor, width: "4px",
fontWeight: 500, height: "4px",
/* TODO point font weight to theme */ borderRadius: "50%",
ml: "15px", backgroundColor: "gray",
}} opacity: 0.8,
> }}
{percentage}% />
</Typography> <Typography
)} component="span"
{!noTitle && <Box sx={{ opacity: 0.6 }}>{url}</Box>} sx={{
</Box> color: percentageColor,
fontWeight: 500,
}}
>
{percentage}%
</Typography>
</>
)}
</Stack>
<span style={{ opacity: 0.6 }}>{url}</span>
</Stack>
); );
}; };