Skip to content

Commit 1446433

Browse files
fix: move plus button outside the preview area
1 parent a1ffdcc commit 1446433

1 file changed

Lines changed: 58 additions & 63 deletions

File tree

src/app/upload/page.tsx

Lines changed: 58 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -97,33 +97,36 @@ export default function Page() {
9797
(file) => file.type === "application/pdf",
9898
);
9999

100-
if (isNewPdf && acceptedFiles.length > 1) {
101-
toast.error("Only one PDF can be uploaded at a time.", {
102-
id: toastId,
103-
});
104-
return;
105-
}
100+
if (isNewPdf && acceptedFiles.length > 1) {
101+
toast.error("Only one PDF can be uploaded at a time.", {
102+
id: toastId,
103+
});
104+
return;
105+
}
106106

107-
if (isNewPdf && hasExistingImages) {
108-
toast.error("PDFs cannot be uploaded together with images.", {
109-
id: toastId,
110-
});
111-
return;
112-
}
107+
if (isNewPdf && hasExistingImages) {
108+
toast.error("PDFs cannot be uploaded together with images.", {
109+
id: toastId,
110+
});
111+
return;
112+
}
113113

114-
if (isNewPdf && hasExistingPdf) {
115-
toast.error("Only one PDF is allowed. You’ve already uploaded a PDF.", {
116-
id: toastId,
117-
});
118-
return;
119-
}
114+
if (isNewPdf && hasExistingPdf) {
115+
toast.error("Only one PDF is allowed. You’ve already uploaded a PDF.", {
116+
id: toastId,
117+
});
118+
return;
119+
}
120120

121-
if (!isNewPdf && hasExistingPdf) {
122-
toast.error("Images cannot be uploaded after a PDF. Upload them separately.", {
123-
id: toastId,
124-
});
125-
return;
126-
}
121+
if (!isNewPdf && hasExistingPdf) {
122+
toast.error(
123+
"Images cannot be uploaded after a PDF. Upload them separately.",
124+
{
125+
id: toastId,
126+
},
127+
);
128+
return;
129+
}
127130

128131
const allFiles = [...files, ...acceptedFiles];
129132
if (allFiles.length > 5) {
@@ -282,7 +285,6 @@ if (!isNewPdf && hasExistingPdf) {
282285

283286
clearAllFiles();
284287
} catch (error) {
285-
286288
} finally {
287289
setIsUploading(false);
288290
}
@@ -291,7 +293,7 @@ if (!isNewPdf && hasExistingPdf) {
291293
return (
292294
<main className="mx-auto max-w-3xl px-4 py-8">
293295
<div className="flex h-[calc(100vh-90px)] flex-col justify-center px-6 font-play">
294-
<div className="2xl:my-15 flex flex-col items-center">
296+
<div className="2xl:my-15 flex flex-col ">
295297
{previews.length === 0 && (
296298
<fieldset className="mb-4 w-full max-w-md rounded-lg border-2 border-gray-300 p-4 pr-8">
297299
<div className="flex w-full flex-col 2xl:gap-y-4">
@@ -346,9 +348,9 @@ if (!isNewPdf && hasExistingPdf) {
346348
</div>
347349
<div className="mt-4 text-sm text-gray-500">
348350
Note: Uploaded papers are first reviewed by our team
349-
before appearing on the website. If your paper doesn&apos;t
350-
show up immediately, please be patient, it&apos;s likely
351-
still under review.
351+
before appearing on the website. If your paper
352+
doesn&apos;t show up immediately, please be patient,
353+
it&apos;s likely still under review.
352354
</div>
353355
</section>
354356
)}
@@ -362,6 +364,33 @@ if (!isNewPdf && hasExistingPdf) {
362364
</fieldset>
363365
)}
364366

367+
<Dropzone
368+
onDrop={onDrop}
369+
accept={{
370+
"image/*": [".jpeg", ".jpg", ".png", ".gif", ".bmp", ".webp"],
371+
"application/pdf": [".pdf"],
372+
}}
373+
multiple={true}
374+
>
375+
{({ getRootProps, getInputProps }) => (
376+
<div
377+
className="relative h-20 w-20 flex-shrink-0 cursor-pointer"
378+
{...getRootProps()}
379+
>
380+
<input {...getInputProps()} />
381+
<div className="absolute left-4 top-4 h-16 w-16 rounded-2xl bg-violet-950" />
382+
<div className="absolute left-0 top-0 h-10 w-10 rounded-[20px] bg-violet-950" />
383+
<div className="absolute left-1 top-1 flex h-8 w-8 items-center rounded-[20px] bg-black/50" />
384+
<div className="absolute left-9 top-9 text-2xl text-white">
385+
<FiPlus className="h-7 w-7" />
386+
</div>
387+
<div className="absolute left-4 top-3 text-xs font-semibold text-white">
388+
{previews.length}
389+
</div>
390+
</div>
391+
)}
392+
</Dropzone>
393+
365394
{previews.length > 0 && (
366395
<section className="mt-6 flex w-full flex-col items-center">
367396
<div className="flex w-max gap-4">
@@ -425,40 +454,6 @@ if (!isNewPdf && hasExistingPdf) {
425454
</div>
426455
</SortablePreview>
427456
))}
428-
429-
<Dropzone
430-
onDrop={onDrop}
431-
accept={{
432-
"image/*": [
433-
".jpeg",
434-
".jpg",
435-
".png",
436-
".gif",
437-
".bmp",
438-
".webp",
439-
],
440-
"application/pdf": [".pdf"],
441-
}}
442-
multiple={true}
443-
>
444-
{({ getRootProps, getInputProps }) => (
445-
<div
446-
className="relative h-20 w-20 flex-shrink-0 cursor-pointer"
447-
{...getRootProps()}
448-
>
449-
<input {...getInputProps()} />
450-
<div className="absolute left-4 top-4 h-16 w-16 rounded-2xl bg-violet-950" />
451-
<div className="absolute left-0 top-0 h-10 w-10 rounded-[20px] bg-violet-950" />
452-
<div className="absolute left-1 top-1 flex h-8 w-8 items-center rounded-[20px] bg-black/50" />
453-
<div className="absolute left-9 top-9 text-2xl text-white">
454-
<FiPlus className="h-7 w-7" />
455-
</div>
456-
<div className="absolute left-4 top-3 text-xs font-semibold text-white">
457-
{previews.length}
458-
</div>
459-
</div>
460-
)}
461-
</Dropzone>
462457
</div>{" "}
463458
{previews.length > 2 && (
464459
<div className="text-l mt-4 text-right text-white/50">

0 commit comments

Comments
 (0)