1.0.33 • Published 2 years ago
@amy-app/react-components v1.0.33
Amy Render
We use a bare-bones approach to our render package, its a bit of a byo. You supply your own renderers into AmyRender
Supported Renderers:
LaTeX
- Katex (We recommend the react-katex npm package, but you could easily roll your own using the katex package)
- Most LaTeX renderers will possibley work fine, we just haven't tested them, there might be edge cases we haven't found yet.
Plots (Graphs)
- Plotly.js (This will most likely be the only supported one for a while, as our plots utilise many of their features)
Markdown
- Marked
- Most other Markdown renderers will work fine, We dont use any specialised markdown in our syntax.
Example config:
It is suggested to copy this config to a new file and import from that into your system.
This so you have the flexability to use your own renderers, and so the AmyRender package isnt huge.
// we need react, because this is a react package...
import React from "react";
import { AmyRender, AmyRenderConfig } from "@amy-app/react-components";
import "katex/dist/katex.min.css";
// these packages are optional (only these have been tested, but this allows us to support more in the future)
import marked from "marked";
import { BlockMath, InlineMath } from "react-katex";
import Plot from "react-plotly.js";
// set up the config, this lets the renderer know what to use to render the different AmySyntax sections
const renderConfig: AmyRenderConfig = {
latex: {
inline: (key: string, text: string) => <InlineMath key={key} math={text} />,
block: (key: string, text: string) => <BlockMath key={key} math={text} />,
},
plot: (name: string, data: any, layout: any) => <Plot key={name} data={data} layout={layout} />,
markdown: marked,
};
// default renderers
export function InstructionRender({ text, color }: { text: string; color?: "black" | "white" }) {
return <AmyRender text={text} config={{ color: color || "black" }} renderConfig={renderConfig} />;
}
export function ExpressionRender({ text, color }: { text: string; color?: "black" | "white" }) {
return (
<AmyRender text={text} config={{ color: color || "black", useBlockMath: true }} renderConfig={renderConfig} />
);
}
1.0.33
2 years ago
1.0.29
3 years ago
1.0.31
3 years ago
1.0.30
3 years ago
1.0.28
3 years ago
1.0.27
3 years ago
1.0.26
4 years ago
1.0.25
4 years ago
1.0.24
4 years ago
1.0.19
4 years ago
1.0.22
4 years ago
1.0.21
4 years ago
1.0.20
4 years ago
1.0.23
4 years ago
1.0.18
4 years ago
1.0.17
4 years ago
1.0.16
4 years ago
1.0.15
4 years ago
1.0.14
4 years ago
1.0.13
4 years ago
1.0.11
4 years ago
1.0.10
4 years ago
1.0.12
4 years ago
1.0.9
4 years ago
1.0.8
4 years ago
1.0.7
4 years ago
1.0.6
4 years ago
1.0.5
4 years ago
1.0.4
4 years ago
1.0.3
4 years ago
1.0.2
4 years ago
1.0.1
4 years ago
1.0.0
4 years ago