diff --git a/src/Controls.jsx b/src/Controls.jsx index 6a0b2a3..68c8058 100644 --- a/src/Controls.jsx +++ b/src/Controls.jsx @@ -1,10 +1,8 @@ -import ExpressionUploader from "./ExpressionLoader"; import ExpressionAnalysis from "./ExpressionAnalysis"; const Controls = () => { return (
-
); diff --git a/src/ExpressionAnalysis.jsx b/src/ExpressionAnalysis.jsx index 247e758..280058b 100644 --- a/src/ExpressionAnalysis.jsx +++ b/src/ExpressionAnalysis.jsx @@ -1,6 +1,6 @@ const ExpressionAnalysis = () => { return ( -
+
Calculator diff --git a/src/ExpressionLoader.jsx b/src/ExpressionLoader.jsx index 459b30f..ea307ac 100644 --- a/src/ExpressionLoader.jsx +++ b/src/ExpressionLoader.jsx @@ -32,22 +32,22 @@ const ExpressionLoader = () => { setMathExpression([...mathExpression, expressionDetails]); }; - - useEffect(() => { - async function getMathPixToken(){ + async function getMathPixToken() { try { - let response = await fetch("http://aspacetech.us-east-2.elasticbeanstalk.com/token",{ - "content-type": "application/json", - method: "POST" - }).then(res => res.json()); + let response = await fetch( + "http://aspacetech.us-east-2.elasticbeanstalk.com/token", + { + "content-type": "application/json", + method: "POST", + } + ).then((res) => res.json()); return response.token; - } - catch (e){ + } catch (e) { console.log("Failed to get temporary token"); } - }; + } async function imageToMathPix(img) { try { @@ -84,10 +84,28 @@ const ExpressionLoader = () => { }, [image]); return ( -
- - - +
+
+
+ +
+ + + +
+ { + if (e.key === "Enter") { + storeExpression(e.target.value); + } + }} + />
); }; diff --git a/src/Expressions.jsx b/src/Expressions.jsx index 410f0e0..3914626 100644 --- a/src/Expressions.jsx +++ b/src/Expressions.jsx @@ -1,6 +1,7 @@ import { useContext } from "react"; import MathContext from "./MathContext"; import { MathJax } from "better-react-mathjax"; +import ExpressionUploader from "./ExpressionLoader"; //import EquationSolver from "./EquationSolver"; const Expressions = () => { @@ -9,52 +10,55 @@ const Expressions = () => { return (
- {mathExpressions ? ( - mathExpressions.map((mExpr) => { - return ( -
- -

- {"`" + mExpr.asciimathExpr + "`"} -

-

{"`" + mExpr.nodeExpr.toString() + "`"}

-
- {Object.keys(mExpr.currentScope).map((variable) => { - return ( -
- - { - mathExpressions.find( - (m) => m.asciimathExpr === mExpr.asciimathExpr - ).currentScope[variable] = e.target.value; - setMathExpressions([...mathExpressions]); - }} - > -
- ); - })} -
-
+ {mathExpressions + ? mathExpressions.map((mExpr, idx) => { + return (
-
- ); - }) - ) : ( -

Upload math expression

- )} + className="ast-expression w-full font-bold text-black" + > +
+ +

+ {"`" + "y_" + idx + "=" + mExpr.asciimathExpr + "`"} +

+

+ {"`" + mExpr.nodeExpr.toString() + "`"} +

+
+ {Object.keys(mExpr.currentScope).map((variable) => { + return ( +
+ + { + mathExpressions.find( + (m) => m.asciimathExpr === mExpr.asciimathExpr + ).currentScope[variable] = e.target.value; + setMathExpressions([...mathExpressions]); + }} + > +
+ ); + })} +
+
+
+ ); + }) + : null} +
); }; diff --git a/src/ImageCapture.jsx b/src/ImageCapture.jsx index 8de2fa9..3d38ec7 100644 --- a/src/ImageCapture.jsx +++ b/src/ImageCapture.jsx @@ -1,7 +1,7 @@ const ImageCapture = () => { //const ImageDraw = ({ setImage }) => { return ( - diff --git a/src/ImageDraw.jsx b/src/ImageDraw.jsx index a4650bb..296a7cb 100644 --- a/src/ImageDraw.jsx +++ b/src/ImageDraw.jsx @@ -94,7 +94,7 @@ const ImageDraw = () => { //const ImageDraw = ({ setImage }) => { return ( - diff --git a/src/ImageUpload.jsx b/src/ImageUpload.jsx index 089f747..3a073b3 100644 --- a/src/ImageUpload.jsx +++ b/src/ImageUpload.jsx @@ -23,7 +23,10 @@ const ImageUpload = ({ setImage }) => {
diff --git a/tailwind.config.js b/tailwind.config.js index 602aa4b..c8d9038 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -5,6 +5,7 @@ module.exports = { extend: { colors: { asm_dgreen: "rgb(57,61,50)", + asm_mgreen: "rgb(73,84,67)", asm_lgreen: "rgb(88,106,83)", asm_white: "rgb(241,243,238)", asm_dbrown: "rgb(158,150,131)", diff --git a/test_images/cos.png b/test_images/cos.png new file mode 100644 index 0000000..553e2fa Binary files /dev/null and b/test_images/cos.png differ diff --git a/test_images/sin.png b/test_images/sin.png new file mode 100644 index 0000000..4863ee9 Binary files /dev/null and b/test_images/sin.png differ