@@ -12,6 +12,7 @@ import {
12
12
import { ChevronRightIcon } from "@heroicons/react/24/outline" ;
13
13
import { XMarkIcon } from "@heroicons/react/24/outline" ;
14
14
import { DocumentIcon } from "@heroicons/react/24/outline" ;
15
+ import { PaperClipIcon } from "@heroicons/react/24/outline" ;
15
16
16
17
import { useUploadContext } from "@/contexts/UploadContext" ;
17
18
@@ -75,10 +76,6 @@ const UploadInterface = () => {
75
76
setTimeout ( ( ) => submitButtonRef . current ?. focus ( ) , 50 ) ;
76
77
} ;
77
78
78
- const onLocalFileUploadClick = ( ) => {
79
- fileInputRef . current ?. click ( ) ;
80
- } ;
81
-
82
79
const onLocalFileUploadInputChange = ( e : ChangeEvent < HTMLInputElement > ) => {
83
80
if ( e . target . files ?. length ) {
84
81
onLocalFileUpload ( e . target . files [ 0 ] ) ;
@@ -177,62 +174,69 @@ const UploadInterface = () => {
177
174
) }
178
175
179
176
< form
180
- className = "relative flex w-full flex-row justify-between rounded-lg border border-gray-200 bg-white p-4 shadow-md"
177
+ className = "relative flex w-full flex-row items-center justify-between rounded-lg border border-gray-200 bg-white p-4 shadow-md"
181
178
id = "upload-form"
182
179
onSubmit = { onSubmit }
183
180
>
184
- { ! isLocalUpload && ! file && (
185
- < input
186
- type = "url"
187
- ref = { urlInputRef }
188
- onChange = { onInputChange }
189
- className = "w-full border-none bg-transparent pr-3 text-lg outline-none"
190
- placeholder = {
191
- ! isLocalUpload
192
- ? "Drop your OpenAPI 3.x file or enter your OpenAPI file URL here"
193
- : ""
194
- }
195
- aria-label = "Enter OpenAPI 3.x file URL here"
196
- disabled = { ! ! file }
197
- />
198
- ) }
199
-
200
- < input
201
- ref = { fileInputRef }
202
- onChange = { onLocalFileUploadInputChange }
203
- className = "hidden h-0 w-0"
204
- type = "file"
205
- name = "drag-upload"
206
- />
207
-
208
- { isLocalUpload && (
209
- < button
210
- onClick = { onClear }
211
- className = "flex items-center rounded-lg bg-gray-200 p-2 text-lg hover:bg-gray-300"
212
- >
213
- < DocumentIcon
214
- height = { 24 }
215
- width = { 24 }
216
- className = "mr-1 text-gray-900"
217
- />
218
- < span className = "max-w-[170px] overflow-hidden whitespace-nowrap md:max-w-[500px]" >
219
- { file ?. name }
220
- </ span >
221
- < XMarkIcon height = { 24 } width = { 24 } className = "ml-3 text-gray-900" />
222
- </ button >
223
- ) }
181
+ < div className = "flex w-full items-center gap-2" >
182
+ { ! isLocalUpload && ! file && (
183
+ < label
184
+ title = "Select OpenAPI file"
185
+ role = "button"
186
+ className = "icon-button p-4 hover:bg-gray-200"
187
+ tabIndex = { 0 }
188
+ >
189
+ < PaperClipIcon height = { 24 } width = { 24 } />
190
+ < input
191
+ ref = { fileInputRef }
192
+ onChange = { onLocalFileUploadInputChange }
193
+ className = "hidden h-0 w-0"
194
+ type = "file"
195
+ id = "drag-upload"
196
+ />
197
+ </ label >
198
+ ) }
224
199
225
- < div className = "flex h-[44px]" >
226
- { ! isLocalUpload && ! file && ! isValidUrlInput && (
200
+ { ! isLocalUpload ? (
201
+ < div className = "flex-1" >
202
+ < input
203
+ autoFocus
204
+ type = "url"
205
+ ref = { urlInputRef }
206
+ onChange = { onInputChange }
207
+ className = "w-full border-none bg-transparent pr-3 text-lg outline-none"
208
+ placeholder = {
209
+ ! isLocalUpload
210
+ ? "Drop your OpenAPI 3.x file or enter your OpenAPI file URL here"
211
+ : ""
212
+ }
213
+ aria-label = "Enter OpenAPI 3.x file URL here"
214
+ disabled = { ! ! file }
215
+ />
216
+ </ div >
217
+ ) : (
227
218
< button
228
- onClick = { onLocalFileUploadClick }
229
- type = "button"
230
- className = "mr-2 whitespace-nowrap rounded-lg border border-gray-500 bg-transparent px-3 py-2 text-gray-500 transition-colors hover:border-gray-900 hover:bg-gray-900 hover:text-white"
219
+ onClick = { onClear }
220
+ className = "flex items-center rounded-lg bg-gray-200 p-2 text-lg hover:bg-gray-300"
231
221
>
232
- Select a file
222
+ < DocumentIcon
223
+ height = { 24 }
224
+ width = { 24 }
225
+ className = "mr-1 text-gray-900"
226
+ />
227
+ < span className = "max-w-[170px] overflow-hidden whitespace-nowrap md:max-w-[500px]" >
228
+ { file ?. name }
229
+ </ span >
230
+ < XMarkIcon
231
+ height = { 24 }
232
+ width = { 24 }
233
+ className = "ml-3 text-gray-900"
234
+ />
233
235
</ button >
234
236
) }
237
+ </ div >
235
238
239
+ < div className = "flex h-[44px]" >
236
240
{ isValidUrlInput && (
237
241
< button
238
242
className = "icon-button mr-2 bg-gray-200 hover:bg-gray-300"
0 commit comments