seperate DropZone component for collections

This commit is contained in:
Abhinav-grd 2021-01-06 12:47:56 +05:30
parent 87bf367c90
commit b7e0ccd900
3 changed files with 20 additions and 48 deletions

View file

@ -19,24 +19,23 @@ const enableBorder = (props) => (props.isDragActive ? 'dashed' : 'none');
const DropDiv = styled.div` const DropDiv = styled.div`
flex: 1; flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: row;
align-items: center;
border-width: 2px; border-width: 2px;
border-radius: 2px; border-radius: 2px;
height:10px;
width:30%;
border-color: ${(props) => getColor(props)}; border-color: ${(props) => getColor(props)};
border-style: ${(props) => enableBorder(props)}; border-style: ${(props) => enableBorder(props)};
outline: none; outline: none;
transition: border 0.24s ease-in-out; transition: border 0.24s ease-in-out;
`; `;
const FileUpload = ({ const CollectionDropZone = ({
children, children,
noClick = null, closeModal,
closeModal = null, collectionLatestFile,
showModal = null, noDragEventsBubbling,
collectionLatestFile = null, showProgress,
noDragEventsBubbling = null,
showProgress = null,
}) => { }) => {
return ( return (
<> <>
@ -46,9 +45,6 @@ const FileUpload = ({
closeModal(); closeModal();
showProgress(); showProgress();
}} }}
noClick={noClick}
onDragOver={showModal}
onDragLeave={closeModal}
noDragEventsBubbling={noDragEventsBubbling} noDragEventsBubbling={noDragEventsBubbling}
> >
{({ {({
@ -78,4 +74,4 @@ const FileUpload = ({
); );
}; };
export default FileUpload; export default CollectionDropZone;

View file

@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import { Button, Card, Col, Container, Modal, Row } from 'react-bootstrap'; import { Button, Card, Modal } from 'react-bootstrap';
import FileUpload from './DragAndDropUpload'; import CollectionDropZone from './CollectionDropZone';
function CollectionSelector({ function CollectionSelector({
modalView, modalView,
@ -9,38 +9,19 @@ function CollectionSelector({
showProgress, showProgress,
}) { }) {
const CollectionIcons = collectionLatestFile.map((item) => ( const CollectionIcons = collectionLatestFile.map((item) => (
<FileUpload <CollectionDropZone key={item.collectionID}
closeModal={closeModal} closeModal={closeModal}
collectionLatestFile={item} collectionLatestFile={item}
noDragEventsBubbling noDragEventsBubbling
showProgress={showProgress} showProgress={showProgress}
> >
<Card <Card style={{ maxHeight: "20%", cursor: 'pointer', border: 'solid', flexWrap: "nowrap" }}>
style={{ <Card.Img variant="top" src={item.thumb} />
margin: '5px', <Card.Body>
padding: '5px', <Card.Text>{item.collectionName}</Card.Text>
width: '95%', </Card.Body>
height: '150px',
position: 'relative',
border: 'solid',
float: 'left',
cursor: 'pointer',
}}
>
<Card.Img
variant='top'
src={item.thumb}
style={{ width: '100%', height: '100%' }}
/>
<Card.Body
style={{
padding: '5px',
}}
>
{item.collectionName}
</Card.Body>{' '}
</Card> </Card>
</FileUpload> </CollectionDropZone>
)); ));
return ( return (
<Modal <Modal
@ -54,10 +35,8 @@ function CollectionSelector({
Select/Click on Collection to upload Select/Click on Collection to upload
</Modal.Title> </Modal.Title>
</Modal.Header> </Modal.Header>
<Modal.Body> <Modal.Body style={{ display: "flex", justifyContent: "space-between", flexWrap: "wrap" }}>
<Container> {CollectionIcons}
<Row>{CollectionIcons}</Row>
</Container>
</Modal.Body> </Modal.Body>
<Modal.Footer> <Modal.Footer>
<Button onClick={closeModal}>Close</Button> <Button onClick={closeModal}>Close</Button>

View file

@ -22,8 +22,6 @@ import AutoSizer from 'react-virtualized-auto-sizer';
import { VariableSizeList as List } from 'react-window'; import { VariableSizeList as List } from 'react-window';
import Collections from './components/Collections'; import Collections from './components/Collections';
import SadFace from 'components/SadFace'; import SadFace from 'components/SadFace';
import FileUpload from './components/DragAndDropUpload';
import UploadButton from 'pages/gallery/components/UploadButton';
import CollectionSelector from './components/CollectionSelector'; import CollectionSelector from './components/CollectionSelector';
import UploadProgress from './components/UploadProgress'; import UploadProgress from './components/UploadProgress';
@ -306,7 +304,6 @@ export default function Gallery(props) {
<CollectionSelector <CollectionSelector
modalView={props.modalView} modalView={props.modalView}
closeModal={props.closeModal} closeModal={props.closeModal}
showModal={props.showModal}
collectionLatestFile={collectionLatestFile} collectionLatestFile={collectionLatestFile}
showProgress={() => setProgressView(true)} showProgress={() => setProgressView(true)}
/> />