11import ReactMarkdown from "react-markdown" ;
22import remarkGfm from "remark-gfm" ;
3+ import { css } from "@styled-system/css" ;
34
45interface MarkdownRendererProps {
56 content : string ;
@@ -11,51 +12,51 @@ export function MarkdownRenderer({
1112 className = ""
1213} : MarkdownRendererProps ) {
1314 return (
14- < div className = { `prose prose-sm max-w-none ${ className } ` } >
15+ < div className = { `${ markdownContainer } ${ className } ` } >
1516 < ReactMarkdown
1617 remarkPlugins = { [ remarkGfm ] }
1718 components = { {
1819 h1 : ( { children } ) => (
19- < h1 className = "text-xl font-bold text-[#0F0F0F] mb-4 leading-[130%] tracking-[-0.4px]" >
20+ < h1 className = { heading1Style } >
2021 { children }
2122 </ h1 >
2223 ) ,
2324 h2 : ( { children } ) => (
24- < h2 className = "text-lg font-bold text-[#0F0F0F] mb-3 leading-[130%] tracking-[-0.4px]" >
25+ < h2 className = { heading2Style } >
2526 { children }
2627 </ h2 >
2728 ) ,
2829 h3 : ( { children } ) => (
29- < h3 className = "text-base font-bold text-[#0F0F0F] mb-2 leading-[130%] tracking-[-0.4px]" >
30+ < h3 className = { heading3Style } >
3031 { children }
3132 </ h3 >
3233 ) ,
3334 p : ( { children } ) => (
34- < p className = "font-medium text-[16px] leading-[160%] tracking-[-0.4px] text-black/80 mb-4" >
35+ < p className = { paragraphStyle } >
3536 { children }
3637 </ p >
3738 ) ,
3839 strong : ( { children } ) => (
39- < strong className = "font-bold text-black/80" > { children } </ strong >
40+ < strong className = { strongStyle } > { children } </ strong >
4041 ) ,
4142 em : ( { children } ) => (
42- < em className = "italic text-black/80" > { children } </ em >
43+ < em className = { emphasisStyle } > { children } </ em >
4344 ) ,
4445 ul : ( { children } ) => (
45- < ul className = "list-disc list-inside mb-4 space-y-1" > { children } </ ul >
46+ < ul className = { unorderedListStyle } > { children } </ ul >
4647 ) ,
4748 ol : ( { children } ) => (
48- < ol className = "list-decimal list-inside mb-4 space-y-1" >
49+ < ol className = { orderedListStyle } >
4950 { children }
5051 </ ol >
5152 ) ,
5253 li : ( { children } ) => (
53- < li className = "font-medium text-[16px] leading-[160%] tracking-[-0.4px] text-black/80" >
54+ < li className = { listItemStyle } >
5455 { children }
5556 </ li >
5657 ) ,
5758 blockquote : ( { children } ) => (
58- < blockquote className = "border-l-4 border-gray-300 pl-4 mb-4 italic text-black/70" >
59+ < blockquote className = { blockquoteStyle } >
5960 { children }
6061 </ blockquote >
6162 ) ,
@@ -65,8 +66,8 @@ export function MarkdownRenderer({
6566 if ( match ) {
6667 // Code block
6768 return (
68- < pre className = "bg-gray-100 rounded-lg p-4 mb-4 overflow-x-auto" >
69- < code className = "text-sm font-mono text-gray-800" { ...props } >
69+ < pre className = { codeBlockStyle } >
70+ < code className = { codeTextStyle } { ...props } >
7071 { children }
7172 </ code >
7273 </ pre >
@@ -76,7 +77,7 @@ export function MarkdownRenderer({
7677 // Inline code
7778 return (
7879 < code
79- className = "bg-gray-100 px-2 py-1 rounded text-sm font-mono text-gray-800"
80+ className = { inlineCodeStyle }
8081 { ...props }
8182 >
8283 { children }
@@ -88,36 +89,202 @@ export function MarkdownRenderer({
8889 href = { href }
8990 target = "_blank"
9091 rel = "noopener noreferrer"
91- className = "text-blue-600 hover:text-blue-800 underline"
92+ className = { linkStyle }
9293 >
9394 { children }
9495 </ a >
9596 ) ,
9697 table : ( { children } ) => (
97- < div className = "overflow-x-auto mb-4" >
98- < table className = "min-w-full border-collapse border border-gray-300" >
98+ < div className = { tableWrapperStyle } >
99+ < table className = { tableStyle } >
99100 { children }
100101 </ table >
101102 </ div >
102103 ) ,
103104 thead : ( { children } ) => (
104- < thead className = "bg-gray-50" > { children } </ thead >
105+ < thead className = { tableHeadStyle } > { children } </ thead >
105106 ) ,
106107 th : ( { children } ) => (
107- < th className = "border border-gray-300 px-4 py-2 text-left font-semibold text-gray-800" >
108+ < th className = { tableHeaderStyle } >
108109 { children }
109110 </ th >
110111 ) ,
111112 td : ( { children } ) => (
112- < td className = "border border-gray-300 px-4 py-2 text-gray-700" >
113+ < td className = { tableCellStyle } >
113114 { children }
114115 </ td >
115116 ) ,
116- hr : ( ) => < hr className = "border-t border-gray-300 my-6" />
117+ hr : ( ) => < hr className = { horizontalRuleStyle } />
117118 } }
118119 >
119120 { content }
120121 </ ReactMarkdown >
121122 </ div >
122123 ) ;
123124}
125+
126+ // Container Styles
127+ const markdownContainer = css ( {
128+ maxWidth : "none" ,
129+ fontSize : "14px" ,
130+ lineHeight : "1.6"
131+ } ) ;
132+
133+ // Heading Styles
134+ const heading1Style = css ( {
135+ fontSize : "24px" ,
136+ fontWeight : "bold" ,
137+ color : "#0F0F0F" ,
138+ marginBottom : "16px" ,
139+ lineHeight : "130%" ,
140+ letterSpacing : "-0.4px"
141+ } ) ;
142+
143+ const heading2Style = css ( {
144+ fontSize : "20px" ,
145+ fontWeight : "bold" ,
146+ color : "#0F0F0F" ,
147+ marginBottom : "12px" ,
148+ lineHeight : "130%" ,
149+ letterSpacing : "-0.4px"
150+ } ) ;
151+
152+ const heading3Style = css ( {
153+ fontSize : "16px" ,
154+ fontWeight : "bold" ,
155+ color : "#0F0F0F" ,
156+ marginBottom : "8px" ,
157+ lineHeight : "130%" ,
158+ letterSpacing : "-0.4px"
159+ } ) ;
160+
161+ // Text Styles
162+ const paragraphStyle = css ( {
163+ fontWeight : "500" ,
164+ fontSize : "16px" ,
165+ lineHeight : "160%" ,
166+ letterSpacing : "-0.4px" ,
167+ color : "rgba(0, 0, 0, 0.8)" ,
168+ marginBottom : "16px"
169+ } ) ;
170+
171+ const strongStyle = css ( {
172+ fontWeight : "bold" ,
173+ color : "rgba(0, 0, 0, 0.8)"
174+ } ) ;
175+
176+ const emphasisStyle = css ( {
177+ fontStyle : "italic" ,
178+ color : "rgba(0, 0, 0, 0.8)"
179+ } ) ;
180+
181+ // List Styles
182+ const unorderedListStyle = css ( {
183+ listStyleType : "disc" ,
184+ listStylePosition : "inside" ,
185+ marginBottom : "16px" ,
186+ "& > li" : {
187+ marginTop : "4px" ,
188+ marginBottom : "4px"
189+ }
190+ } ) ;
191+
192+ const orderedListStyle = css ( {
193+ listStyleType : "decimal" ,
194+ listStylePosition : "inside" ,
195+ marginBottom : "16px" ,
196+ "& > li" : {
197+ marginTop : "4px" ,
198+ marginBottom : "4px"
199+ }
200+ } ) ;
201+
202+ const listItemStyle = css ( {
203+ fontWeight : "500" ,
204+ fontSize : "16px" ,
205+ lineHeight : "160%" ,
206+ letterSpacing : "-0.4px" ,
207+ color : "rgba(0, 0, 0, 0.8)"
208+ } ) ;
209+
210+ // Quote Styles
211+ const blockquoteStyle = css ( {
212+ borderLeftWidth : "4px" ,
213+ borderLeftColor : "#D3D3D3" ,
214+ paddingLeft : "16px" ,
215+ marginBottom : "16px" ,
216+ fontStyle : "italic" ,
217+ color : "rgba(0, 0, 0, 0.7)"
218+ } ) ;
219+
220+ // Code Styles
221+ const codeBlockStyle = css ( {
222+ backgroundColor : "#F5F5F5" ,
223+ borderRadius : "8px" ,
224+ padding : "16px" ,
225+ marginBottom : "16px" ,
226+ overflowX : "auto"
227+ } ) ;
228+
229+ const codeTextStyle = css ( {
230+ fontSize : "14px" ,
231+ fontFamily : "monospace" ,
232+ color : "#333333"
233+ } ) ;
234+
235+ const inlineCodeStyle = css ( {
236+ backgroundColor : "#F5F5F5" ,
237+ paddingX : "8px" ,
238+ paddingY : "4px" ,
239+ borderRadius : "4px" ,
240+ fontSize : "14px" ,
241+ fontFamily : "monospace" ,
242+ color : "#333333"
243+ } ) ;
244+
245+ // Link Styles
246+ const linkStyle = css ( {
247+ color : "#2563EB" ,
248+ textDecoration : "underline" ,
249+ _hover : {
250+ color : "#1E40AF"
251+ }
252+ } ) ;
253+
254+ // Table Styles
255+ const tableWrapperStyle = css ( {
256+ overflowX : "auto" ,
257+ marginBottom : "16px"
258+ } ) ;
259+
260+ const tableStyle = css ( {
261+ minWidth : "100%" ,
262+ borderCollapse : "collapse" ,
263+ border : "1px solid #D3D3D3"
264+ } ) ;
265+
266+ const tableHeadStyle = css ( {
267+ backgroundColor : "#F9F9F9"
268+ } ) ;
269+
270+ const tableHeaderStyle = css ( {
271+ border : "1px solid #D3D3D3" ,
272+ paddingX : "16px" ,
273+ paddingY : "8px" ,
274+ textAlign : "left" ,
275+ fontWeight : "600" ,
276+ color : "#333333"
277+ } ) ;
278+
279+ const tableCellStyle = css ( {
280+ border : "1px solid #D3D3D3" ,
281+ paddingX : "16px" ,
282+ paddingY : "8px" ,
283+ color : "#555555"
284+ } ) ;
285+
286+ // Other Styles
287+ const horizontalRuleStyle = css ( {
288+ borderTop : "1px solid #D3D3D3" ,
289+ marginY : "24px"
290+ } ) ;
0 commit comments