From 3a15744a7a814609d484c9dc7e01828a2a5a5e76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D1=80=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Fri, 13 Aug 2021 10:29:34 +0500 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D1=8C=20enum.=20=D0=9F=D0=BE=D0=B4=D1=81?= =?UTF-8?q?=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BA=D0=B0=20=D1=82=D0=B5=D0=BA?= =?UTF-8?q?=D1=81=D1=82=D0=B0=20=D0=B8=D0=B7=20=D1=81=D0=BB=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D1=80=D1=8F=20=D0=BF=D0=BE=20=D0=BA=D0=BB=D1=8E=D1=87?= =?UTF-8?q?=D0=B5=D0=B2=D0=BE=D0=BC=D1=83=20=D0=B7=D0=BD=D0=B0=D1=87=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8E.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Display.jsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/Display.jsx b/src/components/Display.jsx index 8576b5c..d892a04 100644 --- a/src/components/Display.jsx +++ b/src/components/Display.jsx @@ -7,7 +7,7 @@ export const formatNumber = (value, format) => ? (+value).toFixed(format) : (+value).toPrecision(4) -export const ValueDisplay = ({prefix, value, suffix, isArrowVisible, format}) =>{ +export const ValueDisplay = ({prefix, value, suffix, isArrowVisible, format, enumeration}) => { const [val, setVal] = useState('---') const [arrowState, setArrowState] = useState({ preVal: NaN, @@ -21,6 +21,11 @@ export const ValueDisplay = ({prefix, value, suffix, isArrowVisible, format}) => return } + if(enumeration && enumeration[value]){ + setVal(enumeration[value]) + return + } + if(Number.isFinite(+value)){ if ((isArrowVisible) && (arrowState.preTimestamp + 1000 < Date.now())) { @@ -50,7 +55,7 @@ export const ValueDisplay = ({prefix, value, suffix, isArrowVisible, format}) => } setVal(value) - },[value, isArrowVisible, arrowState, format]) + },[value, isArrowVisible, arrowState, format, enumeration]) let arrow = null if(isArrowVisible)