diff --git a/package-lock.json b/package-lock.json index f0bf095..fe26739 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48,6 +48,7 @@ "react-copy-to-clipboard": "^5.1.0", "react-datepicker": "^4.7.0", "react-dom": "^18.0.0", + "react-file-drop": "^3.1.4", "react-hook-form": "^7.30.0", "react-icons": "^4.3.1", "react-loader-spinner": "^6.0.0-0", @@ -58899,6 +58900,14 @@ "resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.0.tgz", "integrity": "sha512-rtGImPZ0YyLrscKI9xTpV8psd6I8VAtjKCzQDlzyDvqJA8XOW78TXYQwNRNd8g8JZnDu8q9Fu/1v4HPAVwVdHA==" }, + "node_modules/react-file-drop": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/react-file-drop/-/react-file-drop-3.1.4.tgz", + "integrity": "sha512-83633H9CK/IoBXBl77qBS36K0pGb5sQn6c1rc54nxWYkAbM/zo+xuxFnwUDib4Yh+xVmWBZeTAnY5ZSN2PmUCQ==", + "dependencies": { + "prop-types": "^15.7.2" + } + }, "node_modules/react-helmet-async": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/react-helmet-async/-/react-helmet-async-1.3.0.tgz", @@ -111144,6 +111153,14 @@ "resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.0.tgz", "integrity": "sha512-rtGImPZ0YyLrscKI9xTpV8psd6I8VAtjKCzQDlzyDvqJA8XOW78TXYQwNRNd8g8JZnDu8q9Fu/1v4HPAVwVdHA==" }, + "react-file-drop": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/react-file-drop/-/react-file-drop-3.1.4.tgz", + "integrity": "sha512-83633H9CK/IoBXBl77qBS36K0pGb5sQn6c1rc54nxWYkAbM/zo+xuxFnwUDib4Yh+xVmWBZeTAnY5ZSN2PmUCQ==", + "requires": { + "prop-types": "^15.7.2" + } + }, "react-helmet-async": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/react-helmet-async/-/react-helmet-async-1.3.0.tgz", diff --git a/package.json b/package.json index cf9094f..76bfc50 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "react-copy-to-clipboard": "^5.1.0", "react-datepicker": "^4.7.0", "react-dom": "^18.0.0", + "react-file-drop": "^3.1.4", "react-hook-form": "^7.30.0", "react-icons": "^4.3.1", "react-loader-spinner": "^6.0.0-0", diff --git a/src/Components/Inputs/FilesInput/DropInput.jsx b/src/Components/Inputs/FilesInput/DropInput.jsx new file mode 100644 index 0000000..64ac918 --- /dev/null +++ b/src/Components/Inputs/FilesInput/DropInput.jsx @@ -0,0 +1,60 @@ +import { useToggle } from "@react-hookz/web"; +import React from "react"; +import { FileDrop } from "react-file-drop"; + +export default function DropInput({ + value: files, + onChange, + emptyContent, + draggingContent, + hasFilesContent, + height, + multiple = false, + allowedType = "*", + classes = {}, +}) { + const [isDragging, toggleDrag] = useToggle(false); + const fileInputRef = React.useRef(null); + + const onAddFiles = (_files) => { + onChange(_files); + // do something with your files... + }; + + const uploadClick = () => { + fileInputRef.current.click(); + }; + + const status = isDragging ? "dragging" : files ? "has-files" : "empty"; + + return ( +
+ or {" "} +
+ > +); + +const defaultDraggingContent =Drop your files here ⬇⬇⬇
; + +const defaultHasFilesContent = ( +Files Uploaded Successfully!!
+); \ No newline at end of file diff --git a/src/features/Posts/Components/Comments/types.ts b/src/features/Posts/Components/Comments/types.ts index b6e84cb..1d563f1 100644 --- a/src/features/Posts/Components/Comments/types.ts +++ b/src/features/Posts/Components/Comments/types.ts @@ -12,4 +12,5 @@ export interface Comment { export interface CommentWithReplies extends Comment { replies: CommentWithReplies[] -} \ No newline at end of file +} +