Skip to content

Commit 3f59fc4

Browse files
committed
fix: fix #30
1 parent 22ea64b commit 3f59fc4

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

frontend/src/utils/mcformat.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from "react";
2+
import { useTheme } from "next-themes";
23

34
const colorMap: Record<string, string> = {
45
"0": "#000000",
@@ -31,9 +32,20 @@ const colorMap: Record<string, string> = {
3132
v: "#EB7114",
3233
};
3334

35+
const lightModeColorMap: Record<string, string> = {
36+
...colorMap,
37+
e: "#D4A500",
38+
g: "#B89F00",
39+
h: "#8B7355",
40+
i: "#666666",
41+
};
42+
3443
type StyleState = { color?: string; bold?: boolean; italic?: boolean };
3544

3645
export function renderMcText(text: string): React.ReactNode {
46+
const { theme } = useTheme();
47+
const isLight = theme === "light";
48+
const activeColorMap = isLight ? lightModeColorMap : colorMap;
3749
const parts: React.ReactNode[] = [];
3850
let i = 0;
3951
let style: StyleState = {};
@@ -77,7 +89,7 @@ export function renderMcText(text: string): React.ReactNode {
7789
style = { ...style, italic: true };
7890
continue;
7991
}
80-
const col = colorMap[code];
92+
const col = activeColorMap[code];
8193
if (col) {
8294
style = { ...style, color: col };
8395
continue;

0 commit comments

Comments
 (0)