diff --git a/.husky/commit-msg b/.husky/commit-msg old mode 100644 new mode 100755 diff --git a/.husky/pre-push b/.husky/pre-push old mode 100644 new mode 100755 diff --git a/src/components/library/dropzone/Dropzone.tsx b/src/components/library/dropzone/Dropzone.tsx index d45c0bf..b34e44e 100644 --- a/src/components/library/dropzone/Dropzone.tsx +++ b/src/components/library/dropzone/Dropzone.tsx @@ -1,27 +1,14 @@ import type { ReactElement } from "react"; import { DocumentArrowUpIcon } from "@heroicons/react/24/solid"; import clsx from "clsx"; -import { useDropzone } from "react-dropzone"; +import { useDropzone } from "./UseDropzone"; export interface DropzoneProps { onDrop: (acceptedFiles: File[]) => void; } export function Dropzone({ onDrop }: DropzoneProps): ReactElement { - const { getRootProps, getInputProps, isDragActive, isDragAccept, isDragReject } = useDropzone({ - onDrop, - multiple: false, - accept: { - "image/*": [".png", ".jpg", ".jpeg", ".gif", ".webp"], - }, - }); - - function getBackgroundClass(): string { - if (isDragAccept) return "bg-success dark:text-black"; - if (isDragReject) return "bg-error dark:text-black"; - if (isDragActive) return "bg-base-300"; - return "bg-base-200"; - } + const { getRootProps, getInputProps, getBackgroundClass } = useDropzone(onDrop); return (
diff --git a/src/components/library/dropzone/UseDropzone.ts b/src/components/library/dropzone/UseDropzone.ts new file mode 100644 index 0000000..663ec04 --- /dev/null +++ b/src/components/library/dropzone/UseDropzone.ts @@ -0,0 +1,34 @@ +import { useDropzone as useReactDropzone } from "react-dropzone"; + +export function useDropzone(onDrop: (acceptedFiles: File[]) => void): { + getRootProps: (props?: Record) => Record; + getInputProps: (props?: Record) => Record; + isDragActive: boolean; + isDragAccept: boolean; + isDragReject: boolean; + getBackgroundClass: () => string; +} { + const { getRootProps, getInputProps, isDragActive, isDragAccept, isDragReject } = useReactDropzone({ + onDrop, + multiple: false, + accept: { + "image/*": [".png", ".jpg", ".jpeg", ".gif", ".webp"], + }, + }); + + function getBackgroundClass(): string { + if (isDragAccept) return "bg-success dark:text-black"; + if (isDragReject) return "bg-error dark:text-black"; + if (isDragActive) return "bg-base-300"; + return "bg-base-200"; + } + + return { + getRootProps, + getInputProps, + isDragActive, + isDragAccept, + isDragReject, + getBackgroundClass, + }; +} diff --git a/src/components/library/editor/toolbar/ToolbarTools.tsx b/src/components/library/editor/toolbar/ToolbarTools.tsx index 44103e8..e07df1e 100644 --- a/src/components/library/editor/toolbar/ToolbarTools.tsx +++ b/src/components/library/editor/toolbar/ToolbarTools.tsx @@ -18,7 +18,7 @@ export function ToolbarTools(): ReactElement { return (
-
+
-
+
-
+
-
+
-
+
-
+
diff --git a/src/components/library/editor/toolbar/ToolbarZoom.tsx b/src/components/library/editor/toolbar/ToolbarZoom.tsx index b9b9aa8..cebcd0d 100644 --- a/src/components/library/editor/toolbar/ToolbarZoom.tsx +++ b/src/components/library/editor/toolbar/ToolbarZoom.tsx @@ -7,16 +7,16 @@ export function ToolbarZoom(): ReactElement { return (
-
- -
-
-