Skip to content

Commit 2f9e0de

Browse files
authored
Merge pull request #165 from Speedrunyourknowledge/functionCardUI
Convert equation to math form
2 parents 0f2f395 + 6a0cef6 commit 2f9e0de

File tree

4 files changed

+63
-1
lines changed

4 files changed

+63
-1
lines changed

calc-frontend/package-lock.json

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

calc-frontend/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121
"class-variance-authority": "^0.7.1",
2222
"clsx": "^2.1.1",
2323
"jsdom": "^26.0.0",
24+
"katex": "^0.16.22",
2425
"lucide-react": "^0.483.0",
2526
"next-themes": "^0.4.6",
2627
"npm": "^11.1.0",
2728
"react": "^18.3.1",
2829
"react-dom": "^18.3.1",
2930
"react-icons": "^5.5.0",
31+
"react-katex": "^3.0.1",
3032
"react-loader-spinner": "^6.1.6",
3133
"react-markdown": "^10.1.0",
3234
"react-router": "^7.1.5",

calc-frontend/src/components/ui/FunctionCard.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import axios from "axios";
22
import { useNavigate } from "react-router";
33
import { toast } from "sonner";
4+
import { InlineMath } from "react-katex";
5+
import "katex/dist/katex.min.css";
46

57
interface FunctionCardProps {
68
topic: string;
@@ -42,7 +44,9 @@ function FunctionCard({
4244

4345
return (
4446
<div className="bg-[#f6f6f7] p-4 pt-2 rounded-2xl shadow-md text-center w-[240px]">
45-
<p className="text-xl mb-2">{equation}</p>
47+
<p className="text-xl mb-2">
48+
<InlineMath>{equation}</InlineMath>
49+
</p>
4650
<img
4751
src={""}
4852
alt={topic + " graph"}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
declare module "react-katex" {
2+
import * as React from "react";
3+
4+
interface KatexProps {
5+
children?: string;
6+
math?: string;
7+
errorColor?: string;
8+
renderError?: (error: Error) => React.ReactNode;
9+
}
10+
11+
const InlineMath: React.FC<KatexProps>;
12+
const BlockMath: React.FC<KatexProps>;
13+
14+
export { InlineMath, BlockMath };
15+
export default InlineMath;
16+
}

0 commit comments

Comments
 (0)