2026-04-07 07:02:44 -04:00
|
|
|
import Typography from "@mui/material/Typography";
|
|
|
|
|
import { useTheme } from "@mui/material/styles";
|
|
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
|
import type { PageSpeedStrategy } from "@/Types/Monitor";
|
|
|
|
|
import { SPACING } from "@/Utils/Theme/constants";
|
|
|
|
|
|
|
|
|
|
interface StrategyBadgeProps {
|
|
|
|
|
strategy: PageSpeedStrategy | undefined;
|
|
|
|
|
variant?: "caption" | "body2";
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-07 07:14:17 -04:00
|
|
|
export const StrategyBadge = ({ strategy, variant = "body2" }: StrategyBadgeProps) => {
|
2026-04-07 07:02:44 -04:00
|
|
|
const theme = useTheme();
|
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
|
|
if (!strategy) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Typography
|
|
|
|
|
variant={variant}
|
|
|
|
|
px={SPACING.XXL}
|
|
|
|
|
py={SPACING.SM}
|
|
|
|
|
textTransform="capitalize"
|
|
|
|
|
sx={{
|
|
|
|
|
borderRadius: theme.shape.borderRadius,
|
|
|
|
|
backgroundColor: theme.palette.secondary.light,
|
|
|
|
|
color: theme.palette.text.primary,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{t(`pages.pageSpeed.strategy.${strategy}`)}
|
|
|
|
|
</Typography>
|
|
|
|
|
);
|
|
|
|
|
};
|