File tree 6 files changed +24
-8
lines changed
gitbook/src/components/DocumentView/OpenAPI
6 files changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,8 @@ async function OpenAPIBody(props: BlockProps<DocumentBlockSwagger>) {
54
54
icons : {
55
55
chevronDown : < Icon icon = "chevron-down" /> ,
56
56
chevronRight : < Icon icon = "chevron-right" /> ,
57
+ edit : < Icon icon = "edit" /> ,
58
+ clear : < Icon icon = "x" />
57
59
} ,
58
60
CodeBlock : PlainCodeBlock ,
59
61
defaultInteractiveOpened : context . mode === 'print' ,
Original file line number Diff line number Diff line change 57
57
/** URL */
58
58
59
59
.openapi-url {
60
- @apply font-mono text-sm text-dark/8 dark:text-light/8;
60
+ @apply flex items-center font-mono text-sm text-dark/8 dark:text-light/8;
61
61
}
62
62
63
63
.openapi-url-var {
365
365
@apply mb-0;
366
366
}
367
367
368
- .openapi-server-button {
369
- @apply disabled:opacity-5;
368
+ .openapi-select-button ,
369
+ .openapi-edit-button {
370
+ @apply p-0.5 inline-flex text-dark/6 dark:text-light/6 hover:opacity-8;
371
+ }
372
+
373
+ .openapi-edit-button { @apply p-0.5 ml-4 size-4; }
374
+
375
+ .openapi-edit-button > * {
376
+ @apply size-full;
377
+ }
378
+
379
+ .openapi-select-button {
380
+ @apply leading-[1cap ] disabled:opacity-5;
370
381
}
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ export async function OpenAPIOperation(props: {
37
37
{ operation . description ? (
38
38
< Markdown className = "openapi-description" source = { operation . description } />
39
39
) : null }
40
- < div className = "openapi-target" >
40
+ < div className = "openapi-target flex items-center " >
41
41
< span
42
42
className = { classNames (
43
43
'openapi-method' ,
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ export function ServerURLForm(props: {
49
49
} ) ;
50
50
}
51
51
52
+ const isEditable = servers . length > 1 || server . variables ;
52
53
return (
53
54
< form ref = { formRef } onSubmit = { e => { e . preventDefault ( ) ; updateServerVariables ( new FormData ( e . currentTarget ) ) ; } } className = "contents" >
54
55
< fieldset disabled = { ctx ?. isPending } className = "contents" >
@@ -61,11 +62,11 @@ export function ServerURLForm(props: {
61
62
onChange = { switchServer }
62
63
/>
63
64
) : null }
64
- < button className = 'inline-flex pl-4 ' onClick = { ( ) => {
65
+ { isEditable ? < button className = 'openapi-edit-button ml-2 ' onClick = { ( ) => {
65
66
const state = { ...ctx ?. state } ;
66
67
delete state . edit ;
67
68
update ( { server : `${ serverIndex } ` , ...state , ...( ctx ?. state ?. edit ? undefined : { edit : 'true' } ) } ) ;
68
- } } aria-label = { ctx ?. state ?. edit ? "Clear" : "Edit" } > { ctx ?. state ?. edit ? 'X' : 'Edit' } </ button >
69
+ } } title = { ctx ?. state ?. edit ? undefined : "Try different server options" } aria-label = { ctx ?. state ?. edit ? "Clear" : "Edit" } > { ctx ?. state ?. edit ? context . icons . clear : context . icons . edit } </ button > : null }
69
70
</ fieldset >
70
71
</ form >
71
72
) ;
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ export function ServerSelector(props: {
18
18
< span className = "inline-flex pl-4 gap-2" >
19
19
< input type = "hidden" value = { `${ index } ` } name = "server" />
20
20
< button
21
- className = "openapi-server -button"
21
+ className = "openapi-select -button"
22
22
disabled = { index === 0 }
23
23
onClick = { ( e ) => {
24
24
e . preventDefault ( ) ;
@@ -31,7 +31,7 @@ export function ServerSelector(props: {
31
31
◀
32
32
</ button >
33
33
< button
34
- className = "openapi-server -button"
34
+ className = "openapi-select -button"
35
35
disabled = { index >= servers . length - 1 }
36
36
onClick = { ( e ) => {
37
37
e . preventDefault ( ) ;
Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ export interface OpenAPIClientContext {
8
8
icons : {
9
9
chevronDown : React . ReactNode ;
10
10
chevronRight : React . ReactNode ;
11
+ edit : React . ReactNode ;
12
+ clear : React . ReactNode ;
11
13
} ;
12
14
13
15
/**
You can’t perform that action at this time.
0 commit comments