From e20e1adae62caf1a0aa0a8f25c8994fcd8cf8c8c Mon Sep 17 00:00:00 2001 From: Ashutosh Bishnoi Date: Mon, 26 Jul 2021 16:47:10 +0530 Subject: Rebases the pull request Initial Draft of Device Quick Menu Initial Draft --- modern/src/common/formatter.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'modern/src/common') diff --git a/modern/src/common/formatter.js b/modern/src/common/formatter.js index 3c0341b..f0bb2e1 100644 --- a/modern/src/common/formatter.js +++ b/modern/src/common/formatter.js @@ -98,3 +98,25 @@ export const formatCoordinate = (key, value, unit) => { return `${value.toFixed(6)}°`; } }; + +export const getStatusColor = (status) => { + switch (status) { + case 'online': + return 'green'; + case 'offline': + return 'red'; + case 'unknown': + default: + return 'gray'; + } +}; + +export const getBatteryStatus = (batteryLevel) => { + if (batteryLevel >= 70) { + return 'green'; + } + if (batteryLevel > 30) { + return 'gray'; + } + return 'red'; +}; -- cgit v1.2.3