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
+21 -21
@@ -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", {title}
content: `""`, {percentageColor && percentage && (
<>
<span
style={{
content: '""',
width: "4px", width: "4px",
height: "4px", height: "4px",
borderRadius: "50%", borderRadius: "50%",
backgroundColor: "gray", backgroundColor: "gray",
opacity: 0.8, opacity: 0.8,
right: "-10px",
top: "42%",
},
}} }}
> />
{title}
</Box>
{percentageColor && percentage && (
<Typography <Typography
component="span" component="span"
sx={{ sx={{
color: percentageColor, color: percentageColor,
fontWeight: 500, fontWeight: 500,
/* TODO point font weight to theme */
ml: "15px",
}} }}
> >
{percentage}% {percentage}%
</Typography> </Typography>
</>
)} )}
{!noTitle && <Box sx={{ opacity: 0.6 }}>{url}</Box>} </Stack>
</Box> <span style={{ opacity: 0.6 }}>{url}</span>
</Stack>
); );
}; };