Skip to content

Commit 4408410

Browse files
author
Jon Walls
committed
equation showing in component
1 parent 68651c2 commit 4408410

File tree

3 files changed

+27
-28
lines changed

3 files changed

+27
-28
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"@mui/material": "^5.4.3",
3131
"react": "^17.0.2",
3232
"react-dom": "^17.0.2",
33+
"react-mathjax": "^1.0.1",
3334
"react-stepper-horizontal": "^1.0.11",
3435
"styled-components": "^5.3.3"
3536
}

src/ExampleComponent.js

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
import MathJax from 'react-mathjax'
23

34
import { Box, Button, Divider, TextField, Typography } from '@mui/material'
45

@@ -13,6 +14,11 @@ import { Box, Button, Divider, TextField, Typography } from '@mui/material'
1314
}
1415
*/
1516

17+
const tex = {
18+
quadratic_solution: 'x = {-b \\pm \\sqrt{b^2-4ac} \\over 2a}',
19+
tex_example: `f(x) = \\int_{-\\infty}^\\infty \\hat f(\\xi)\\,e^{2 \\pi i \\xi x} \\,d\\xi`,
20+
}
21+
1622
const ExampleComponent = ({ triggerQuery, model, modelUpdate }) => {
1723
const handleChange = (e) => {
1824
modelUpdate({
@@ -21,34 +27,14 @@ const ExampleComponent = ({ triggerQuery, model, modelUpdate }) => {
2127
}
2228
return(
2329
<>
24-
<Box sx={{ m: 1 }}>
25-
<Typography variant='h2'>{model.greeting}{model.username}</Typography>
26-
<Typography variant='h4'>{model.message}</Typography>
27-
<Button variant="outlined"
28-
onClick={()=>triggerQuery(model.runQuery)}
29-
>Get a user name</Button>
30-
</Box>
31-
32-
<Box sx={{ m: 1 }}>
33-
<Typography variant='body1'>Want to trigger a query?</Typography>
34-
<Button variant="outlined"
35-
onClick={()=>triggerQuery(model.yesQuery)}
36-
>
37-
👍
38-
</Button>
39-
<Button variant="outlined"
40-
onClick={()=>triggerQuery(model.noQuery)}
41-
>
42-
👎
43-
</Button>
44-
</Box>
45-
46-
<Divider />
47-
48-
<Box sx={{ m: 1 }}>
49-
<TextField id="outlined-uncontrolled" label="Change Greeting" onChange={handleChange} />
50-
</Box>
51-
</>
30+
<Box sx={{ m: 1 }} id="retool-custom-mathjax-container">
31+
<Typography variant="body1">{model.text}</Typography>
32+
<MathJax.Provider>
33+
<MathJax.Node formula={model.equation} id="retool-custom-mathjax-equation"/>
34+
</MathJax.Provider>
35+
<Typography variant="body1">{model.question}</Typography>
36+
</Box>
37+
</>
5238
);
5339
}
5440
export default ExampleComponent;

yarn.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2827,6 +2827,11 @@ lines-and-columns@^1.1.6:
28272827
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632"
28282828
integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==
28292829

2830+
load-script@^1.0.0:
2831+
version "1.0.0"
2832+
resolved "https://registry.yarnpkg.com/load-script/-/load-script-1.0.0.tgz#0491939e0bee5643ee494a7e3da3d2bac70c6ca4"
2833+
integrity sha1-BJGTngvuVkPuSUp+PaPSuscMbKQ=
2834+
28302835
loader-runner@^4.2.0:
28312836
version "4.2.0"
28322837
resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.2.0.tgz#d7022380d66d14c5fb1d496b89864ebcfd478384"
@@ -3422,6 +3427,13 @@ react-is@^17.0.2:
34223427
resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0"
34233428
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==
34243429

3430+
react-mathjax@^1.0.1:
3431+
version "1.0.1"
3432+
resolved "https://registry.yarnpkg.com/react-mathjax/-/react-mathjax-1.0.1.tgz#a8c282e75d277a201632dfd07edf41edda372b4b"
3433+
integrity sha512-+mjFcciZY3GQoqiQm3aRTyDjgBKuoaXpY+SCONX00jScuPpTKwnASeFMS5+pbTIzDf5zPT2Y9ZZfQ9U/d4CKtQ==
3434+
dependencies:
3435+
load-script "^1.0.0"
3436+
34253437
react-stepper-horizontal@^1.0.11:
34263438
version "1.0.11"
34273439
resolved "https://registry.yarnpkg.com/react-stepper-horizontal/-/react-stepper-horizontal-1.0.11.tgz#ac10549c2ccb2d39ce820bdfe4bfeac113c90813"

0 commit comments

Comments
 (0)