-
Notifications
You must be signed in to change notification settings - Fork 39
/
index.tsx
303 lines (300 loc) · 6.77 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
import 'uno.css'
import '@unocss/reset/tailwind.css'
import clsx from 'clsx'
import type { Components } from 'react-markdown'
import omit from 'omit.js'
import Toolbox from './toolbox'
import './index.css'
function omitProps(props: any) {
return omit(props, ['node', 'ordered', 'inline'])
}
const components: Components = {
container: ({ className, ...props }) => (
<div
className={clsx(
'font-sans text-base text-dark-400 bg-white',
'dark:text-light-700 dark:bg-dark-400',
className,
)}
{...omitProps(props)}
/>
),
content: ({ className, ...props }) => (
<div
className={clsx(
'border print:border-none border-light-700 md:w-full md:max-w-screen-md xs:w-full mx-auto p-y-5 sm:p-x-10 p-x-4',
'dark:border-dark-100',
'relative',
className,
)}
{...omitProps(props)}
/>
),
h1: ({ className, ...props }) => (
<h1
className={clsx('m-t-2 m-b-1.5 text-2xl font-semibold', className)}
{...omitProps(props)}
/>
),
h2: ({ className, ...props }) => {
return (
<h2
className={clsx(
'm-t-3 m-b-1 text-xl font-semibold p-y-1 b-b border-dark',
'dark:border-dark-100',
className,
)}
{...omitProps(props)}
></h2>
)
},
h3: ({ className, ...props }) => (
<h3
className={clsx('m-t-2 m-b-1 p-y-0.5 text-base font-semibold', className)}
{...omitProps(props)}
/>
),
ul: ({ className, ...props }) => (
<ul
className={clsx(
'm-b-2 text-0.9rem p-l-5 list-disc',
'dark:text-gray-300',
className,
)}
{...omitProps(props)}
/>
),
ol: ({ className, ...props }) => (
<ol
className={clsx('m-b-2 text-0.9rem p-l-5 list-decimal', className)}
{...omitProps(props)}
/>
),
li: ({ className, ...props }) => (
<li
className={clsx('p-y-0.5', className)}
{...omitProps(props)}
/>
),
a: ({ className, ...props }) => (
<a
className={clsx(
'text-blue-600 underline',
'dark:text-blue-400',
className,
)}
{...omitProps(props)}
/>
),
p: ({ className, ...props }) => (
<p
className={clsx('', className)}
{...omitProps(props)}
/>
),
img: ({ className, ...props }) => (
<img
className={clsx('inline', className)}
{...omitProps(props)}
/>
),
strong: ({ className, ...props }) => (
<strong
className={clsx('font-semibold', className)}
{...omitProps(props)}
/>
),
card: ({ className, ...props }) => {
return (
<div
className={clsx('p-y-0.5 grid grid-cols-2 gap-y-0.5', className)}
{...omitProps(props)}
/>
)
},
'card-item': ({ className, index, ...props }) => {
return (
<div
{...omitProps(props)}
className={clsx(
'text-sm',
{ 'justify-self-end': index! % 2 === 1 },
className,
)}
/>
)
},
'card-item-label': ({ className, ...props }) => {
return (
<span
{...omitProps(props)}
className={clsx('text-sm font-medium', className)}
/>
)
},
'card-item-value': ({ className, ...props }) => {
return (
<span
className={clsx(
'text-blue-gray-600',
'dark:text-blue-gray-300',
className,
)}
{...omitProps(props)}
/>
)
},
description: ({ className, ...props }) => {
return (
<p
{...omitProps(props)}
className={clsx('text-sm indent', className)}
/>
)
},
header: ({ className, ...props }) => {
return (
<header
{...omitProps(props)}
className={clsx('flex flex-col items-center p-4', className)}
/>
)
},
'header-content': ({ className, ...props }) => {
return (
<div
{...omitProps(props)}
className={clsx('flex flex-col items-center', className)}
/>
)
},
'header-name': ({ className, ...props }) => {
return (
<h1
{...omitProps(props)}
className={clsx('font-bold text-3xl', className)}
/>
)
},
'header-avatar': ({ className, ...props }) => {
return (
<img
{...omitProps(props)}
className={clsx('w-40 text-3xl', className)}
/>
)
},
'header-row': ({ className, ...props }) => {
return (
<ul
{...omitProps(props)}
className={clsx('list-none flex flex-wrap', className)}
/>
)
},
'header-col': ({ className, ...props }) => {
return (
<li
className={clsx(
'sibling:before:content-[quoted:|] sibling:before:p-x-2 sibling:before:text-gray-400',
className,
)}
{...omitProps(props)}
/>
)
},
table: ({ className, ...props }) => {
return (
<table
className={clsx(
'border border-dark text-sm',
'dark:border-dark-100',
className,
)}
{...omitProps(props)}
/>
)
},
th: ({ className, ...props }) => {
return (
<th
className={clsx(
'border p-2 border-dark',
'dark:border-dark-100',
className,
)}
{...(props as any)}
/>
)
},
td: ({ className, ...props }) => {
return (
<td
className={clsx(
'border p-2 border-dark',
'dark:border-dark-100',
className,
)}
{...(props as any)}
/>
)
},
blockquote: ({ className, ...props }) => {
return (
<blockquote
className={clsx(
'border-l-0.3rem p-l-2 border-gray-200 m-b-4 text-gray-700',
'dark:text-gray-400',
className,
)}
{...omitProps(props)}
/>
)
},
code: ({ className, ...props }) => {
return (
<code
className={clsx(
'p-x-1.5 p-y-0.5 bg-neutral-100 rounded-md text-xs',
'dark:bg-neutral-500',
className,
)}
{...omitProps(props)}
/>
)
},
task: ({ className, ...props }) => (
<ul
className={clsx('m-b-2 text-0.9rem p-y-1', className)}
{...omitProps(props)}
/>
),
'task-item': ({ className, ...props }) => (
<li
className={clsx('p-x-5', className)}
{...omitProps(props)}
/>
),
'task-item-checkbox': ({ className, ...props }) => (
<input
className={clsx('-m-l-5 m-r-1 m-b-0.5 align-middle', className)}
{...omitProps(props)}
/>
),
pre: ({ className, ...props }) => (
<pre
className={clsx('bg-light p-x-5 p-y-3', 'dark:bg-dark-300', className)}
{...omitProps(props)}
/>
),
toolbox: ({ node, ...props }) => {
const meta = node.data || {}
return (
<Toolbox
{...omitProps(props)}
meta={meta}
></Toolbox>
)
},
}
export default components