1
1
import Link from "@mui/material/Link" ;
2
- import { makeStyles } from "@mui/styles" ;
3
2
import Table from "@mui/material/Table" ;
4
3
import TableBody from "@mui/material/TableBody" ;
5
4
import TableCell from "@mui/material/TableCell" ;
@@ -12,17 +11,24 @@ import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
12
11
import gfm from "remark-gfm" ;
13
12
import { colors } from "theme/colors" ;
14
13
import { darcula } from "react-syntax-highlighter/dist/cjs/styles/prism" ;
15
- import { combineClasses } from "utils/combineClasses " ;
14
+ import { type Interpolation , type Theme } from "@emotion/react " ;
16
15
17
- export const Markdown : FC < { children : string ; className ?: string } > = ( {
18
- children,
19
- className,
20
- } ) => {
21
- const styles = useStyles ( ) ;
16
+ interface MarkdownProps {
17
+ /**
18
+ * The Markdown text to parse and render
19
+ */
20
+ children : string ;
21
+
22
+ className ?: string ;
23
+ }
24
+
25
+ export const Markdown : FC < MarkdownProps > = ( props ) => {
26
+ const { children, className } = props ;
22
27
23
28
return (
24
29
< ReactMarkdown
25
- className = { combineClasses ( [ styles . markdown , className ] ) }
30
+ css = { markdownStyles }
31
+ className = { className }
26
32
remarkPlugins = { [ gfm ] }
27
33
components = { {
28
34
a : ( { href, target, children } ) => (
@@ -58,7 +64,16 @@ export const Markdown: FC<{ children: string; className?: string }> = ({
58
64
{ String ( children ) }
59
65
</ SyntaxHighlighter >
60
66
) : (
61
- < code className = { styles . codeWithoutLanguage } { ...props } >
67
+ < code
68
+ css = { ( theme ) => ( {
69
+ padding : theme . spacing ( 0.125 , 0.5 ) ,
70
+ background : theme . palette . divider ,
71
+ borderRadius : 4 ,
72
+ color : theme . palette . text . primary ,
73
+ fontSize : 14 ,
74
+ } ) }
75
+ { ...props }
76
+ >
62
77
{ children }
63
78
</ code >
64
79
) ;
@@ -100,67 +115,57 @@ export const Markdown: FC<{ children: string; className?: string }> = ({
100
115
101
116
export const MemoizedMarkdown = memo ( Markdown ) ;
102
117
103
- const useStyles = makeStyles ( ( theme ) => ( {
104
- markdown : {
105
- fontSize : 16 ,
106
- lineHeight : "24px" ,
107
-
108
- "& h1, & h2, & h3, & h4, & h5, & h6" : {
109
- marginTop : theme . spacing ( 4 ) ,
110
- marginBottom : theme . spacing ( 2 ) ,
111
- lineHeight : "1.25" ,
112
- } ,
118
+ const markdownStyles : Interpolation < Theme > = ( theme : Theme ) => ( {
119
+ fontSize : 16 ,
120
+ lineHeight : "24px" ,
113
121
114
- "& p" : {
115
- marginTop : 0 ,
116
- marginBottom : theme . spacing ( 2 ) ,
117
- } ,
122
+ "& h1, & h2, & h3, & h4, & h5, & h6" : {
123
+ marginTop : theme . spacing ( 4 ) ,
124
+ marginBottom : theme . spacing ( 2 ) ,
125
+ lineHeight : "1.25" ,
126
+ } ,
118
127
119
- "& p:only-child " : {
120
- marginTop : 0 ,
121
- marginBottom : 0 ,
122
- } ,
128
+ "& p" : {
129
+ marginTop : 0 ,
130
+ marginBottom : theme . spacing ( 2 ) ,
131
+ } ,
123
132
124
- "& ul, & ol" : {
125
- display : "flex" ,
126
- flexDirection : "column" ,
127
- gap : theme . spacing ( 1 ) ,
128
- marginBottom : theme . spacing ( 2 ) ,
129
- } ,
133
+ "& p:only-child" : {
134
+ marginTop : 0 ,
135
+ marginBottom : 0 ,
136
+ } ,
130
137
131
- "& li > ul, & li > ol" : {
132
- marginTop : theme . spacing ( 2 ) ,
133
- } ,
138
+ "& ul, & ol" : {
139
+ display : "flex" ,
140
+ flexDirection : "column" ,
141
+ gap : theme . spacing ( 1 ) ,
142
+ marginBottom : theme . spacing ( 2 ) ,
143
+ } ,
134
144
135
- " & li > p " : {
136
- marginBottom : 0 ,
137
- } ,
145
+ "& li > ul, & li > ol " : {
146
+ marginTop : theme . spacing ( 2 ) ,
147
+ } ,
138
148
139
- "& .prismjs" : {
140
- background : theme . palette . background . paperLight ,
141
- borderRadius : theme . shape . borderRadius ,
142
- padding : theme . spacing ( 2 , 3 ) ,
143
- overflowX : "auto" ,
149
+ "& li > p" : {
150
+ marginBottom : 0 ,
151
+ } ,
144
152
145
- "& code" : {
146
- color : theme . palette . text . secondary ,
147
- } ,
153
+ "& .prismjs" : {
154
+ background : theme . palette . background . paperLight ,
155
+ borderRadius : theme . shape . borderRadius ,
156
+ padding : theme . spacing ( 2 , 3 ) ,
157
+ overflowX : "auto" ,
148
158
149
- "& .key, & .property, & .inserted, .keyword " : {
150
- color : colors . turquoise [ 7 ] ,
151
- } ,
159
+ "& code " : {
160
+ color : theme . palette . text . secondary ,
161
+ } ,
152
162
153
- "& .deleted" : {
154
- color : theme . palette . error . light ,
155
- } ,
163
+ "& .key, & .property, & .inserted, .keyword" : {
164
+ color : colors . turquoise [ 7 ] ,
156
165
} ,
157
- } ,
158
166
159
- codeWithoutLanguage : {
160
- padding : theme . spacing ( 0.125 , 0.5 ) ,
161
- background : theme . palette . divider ,
162
- borderRadius : 4 ,
163
- color : theme . palette . text . primary ,
164
- fontSize : 14 ,
167
+ "& .deleted" : {
168
+ color : theme . palette . error . light ,
169
+ } ,
165
170
} ,
166
- } ) ) ;
171
+ } ) ;
0 commit comments