@@ -6,34 +6,32 @@ import Highlight, {
6
6
PrismTheme ,
7
7
} from "prism-react-renderer"
8
8
import Prism from "prism-react-renderer/prism"
9
- import { Box , BoxProps , Flex , useColorModeValue } from "@chakra-ui/react"
10
9
11
10
// https://github.com/FormidableLabs/prism-react-renderer/tree/master#custom-language-support
12
11
import CopyToClipboard from "@/components/CopyToClipboard"
13
12
import Emoji from "@/components/Emoji"
13
+ import { Flex } from "@/components/ui/flex"
14
+
15
+ import { cn } from "@/lib/utils/cn"
14
16
15
17
import { LINES_BEFORE_COLLAPSABLE } from "@/lib/constants"
18
+
19
+ import useColorModeValue from "@/hooks/useColorModeValue"
16
20
; ( typeof global !== "undefined" ? global : window ) . Prism = Prism
17
21
require ( "prismjs/components/prism-solidity" )
18
22
19
- const TopBarItem = ( props : BoxProps ) => {
20
- const bgColor = useColorModeValue ( "#f7f7f7" , "#363641" )
21
-
23
+ const TopBarItem = ( {
24
+ className,
25
+ ...props
26
+ } : React . HTMLAttributes < HTMLDivElement > ) => {
22
27
return (
23
- < Box
24
- border = "1px"
25
- borderRadius = "base"
26
- borderColor = "searchBorder"
27
- bg = { bgColor }
28
- ms = { 2 }
29
- py = { 1 }
30
- px = { 2 }
31
- _hover = { {
32
- cursor : "pointer" ,
33
- color : "text100" ,
34
- transform : "scale(1.04)" ,
35
- boxShadow : "1px 1px 8px 1px rgba(0, 0, 0, 0.5)" ,
36
- } }
28
+ < div
29
+ className = { cn (
30
+ "ms-2 rounded border px-2 py-1 shadow-[1px_1px_8px_1px_rgba(var(--black),_0.5)] transition-transform duration-100" ,
31
+ "hover:scale-105 hover:cursor-pointer hover:bg-gray-200 hover:shadow-md hover:transition-transform hover:duration-100" ,
32
+ "bg-background-highlight hover:bg-background" ,
33
+ className
34
+ ) }
37
35
{ ...props }
38
36
/>
39
37
)
@@ -42,8 +40,8 @@ const TopBarItem = (props: BoxProps) => {
42
40
const codeTheme = {
43
41
light : {
44
42
plain : {
45
- backgroundColor : "#fafafa" ,
46
- color : "#333333" ,
43
+ backgroundColor : "#f7f7f7" , // background-highlight (gray-50)
44
+ color : "#6C24DF" , // primary (purple-600)
47
45
} ,
48
46
styles : [
49
47
{
@@ -114,8 +112,8 @@ const codeTheme = {
114
112
dark : {
115
113
// Pulled from `defaultProps.theme` for potential customization
116
114
plain : {
117
- backgroundColor : "#2a2734" ,
118
- color : "#9a86fd" ,
115
+ backgroundColor : "#121212" , // background-highlight (gray-900)
116
+ color : "#B38DF0" , // primary (purple-400)
119
117
} ,
120
118
styles : [
121
119
{
@@ -251,18 +249,17 @@ const Codeblock = ({
251
249
return (
252
250
/* Overwrites codeblocks inheriting RTL styling in Right-To-Left script languages (e.g. Arabic) */
253
251
/* Context: https://github.com/ethereum/ethereum-org-website/issues/6202 */
254
- < Box position = "relative" dir = "ltr" >
255
- < Box
256
- borderRadius = "base"
257
- border = { fromHomepage ? "none" : "1px solid" }
258
- borderColor = "border"
259
- maxH = {
260
- isCollapsed
252
+ < div className = "relative" dir = "ltr" >
253
+ < div
254
+ className = { cn (
255
+ "mb-4 overflow-scroll rounded" ,
256
+ fromHomepage && "mb-0 border"
257
+ ) }
258
+ style = { {
259
+ maxHeight : isCollapsed
261
260
? `calc((1.2rem * ${ LINES_BEFORE_COLLAPSABLE } ) + 4.185rem)`
262
- : "none"
263
- }
264
- overflow = "scroll"
265
- mb = { fromHomepage ? 0 : 4 }
261
+ : "none" ,
262
+ } }
266
263
>
267
264
< Highlight
268
265
{ ...defaultProps }
@@ -271,53 +268,38 @@ const Codeblock = ({
271
268
theme = { selectedTheme as PrismTheme }
272
269
>
273
270
{ ( { className, style, tokens, getLineProps, getTokenProps } ) => (
274
- < Box
275
- as = "pre"
271
+ < pre
272
+ className = { cn (
273
+ "m-0 w-fit min-w-full overflow-visible py-6 ps-4" ,
274
+ hasTopBar && "pt-[2.75rem]" ,
275
+ className
276
+ ) }
276
277
style = { style }
277
- className = { className }
278
- pt = { hasTopBar ? "2.75rem" : 6 }
279
- pb = { 6 }
280
- ps = { 4 }
281
- m = { 0 }
282
- overflow = "visible"
283
- minW = "full"
284
- w = "fit-content"
285
278
>
286
279
{ tokens . map ( ( line , i ) => {
287
280
return i === tokens . length - 1 &&
288
281
line [ 0 ] . content === "" ? null : (
289
- < Box
282
+ < div
290
283
key = { i }
291
- display = "table-row"
284
+ style = { { display : "table-row" } }
292
285
{ ...getLineProps ( { line, key : i } ) }
293
286
>
294
287
{ shouldShowLineNumbers && (
295
- < Box
296
- as = "span"
297
- display = "table-cell"
298
- textAlign = "end"
299
- pe = { 8 }
300
- userSelect = "none"
301
- opacity = { 0.4 }
302
- >
288
+ < span className = "table-cell select-none pe-8 text-end opacity-40" >
303
289
{ i + 1 }
304
- </ Box >
290
+ </ span >
305
291
) }
306
- < Box as = " span" display = "table-cell" >
292
+ < span className = "table-cell" >
307
293
{ line . map ( ( token , key ) => (
308
294
< span key = { key } { ...getTokenProps ( { token, key } ) } />
309
295
) ) }
310
- </ Box >
311
- </ Box >
296
+ </ span >
297
+ </ div >
312
298
)
313
299
} ) }
314
300
{ ! fromHomepage && (
315
301
< Flex
316
- className = { className }
317
- justify = "flex-end"
318
- position = "absolute"
319
- top = { 3 }
320
- insetInlineEnd = { 4 }
302
+ className = { cn ( "absolute end-4 top-3 justify-end" , className ) }
321
303
>
322
304
{ allowCollapse &&
323
305
totalLines - 1 > LINES_BEFORE_COLLAPSABLE && (
@@ -349,11 +331,11 @@ const Codeblock = ({
349
331
) }
350
332
</ Flex >
351
333
) }
352
- </ Box >
334
+ </ pre >
353
335
) }
354
336
</ Highlight >
355
- </ Box >
356
- </ Box >
337
+ </ div >
338
+ </ div >
357
339
)
358
340
}
359
341
0 commit comments