24 lines
1.1 KiB
TypeScript
24 lines
1.1 KiB
TypeScript
import { Fragment } from "react";
|
|
import { Colors } from "~/application/enums/shared/Colors";
|
|
import SimpleBadge from "~/components/ui/badges/SimpleBadge";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
export default function SpeedBadge({ duration }: { duration: number }) {
|
|
const { t } = useTranslation();
|
|
|
|
// Lightning fast: Green (e.g. #4CAF50), <10 ms
|
|
// Fast: Light green (e.g. #8BC34A), 11 - 100 ms
|
|
// Average: Yellow (e.g. #FFC107), 101 - 500 ms
|
|
// Slow: Orange (e.g. #FF9800), 501 - 1000 ms
|
|
// Very slow: Red (e.g. #F44336), >1000 ms
|
|
return (
|
|
<Fragment>
|
|
{duration < 10 && <SimpleBadge title={t("metrics.speed.lightningFast")} color={Colors.GREEN} />}
|
|
{duration >= 10 && duration < 100 && <SimpleBadge title={t("metrics.speed.fast")} color={Colors.TEAL} />}
|
|
{duration >= 100 && duration < 500 && <SimpleBadge title={t("metrics.speed.average")} color={Colors.YELLOW} />}
|
|
{duration >= 500 && duration < 1000 && <SimpleBadge title={t("metrics.speed.slow")} color={Colors.ORANGE} />}
|
|
{duration >= 1000 && <SimpleBadge title={t("metrics.speed.verySlow")} color={Colors.RED} />}
|
|
</Fragment>
|
|
);
|
|
}
|