mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Co-authored-by: Heroman3003 <31296024+Heroman3003@users.noreply.github.com> Co-authored-by: Selis <selis@xynolabs.com>
28 lines
751 B
JavaScript
28 lines
751 B
JavaScript
/**
|
|
* @file
|
|
* @copyright 2020 Aleksej Komarov
|
|
* @license MIT
|
|
*/
|
|
|
|
import { Color } from 'common/color';
|
|
import { toFixed } from 'common/math';
|
|
import { useSelector } from 'common/redux';
|
|
import { Box } from 'tgui_ch/components'; // CHOMPEdit - tgui_ch
|
|
import { selectPing } from './selectors';
|
|
|
|
export const PingIndicator = (props, context) => {
|
|
const ping = useSelector(context, selectPing);
|
|
const color = Color.lookup(ping.networkQuality, [
|
|
new Color(220, 40, 40),
|
|
new Color(220, 200, 40),
|
|
new Color(60, 220, 40),
|
|
]);
|
|
const roundtrip = ping.roundtrip ? toFixed(ping.roundtrip) : '--';
|
|
return (
|
|
<div className="Ping">
|
|
<Box className="Ping__indicator" backgroundColor={color} />
|
|
{roundtrip}
|
|
</div>
|
|
);
|
|
};
|