Skip to content

Commit 79a08ed

Browse files
authored
Use attachment icon (#220)
1 parent aa2f624 commit 79a08ed

File tree

2 files changed

+56
-51
lines changed

2 files changed

+56
-51
lines changed

apps/web/src/app/globals.css

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
html {
66
background-color: #f8f8f8;
7+
color: #333;
78
}
89

910
main,

apps/web/src/components/UploadInterface/index.tsx

+55-51
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
import { ChevronRightIcon } from "@heroicons/react/24/outline";
1313
import { XMarkIcon } from "@heroicons/react/24/outline";
1414
import { DocumentIcon } from "@heroicons/react/24/outline";
15+
import { PaperClipIcon } from "@heroicons/react/24/outline";
1516

1617
import { useUploadContext } from "@/contexts/UploadContext";
1718

@@ -75,10 +76,6 @@ const UploadInterface = () => {
7576
setTimeout(() => submitButtonRef.current?.focus(), 50);
7677
};
7778

78-
const onLocalFileUploadClick = () => {
79-
fileInputRef.current?.click();
80-
};
81-
8279
const onLocalFileUploadInputChange = (e: ChangeEvent<HTMLInputElement>) => {
8380
if (e.target.files?.length) {
8481
onLocalFileUpload(e.target.files[0]);
@@ -177,62 +174,69 @@ const UploadInterface = () => {
177174
)}
178175

179176
<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"
181178
id="upload-form"
182179
onSubmit={onSubmit}
183180
>
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+
)}
224199

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+
) : (
227218
<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"
231221
>
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+
/>
233235
</button>
234236
)}
237+
</div>
235238

239+
<div className="flex h-[44px]">
236240
{isValidUrlInput && (
237241
<button
238242
className="icon-button mr-2 bg-gray-200 hover:bg-gray-300"

0 commit comments

Comments
 (0)