diff --git a/src/pages/gallery/components/AddCollection.tsx b/src/pages/gallery/components/AddCollection.tsx index 64d386517..6c73876e4 100644 --- a/src/pages/gallery/components/AddCollection.tsx +++ b/src/pages/gallery/components/AddCollection.tsx @@ -1,9 +1,8 @@ import React, { useState } from "react"; import { Card } from "react-bootstrap"; -import Dropzone from "react-dropzone"; import styled from "styled-components"; -import { DropDiv } from "./CollectionDropZone"; import CreateCollection from "./CreateCollection"; +import DropzoneWrapper from "./DropzoneWrapper"; const ImageContainer = styled.div` min-height: 192px; @@ -24,46 +23,26 @@ export default function AddCollection(props) { const [acceptedFiles, setAcceptedFiles] = useState(); const [createCollectionView, setCreateCollectionView] = useState(false); - const { children, closeUploadModal, showUploadModal, ...rest } = props; + const { closeUploadModal, showUploadModal, ...rest } = props; const createCollection = (acceptedFiles) => { setAcceptedFiles(acceptedFiles); setCreateCollectionView(true); }; - + const children = ( + + + + Create New Album + + ); return ( <> - - {({ - getRootProps, - getInputProps, - isDragActive, - isDragAccept, - isDragReject, - }) => { - return ( - - - - + - Create New Album - - - ); - }} - + children={children} + /> { - if (props.isDragAccept) { - return '#00e676'; - } - if (props.isDragReject) { - return '#ff1744'; - } - if (props.isDragActive) { - return '#2196f3'; - } -}; - -export const enableBorder = (props) => (props.isDragActive ? 'dashed' : 'none'); - -export const DropDiv = styled.div` - width:200px; - margin:5px; - height:230px; - color:black; - border-width: 2px; - border-radius: 2px; - border-color: ${(props) => getColor(props)}; - border-style: ${(props) => enableBorder(props)}; - outline: none; - transition: border 0.24s ease-in-out; -`; function CollectionDropZone({ children, @@ -53,34 +26,12 @@ function CollectionDropZone({ setProgressView(false); } return ( - - {({ - getRootProps, - getInputProps, - isDragActive, - isDragAccept, - isDragReject, - }) => { - return ( - - - {children} - - ); - }} - + /> ); }; diff --git a/src/pages/gallery/components/DropzoneWrapper.tsx b/src/pages/gallery/components/DropzoneWrapper.tsx new file mode 100644 index 000000000..48f2c607f --- /dev/null +++ b/src/pages/gallery/components/DropzoneWrapper.tsx @@ -0,0 +1,64 @@ +import React from 'react'; +import Dropzone from 'react-dropzone'; +import styled from 'styled-components'; + +export const getColor = (props) => { + if (props.isDragAccept) { + return '#00e676'; + } + if (props.isDragReject) { + return '#ff1744'; + } + if (props.isDragActive) { + return '#2196f3'; + } +}; + +export const enableBorder = (props) => (props.isDragActive ? 'dashed' : 'none'); + +export const DropDiv = styled.div` + width:200px; + margin:5px; + height:230px; + color:black; + border-width: 2px; + border-radius: 2px; + border-color: ${(props) => getColor(props)}; + border-style: ${(props) => enableBorder(props)}; + outline: none; + transition: border 0.24s ease-in-out; +`; + +export function DropzoneWrapper(props) { + const { children, ...callbackProps } = props + return ( + + {({ + getRootProps, + getInputProps, + isDragActive, + isDragAccept, + isDragReject, + }) => { + return ( + + + {children} + + ); + }} + + ); +}; + +export default DropzoneWrapper;