From ab92ba7af6de52195a7fb0da6430ee74f153124a Mon Sep 17 00:00:00 2001 From: "[poww10s]" <[theironminer@gmail.com]> Date: Fri, 27 Nov 2020 02:00:42 -0500 Subject: [PATCH] added Dropzone and rudimentary styling --- src/App.js | 2 + src/features/io/IO.js | 81 +++++++++++++++++++++++---- src/features/menu/Menu.js | 12 +--- src/features/timbre/timbreSwitcher.js | 65 +++++++++++---------- 4 files changed, 105 insertions(+), 55 deletions(-) diff --git a/src/App.js b/src/App.js index 06d8513..cce8456 100644 --- a/src/App.js +++ b/src/App.js @@ -1,6 +1,7 @@ import React from 'react'; import MainMenu from './features/menu/Menu'; import TimbreSwitcher from './features/timbre/timbreSwitcher'; +import IO from './features/io/IO'; import './App.css'; function App() { @@ -8,6 +9,7 @@ function App() {
+
diff --git a/src/features/io/IO.js b/src/features/io/IO.js index 7602201..05db08e 100644 --- a/src/features/io/IO.js +++ b/src/features/io/IO.js @@ -1,21 +1,78 @@ -import React from 'react'; +import React, { useState, useEffect, useMemo } from 'react'; import { useDropzone } from 'react-dropzone'; -export default function Dropzone(props) { - const { getRootProps, getInputProps, open, acceptedFiles } = useDropzone({ - noClick: true, +const baseStyle = { + flex: 1, + display: 'flex', + flexDirection: 'column', + alignItems: 'center', + padding: '20px', + borderWidth: 2, + borderRadius: 2, + borderColor: '#eeeeee', + borderStyle: 'dashed', + backgroundColor: '#fafafa', + color: '#bdbdbd', + outline: 'none', + transition: 'border .24s ease-in-out', +}; + +const activeStyle = { + borderColor: '#2196f3', +}; + +const acceptStyle = { + borderColor: '#00e676', +}; + +const rejectStyle = { + borderColor: '#ff1744', +}; + +const Dropzone = ({ setFile }) => { + const { + getRootProps, + getInputProps, + isDragAccept, + isDragActive, + isDragReject, + } = useDropzone({ + multiple: false, + maxFiles: 1, noKeyboard: true, + onDrop: (files) => setFile(files[0]), + }); + + const style = useMemo( + () => ({ + ...baseStyle, + ...(isDragActive ? activeStyle : {}), + ...(isDragAccept ? acceptStyle : {}), + ...(isDragReject ? rejectStyle : {}), + }), + [isDragActive, isDragReject, isDragAccept] + ); + + return ( +
+
+ +

Drag and drop file here, or click to select

+
+
+ ); +}; + +export default function IO(props) { + const [file, setFile] = useState(null); + + useEffect(() => { + console.log(file); }); return ( -
-
- -

Drag and drop files here

- -
+
+
); } diff --git a/src/features/menu/Menu.js b/src/features/menu/Menu.js index 03ad864..8fb56c5 100644 --- a/src/features/menu/Menu.js +++ b/src/features/menu/Menu.js @@ -1,16 +1,12 @@ -import React, { useState, useCallback } from 'react'; +import React, { useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; // probably temporarily here -import { - parameterRefreshAll, - parameterFlipUnsaved, -} from '../timbre/parameters/parameterSlice'; // probably temporarily here +import { parameterRefreshAll } from '../timbre/parameters/parameterSlice'; // probably temporarily here import logo from '../../1f3b9.svg'; import './Menu.css'; // for things such as (do you want to save? or do you want to reset things?) const Modal = ({ show, handleSave, handleNoSave, handleClose }) => { const modalDisplay = show ? 'modal modal-display' : 'modal modal-hide'; - const dispatch = useDispatch(); return (
@@ -47,10 +43,6 @@ export default function MainMenu() { const [showModal, setShowModal] = useState(false); const dispatch = useDispatch(); - const unSavedUpdate = useCallback(() => dispatch(parameterFlipUnsaved), [ - dispatch, - ]); - const HandleClick = () => { setOpen({ className: open.openState diff --git a/src/features/timbre/timbreSwitcher.js b/src/features/timbre/timbreSwitcher.js index ed2d18e..34160ea 100644 --- a/src/features/timbre/timbreSwitcher.js +++ b/src/features/timbre/timbreSwitcher.js @@ -7,38 +7,37 @@ import { Tab, Tabs, TabList, TabPanel } from 'react-tabs'; import styles from './Timbre.module.css'; export default function TimbreSwitcher(props) { - return ( -
- - - Timbre 1 - Timbre 2 - Vocoder - Effects - Arpeggio - + return ( +
+ + + Timbre 1 + Timbre 2 + Vocoder + Effects + Arpeggio + - - - - - - - - - - - - - - - - -
- ); + + + + + + + + + + + + + + + +
+
+ ); }