File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 11import React from "react" ;
2+ import { useTheme } from "next-themes" ;
23
34const 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+
3443type StyleState = { color ?: string ; bold ?: boolean ; italic ?: boolean } ;
3544
3645export 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 ;
You can’t perform that action at this time.
0 commit comments