Add local reference to mathjax context

This commit is contained in:
Martin Fournier 2022-01-08 07:48:10 -05:00
parent d2193e017d
commit 78a91d9997
6 changed files with 33 additions and 33 deletions

@ -1,6 +1,6 @@
import React from "react";
import { IIndustry } from "../IIndustry";
import { MathJax, MathJaxContext } from "better-react-mathjax";
import { MathJaxWrapper } from "../../MathJaxWrapper";
interface IProps {
division: IIndustry;
@ -19,8 +19,6 @@ export function IndustryProductEquation(props: IProps): React.ReactElement {
}
return (
<MathJaxContext>
<MathJax>{"\\(" + reqs.join("+") + `\\Rightarrow` + prod.map((p) => `1 \\text{${p}}`).join("+") + "\\)"}</MathJax>
</MathJaxContext>
<MathJaxWrapper>{"\\(" + reqs.join("+") + `\\Rightarrow` + prod.map((p) => `1 \\text{${p}}`).join("+") + "\\)"}</MathJaxWrapper>
);
}

@ -15,7 +15,7 @@ import { Reputation } from "../../ui/React/Reputation";
import { numeralWrapper } from "../../ui/numeralFormat";
import { dialogBoxCreate } from "../../ui/React/DialogBox";
import { MathJax, MathJaxContext } from "better-react-mathjax";
import { MathJaxWrapper } from "../../MathJaxWrapper";
import Typography from "@mui/material/Typography";
import Paper from "@mui/material/Paper";
@ -98,9 +98,7 @@ export function DonateOption(props: IProps): React.ReactElement {
}}
/>
<Typography>
<MathJaxContext>
<MathJax>{`\\(reputation = \\frac{\\text{donation amount} \\cdot \\text{reputation multiplier}}{10^{${digits}}}\\)`}</MathJax>
</MathJaxContext>
<MathJaxWrapper>{`\\(reputation = \\frac{\\text{donation amount} \\cdot \\text{reputation multiplier}}{10^{${digits}}}\\)`}</MathJaxWrapper>
</Typography>
</>
)}

@ -9,7 +9,7 @@ import { FactionInfo } from "../../Faction/FactionInfo";
import { Reputation } from "../../ui/React/Reputation";
import { Favor } from "../../ui/React/Favor";
import { MathJax, MathJaxContext } from "better-react-mathjax";
import { MathJaxWrapper } from "../../MathJaxWrapper";
import makeStyles from "@mui/styles/makeStyles";
import createStyles from "@mui/styles/createStyles";
@ -57,16 +57,12 @@ export function Info(props: IProps): React.ReactElement {
You will have <Favor favor={Math.floor(props.faction.favor + favorGain)} /> faction favor after
installing an Augmentation.
</Typography>
<MathJaxContext>
<MathJax>{"\\(\\huge{r = \\text{total faction reputation}}\\)"}</MathJax>
</MathJaxContext>
<MathJaxContext>
<MathJax>
<MathJaxWrapper>{"\\(\\huge{r = \\text{total faction reputation}}\\)"}</MathJaxWrapper>
<MathJaxWrapper>
{
"\\(\\huge{favor=1+\\left\\lfloor\\log_{1.02}\\left(\\frac{r+25000}{25500}\\right)\\right\\rfloor}\\)"
}
</MathJax>
</MathJaxContext>
</MathJaxWrapper>
</>
}
>
@ -88,12 +84,9 @@ export function Info(props: IProps): React.ReactElement {
amount of reputation you earned with this faction. Across all resets.
</Typography>
<MathJaxContext>
<MathJax>{"\\(\\huge{r = reputation}\\)"}</MathJax>
</MathJaxContext>
<MathJaxContext>
<MathJax>{"\\(\\huge{\\Delta r = \\Delta r \\times \\frac{100+favor}{100}}\\)"}</MathJax>
</MathJaxContext>
<MathJaxWrapper>{"\\(\\huge{r = reputation}\\)"}</MathJaxWrapper>
<MathJaxWrapper>{"\\(\\huge{\\Delta r = \\Delta r \\times \\frac{100+favor}{100}}\\)"}</MathJaxWrapper>
</>
}
>

@ -6,7 +6,7 @@ import Typography from "@mui/material/Typography";
import { IPlayer } from "../../PersonObjects/IPlayer";
import { Money } from "../../ui/React/Money";
import { MathJax, MathJaxContext } from "better-react-mathjax";
import { MathJaxWrapper } from "../../MathJaxWrapper";
type IProps = {
p: IPlayer;
@ -33,9 +33,7 @@ export function CoresButton(props: IProps): React.ReactElement {
return (
<Tooltip
title={
<MathJaxContext>
<MathJax>{`\\(\\large{cost = 10^9 \\cdot 7.5 ^{\\text{cores}}}\\)`}</MathJax>
</MathJaxContext>
<MathJaxWrapper>{`\\(\\large{cost = 10^9 \\cdot 7.5 ^{\\text{cores}}}\\)`}</MathJaxWrapper>
}
>
<span>

@ -9,7 +9,8 @@ import { purchaseRamForHomeComputer } from "../../Server/ServerPurchases";
import { Money } from "../../ui/React/Money";
import { numeralWrapper } from "../../ui/numeralFormat";
import { MathJax, MathJaxContext } from "better-react-mathjax";
import { MathJaxWrapper } from "../../MathJaxWrapper";
type IProps = {
p: IPlayer;
@ -32,9 +33,7 @@ export function RamButton(props: IProps): React.ReactElement {
return (
<Tooltip
title={
<MathJaxContext>
<MathJax>{`\\(\\large{cost = 3.2 \\cdot 10^3 \\cdot 1.58^{log_2{(ram)}}}\\)`}</MathJax>
</MathJaxContext>
<MathJaxWrapper>{`\\(\\large{cost = 3.2 \\cdot 10^3 \\cdot 1.58^{log_2{(ram)}}}\\)`}</MathJaxWrapper>
}
>
<span>

14
src/MathJaxWrapper.tsx Normal file

@ -0,0 +1,14 @@
import React from 'react';
import { MathJax, MathJaxContext } from "better-react-mathjax";
interface IProps {
children: React.ReactNode;
}
export function MathJaxWrapper({ children }: IProps): React.ReactElement {
return (
<MathJaxContext version={3} src={"dist/ext/MathJax-3.2.0/es5/tex-chtml.js"}>
<MathJax>{children}</MathJax>
</MathJaxContext>
)
}