@@ -8,7 +8,7 @@ import { Tokenizer, CacheableLineTokens } from './tokenizers/types';
8
8
import { Token } from './tokenizers/token' ;
9
9
import 'requestidlecallback' ;
10
10
import { rhythm } from '../../utils/typography' ;
11
- import { padding , Side , resets , darkMode , animations , minWidth , variables , masked } from '../../styles/utils' ;
11
+ import { padding , Side , resets , darkMode , animations , minWidth , variables , masked , margin } from '../../styles/utils' ;
12
12
import { Icon } from '../Icon' ;
13
13
14
14
function createValueFromString ( text : string ) : Value {
@@ -139,16 +139,19 @@ const loadingIcon = (
139
139
const editIcon = < Icon css = { iconStyles } src = { require ( '../icons/pencil.svg' ) } alt = "Edit" /> ;
140
140
const resetIcon = < Icon css = { iconStyles } src = { require ( '../icons/reset.svg' ) } alt = "Reset" /> ;
141
141
const containerStyles = css ( [
142
- padding ( 0.5 , Side . Vertical ) ,
142
+ padding ( 0.5 ) ,
143
+ margin ( - 0.5 , Side . Horizontal ) ,
143
144
{
144
145
position : 'relative' ,
145
146
fontSize : '1rem' ,
146
- ':hover > button ' : {
147
- opacity : 1 ,
147
+ ':focus-within ' : {
148
+ background : 'var(--background-alt)' ,
148
149
} ,
149
150
...minWidth ( variables . sizes . bigEnough , [
151
+ margin ( 0 , Side . Horizontal ) ,
150
152
padding ( 1 , Side . Left ) ,
151
153
padding ( 2 , Side . Right ) ,
154
+ { borderRadius : 8 } ,
152
155
] ) ,
153
156
} ,
154
157
] ) ;
@@ -200,31 +203,33 @@ export function InteractiveCodeBlock<
200
203
} , [ props . isLoading ] ) ;
201
204
202
205
return (
203
- < pre css = { containerStyles } >
204
- < Editor
205
- ref = { editorRef }
206
- value = { state }
207
- onChange = { ( { value, operations } ) => {
208
- if ( props . onChange ) {
209
- props . onChange ( getFullText ( value ) , operations ) ;
210
- }
206
+ < div css = { { position : 'relative' , ':hover > button' : { opacity : 1 } } } >
207
+ < pre css = { containerStyles } >
208
+ < Editor
209
+ ref = { editorRef }
210
+ value = { state }
211
+ onChange = { ( { value, operations } ) => {
212
+ if ( props . onChange ) {
213
+ props . onChange ( getFullText ( value ) , operations ) ;
214
+ }
211
215
212
- setState ( value ) ;
213
- cancelIdleCallback ( callbackId ) ;
214
- callbackId = requestIdleCallback ( ( ) => {
215
- const x = value . set ( 'decorations' , decorateDocument ( value . document ) ) as Value ;
216
- setState ( x ) ;
217
- } ) ;
218
- } }
219
- plugins = { plugins }
220
- decorateNode = { decorateLineSync }
221
- className = { props . className }
222
- css = { editorStyles }
223
- spellCheck = { false }
224
- autoCorrect = { false }
225
- readOnly = { props . readOnly }
226
- style = { { wordWrap : 'normal' , whiteSpace : 'pre' } }
227
- />
216
+ setState ( value ) ;
217
+ cancelIdleCallback ( callbackId ) ;
218
+ callbackId = requestIdleCallback ( ( ) => {
219
+ const x = value . set ( 'decorations' , decorateDocument ( value . document ) ) as Value ;
220
+ setState ( x ) ;
221
+ } ) ;
222
+ } }
223
+ plugins = { plugins }
224
+ decorateNode = { decorateLineSync }
225
+ className = { props . className }
226
+ css = { editorStyles }
227
+ spellCheck = { false }
228
+ autoCorrect = { false }
229
+ readOnly = { props . readOnly }
230
+ style = { { wordWrap : 'normal' , whiteSpace : 'pre' } }
231
+ />
232
+ </ pre >
228
233
{ buttonIcon ? (
229
234
< Button
230
235
css = { { opacity : buttonIcon === resetIcon ? 1 : 0 } }
@@ -243,7 +248,7 @@ export function InteractiveCodeBlock<
243
248
{ buttonIcon }
244
249
</ Button >
245
250
) : null }
246
- </ pre >
251
+ </ div >
247
252
) ;
248
253
}
249
254
0 commit comments