1
+ import { Box , Flex , IconButton , Tooltip } from '@radix-ui/themes' ;
1
2
import { Uri } from 'monaco-editor' ;
2
3
import React , { useEffect , type ReactNode } from 'react' ;
3
4
import { createPortal } from 'react-dom' ;
4
5
import MonacoEditor from 'react-monaco-editor' ;
5
6
import * as _V from 'react-virtuoso' ;
6
- import { Separator , Box , Card , Flex , Inset , IconButton , Tooltip } from '@radix-ui/themes'
7
7
8
- import { transformToFunctionBody } from './esmTransform' ;
9
8
import { useColorMode } from '@docusaurus/theme-common' ;
10
- import { ResetIcon , ClipboardCopyIcon , CubeIcon } from '@radix-ui/react-icons'
9
+ import { ClipboardCopyIcon , CubeIcon , ResetIcon } from '@radix-ui/react-icons' ;
10
+ import { transformToFunctionBody } from './esmTransform' ;
11
11
12
12
// @ts -ignore
13
13
import reactVirtuosoDtsCode from '!!raw-loader!../../../../../../node_modules/react-virtuoso/dist/index.d.ts' ;
@@ -69,7 +69,7 @@ export default function LiveCodeBlock({
69
69
width = "100%"
70
70
height = "100%"
71
71
language = "typescript"
72
- theme = { colorMode === 'dark' ? 'vs -dark' : 'vs -light' }
72
+ theme = { colorMode === 'dark' ? 'custom -dark' : 'custom -light' }
73
73
uri = { ( ) => Uri . parse ( 'file:///custom-example.tsx' ) }
74
74
onChange = { ( value ) => {
75
75
setTsCode ( value )
@@ -92,6 +92,25 @@ export default function LiveCodeBlock({
92
92
updateHeight ( ) ;
93
93
} }
94
94
editorWillMount = { ( monaco ) => {
95
+
96
+ monaco ?. editor . defineTheme ( 'custom-dark' , {
97
+ base : 'vs-dark' ,
98
+ inherit : true ,
99
+ rules : [ ] ,
100
+ colors : {
101
+ 'editor.background' : '#00000000' ,
102
+ }
103
+ } ) ;
104
+
105
+ monaco ?. editor . defineTheme ( 'custom-light' , {
106
+ base : 'vs' ,
107
+ inherit : true ,
108
+ rules : [ ] ,
109
+ colors : {
110
+ 'editor.background' : '#ffffff00' ,
111
+ }
112
+ } ) ;
113
+
95
114
monaco . languages . typescript . typescriptDefaults . setCompilerOptions ( {
96
115
jsx : monaco . languages . typescript . JsxEmit . ReactJSX ,
97
116
jsxFactory : 'React.createElement' ,
@@ -131,16 +150,16 @@ export default function LiveCodeBlock({
131
150
</ Flex >
132
151
< Flex direction = "row" gap = "1" style = { { position : 'absolute' , right : '50%' , bottom : 0 } } p = "1" >
133
152
< Tooltip content = "Reset example" >
134
- < IconButton size = "1" radius = 'large' variant = 'outline ' onClick = { ( ) => {
153
+ < IconButton size = "1" radius = 'large' variant = 'soft ' onClick = { ( ) => {
135
154
setTsCode ( code )
136
155
updateCodeRef . current ?.( code )
137
156
} } >
138
- < ResetIcon width = { 12 } height = { 12 } />
157
+ < ResetIcon width = { 14 } height = { 14 } />
139
158
</ IconButton >
140
159
</ Tooltip >
141
160
142
161
< Tooltip content = { copyTooltip } open = { forceOpenCopyTooltip } >
143
- < IconButton size = "1" radius = 'large' variant = 'outline ' onClick = { ( ) => {
162
+ < IconButton size = "1" radius = 'large' variant = 'soft ' onClick = { ( ) => {
144
163
navigator . clipboard . writeText ( tsCode )
145
164
setCopyTooltip ( 'Copied!' )
146
165
setForceopenCopyTooltip ( true )
@@ -149,15 +168,15 @@ export default function LiveCodeBlock({
149
168
setForceopenCopyTooltip ( undefined )
150
169
} , 600 )
151
170
} } >
152
- < ClipboardCopyIcon width = { 12 } height = { 12 } />
171
+ < ClipboardCopyIcon width = { 14 } height = { 14 } />
153
172
</ IconButton >
154
173
</ Tooltip >
155
174
156
175
< Tooltip content = "Open in codesandbox.io" >
157
- < IconButton size = "1" radius = 'large' variant = 'outline ' onClick = { ( ) => {
176
+ < IconButton size = "1" radius = 'large' variant = 'soft ' onClick = { ( ) => {
158
177
createSandbox ( tsCode )
159
178
} } >
160
- < CubeIcon width = { 12 } height = { 12 } />
179
+ < CubeIcon width = { 14 } height = { 14 } />
161
180
</ IconButton >
162
181
</ Tooltip >
163
182
</ Flex >
0 commit comments