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

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

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

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

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