diff --git a/src/features/helpers/Helpers.js b/src/features/helpers/Helpers.js index 93206d7..22f17c1 100644 --- a/src/features/helpers/Helpers.js +++ b/src/features/helpers/Helpers.js @@ -6,52 +6,52 @@ import './rcSelectTheme.css'; const SliderWithToolTip = createSliderWithTooltip(RCSlider); const SelectStyle = { - control: (provided) => ({ - ...provided, - width: '100%', - }), + control: (provided) => ({ + ...provided, + width: '100%', + }), }; const Slider = (props) => { - return ( - `${v}`} - min={props.min} - max={props.max} - value={props.parameter} - onChange={(v) => props.onChange(v)} - /> - ); + return ( + `${v}`} + min={props.min} + max={props.max} + value={props.parameter} + onChange={(v) => props.onChange(v)} + /> + ); }; const SelectList = (props) => { - return ( - `${option.value}` + } + onChange={(e) => props.onChange(e.value)} + styles={SelectStyle} + /> + ); }; const Checkbox = (props) => { - return ( -
- {`${props.name}:`} - props.onChange(e.target.checked)} - /> -
- ); + return ( +
+ {`${props.name}:`} + props.onChange(e.target.checked)} + /> +
+ ); }; export { Slider, SelectList, Checkbox }; diff --git a/src/features/io/IO.css b/src/features/io/IO.css index 4be86df..d4c131a 100644 --- a/src/features/io/IO.css +++ b/src/features/io/IO.css @@ -14,11 +14,3 @@ border: 0.09em solid slategray; border-radius: 6px; } - -.show { - display: flex; -} - -.hide { - display: none; -} diff --git a/src/features/io/IO.js b/src/features/io/IO.js index 477e501..c7cda39 100644 --- a/src/features/io/IO.js +++ b/src/features/io/IO.js @@ -65,11 +65,7 @@ const Dropzone = ({ setFile }) => { ); }; -export default function IO({ show }) { - const display = show - ? 'dropzone-container show' - : 'dropzone-container hide'; - +export default function IO() { const [file, setFile] = useState(null); useEffect(() => { @@ -77,8 +73,10 @@ export default function IO({ show }) { }); return ( -
+
); } + +/* TODO -- possibly add clicking outside the modal to close it*/ diff --git a/src/features/menu/Menu.js b/src/features/menu/Menu.js index fe55c48..fdb44ac 100644 --- a/src/features/menu/Menu.js +++ b/src/features/menu/Menu.js @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useState, useRef, useEffect } from 'react'; import IO from '../io/IO'; import { useDispatch, useSelector } from 'react-redux'; // probably temporarily here import { parameterRefreshAll } from '../timbre/parameters/parameterSlice'; // probably temporarily here @@ -6,31 +6,34 @@ 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 Modal = ({ children, show, setShow }) => { + const node = useRef(); const modalDisplay = show ? 'modal modal-display' : 'modal modal-hide'; + + useEffect(() => { + const current = node.current; + + const handleOutsideClick = (event) => { + console.log('clicking anywhere'); + if (current.contains(event.target)) { + return; + } else setShow(); + }; + + if (show) { + document.addEventListener('mousedown', handleOutsideClick); + } else { + document.removeEventListener('mousedown', handleOutsideClick); + } + + return () => { + document.removeEventListener('mousedown', handleOutsideClick); + }; + }, [show, setShow]); + return ( -
-
- Save Changes - - Do you want to save your changes? - - - - -
+
+ {children}
); }; @@ -73,19 +76,37 @@ export default function MainMenu() { return (
- { - showSaveCheck(); - HandleClick(); // temporary while I implement the binary parsing stuff - }} - handleNoSave={() => { - dispatch(parameterRefreshAll()); - showSaveCheck(); - HandleClick(); - }} - /> + +
+ Save Changes + + Do you want to save your changes? + + + + +
+
@@ -111,7 +132,9 @@ export default function MainMenu() {
- + + +
);