@@ -136,14 +136,23 @@ export default function Page() {
136136 return ;
137137 }
138138
139+ const totalSize = allFiles . reduce (
140+ ( sum , f ) => sum + f . size ,
141+ 0 ,
142+ ) ;
143+ if ( totalSize > maxFileSize ) {
144+ toast . error ( "The total upload size exceeds 5MB." , { id : toastId } ) ;
145+ return ;
146+ }
147+
139148 const invalidFiles = acceptedFiles . filter (
140149 ( file ) =>
141150 file . size > maxFileSize || ! allowedFileTypes . includes ( file . type ) ,
142151 ) ;
143152
144153 if ( invalidFiles . length > 0 ) {
145154 toast . error (
146- "Some files are invalid. Make sure each is under 5MB and of allowed types (PDF, JPEG, PNG, GIF)." ,
155+ "Some files are invalid. Make sure the total size is below 5MB and files are of allowed types (PDF, JPEG, PNG, GIF)." ,
147156 { id : toastId } ,
148157 ) ;
149158 return ;
@@ -375,44 +384,52 @@ export default function Page() {
375384 multiple = { true }
376385 >
377386 { ( { getRootProps, getInputProps, isDragActive } ) => {
378- const pdfUploaded = files . some ( f => f . type === "application/pdf" ) ;
379- return (
380- < div
381- className = { `relative h-20 w-20 flex-shrink-0 touch-none group${
382- isDragActive || isGlobalDragging
383- ? "border-2 border-solid border-[#6D28D9]"
384- : ""
385- } `}
386- { ...( ! pdfUploaded ? getRootProps ( ) : { } ) }
387- >
388- { ! pdfUploaded && < input { ...getInputProps ( ) } /> }
389- < div className = { `absolute left-4 top-4 h-16 w-16 rounded-2xl bg-violet-950 ${ pdfUploaded ? "text-gray-500 cursor-not-allowed" : "text-white cursor-pointer" } ` } />
390- < div className = "absolute left-0 top-0 h-10 w-10 rounded-[20px] bg-violet-950" />
391- < div className = "absolute left-1 top-1 flex h-8 w-8 items-center rounded-[20px] bg-black/50" />
392- < div className = { `absolute left-9 top-9 text-2xl ${ pdfUploaded ? "text-gray-500 cursor-not-allowed" : "text-white cursor-pointer" } ` }
393- >
394- < div className = { `absolute text-2xl ${ pdfUploaded ? "text-gray-500 cursor-not-allowed" : "text-white cursor-pointer" } ` }
395- >
396- < FiPlus className = "h-7 w-7" />
397-
398- { pdfUploaded && ( < div className = "absolute left-12 top-1/2 -translate-y-1/2 whitespace-nowrap rounded-md bg-gradient-to-r from-indigo-900 to-violet-900 px-3 py-1 text-xs text-white shadow-lg opacity-0 group-hover:opacity-100 transition-all duration-300 group-hover:translate-x-1" >
399- Only one PDF file is permitted.
387+ const pdfUploaded = files . some (
388+ ( f ) => f . type === "application/pdf" ,
389+ ) ;
390+ return (
391+ < div
392+ className = { `relative h-20 w-20 flex-shrink-0 touch-none group${
393+ isDragActive || isGlobalDragging
394+ ? "border-2 border-solid border-[#6D28D9]"
395+ : ""
396+ } `}
397+ { ...( ! pdfUploaded ? getRootProps ( ) : { } ) }
398+ >
399+ { ! pdfUploaded && < input { ...getInputProps ( ) } /> }
400+ < div
401+ className = { `absolute left-4 top-4 h-16 w-16 rounded-2xl bg-[#A78BFA] dark:bg-violet-950 ${ pdfUploaded ? "cursor-not-allowed text-gray-500" : "cursor-pointer text-white" } ` }
402+ />
403+ < div className = "absolute left-0 top-0 h-10 w-10 rounded-[20px] bg-[#A78BFA] dark:bg-violet-950" />
404+
405+ < div className = "absolute left-1 top-1 flex h-8 w-8 items-center rounded-[20px] bg-black/30 dark:bg-black/50" />
406+ < div
407+ className = { `absolute left-9 top-9 text-2xl ${ pdfUploaded ? "cursor-not-allowed text-gray-500" : "cursor-pointer text-white" } ` }
408+ >
409+ < div
410+ className = { `absolute text-2xl ${ pdfUploaded ? "cursor-not-allowed text-gray-500" : "cursor-pointer text-white" } ` }
411+ >
412+ < FiPlus className = "h-7 w-7" />
413+
414+ { pdfUploaded && (
415+ < div className = "absolute left-12 top-1/2 -translate-y-1/2 whitespace-nowrap rounded-md bg-gradient-to-r from-indigo-900 to-violet-900 px-3 py-1 text-xs text-white opacity-0 shadow-lg transition-all duration-300 group-hover:translate-x-1 group-hover:opacity-100" >
416+ Only one PDF file is permitted.
417+ </ div >
418+ ) }
419+ </ div >
420+ </ div >
421+ < div className = "absolute left-4 top-3 text-xs font-semibold text-white" >
422+ { previews . length }
400423 </ div >
401- ) }
402- </ div >
403- </ div >
404- < div className = "absolute left-4 top-3 text-xs font-semibold text-white" >
405- { previews . length }
406424 </ div >
407- </ div >
408425 ) ;
409426 } }
410427 </ Dropzone >
411428 ) }
412429 { previews . length > 0 && (
413430 < section className = "mt-6 flex w-full flex-col items-center" >
414431 < div className = "flex w-max gap-4" >
415- < div className = "scrollbar-hide flex w-[80vw] max-w-4xl flex-col justify-between overflow-x-auto overflow-y-hidden rounded-[40px] border-[6px] border-indigo-900 bg-indigo-900/10 p-4 sm:p-6 md:w-max md:p-8" >
432+ < div className = "scrollbar-hide flex w-[80vw] max-w-4xl flex-col justify-between overflow-x-auto overflow-y-hidden rounded-[40px] border-[6px] border-[#A78BFA] bg-indigo-900/10 p-4 dark:border-indigo-900 sm:p-6 md:w-max md:p-8" >
416433 < DndContext
417434 sensors = { sensors }
418435 collisionDetection = { closestCenter }
@@ -493,7 +510,7 @@ export default function Page() {
493510 < Button
494511 onClick = { handleUpload }
495512 disabled = { isUploading || files . length === 0 }
496- className = "mt-8 rounded-[40px] bg-violet-950 px-8 py-3 text-xl text-white hover:bg-violet-800"
513+ className = "mt-8 rounded-[40px] bg-[#A78BFA] px-8 py-3 text-xl text-white hover:bg-[#8B5CF6] dark:bg-violet-950 dark: hover:bg-violet-800"
497514 >
498515 { isUploading ? "Uploading..." : "Upload" }
499516 </ Button >
0 commit comments