From 14064fb63f3a1614683f28bf97026f1efa5fa56d Mon Sep 17 00:00:00 2001 From: "sigonasr2, Sig, Sigo" Date: Tue, 14 Dec 2021 17:54:23 +0000 Subject: [PATCH] Include editable values --- equations/src/App.js | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/equations/src/App.js b/equations/src/App.js index 1548996..1e986a2 100644 --- a/equations/src/App.js +++ b/equations/src/App.js @@ -107,7 +107,7 @@ function EquationValue(p) { function Equation(p) { const {data} = p - const [equation,setEquation]=useState([["data2"],"+","data3"]) + const [equation,setEquation]=useState([["atk"],"×","elementalBonus"]) function SolveEquation(eq) { var newEq = [...eq] @@ -170,22 +170,43 @@ function Equation(p) { {equation.map((eq,i)=>Array.isArray(eq)?:eq==="×"||eq==="-"||eq==="+"||eq==="÷"?:)}

-

{SolveEquation(equation)}

+

{SolveEquation(equation).toFixed(2)}

+ +} + +function EditBox(p) { + const {val,setVal} = p + + const [v,setV] = useState(val) + + useEffect(()=>{ + setVal(v) + },[v]) + + return {setV(ev.currentTarget.value)}}/> +} + +function ValueEditor(p) { + const {lv,setLv,atk,setAtk,def,setDef,elementalBonus,setElementalBonus} = p + + return <>LV
+ ATK
+ ENEMY DEF
+ ENEMY ELEMENTAL BONUS
} function App() { - const fieldData = { - data1:84, - data2:49, - data3:3.5, - data4:67 - } + const [lv,setLv] = useState(4) + const [atk,setAtk] = useState(84) + const [def,setDef] = useState(16) + const [elementalBonus,setElementalBonus] = useState(0.4) return (
+
- +
); }