From 18ff2ffa915eaefca125a4c24fde7aca77550fac Mon Sep 17 00:00:00 2001 From: "np.w" Date: Fri, 19 Feb 2021 18:34:47 -0600 Subject: [PATCH] style boxes when selecting item move target --- client/src/app.js | 16 +++++++++++++++- client/src/box.js | 7 ++++--- client/src/styles/app.css | 8 +++++++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/client/src/app.js b/client/src/app.js index 176af17..35a2f15 100644 --- a/client/src/app.js +++ b/client/src/app.js @@ -30,6 +30,10 @@ function App() { const [dragSource, setDragSource] = useState({}); const [dragSourceElement, setDragSourceElement] = useState(undefined); + + const [isMoving, setIsMoving] = useState(false); + const [moveItem, setMoveItem] = useState(null); + //fetch all box data useEffect(() => { const fetchData = async () => { @@ -177,6 +181,11 @@ function App() { } return false; } + const handleSelectMoveBox = (boxData, event) => { + console.log(`move item: ${moveItem} to box ${boxData._id}`); + setMoveItem(null); + setIsMoving(false); + } const boxHandler = { handleSubmit: handleSubmitBox, handleRemove: handleRemoveBox, @@ -185,7 +194,8 @@ function App() { handleEdit: handleEditBox, handleDragStart: handleDragStartBox, handleDragOver: handleDragOverBox, - handleDrop: handleDropBox + handleDrop: handleDropBox, + handleSelectMove: handleSelectMoveBox, }; const handleModalCloseBox = () => { @@ -251,6 +261,9 @@ function App() { setShowModalItem(true); } const handleMoveItem = (boxID, itemID) => { + setMoveItem(itemID); + setIsMoving(true); + /*highlight which boxes available to move to*/ /*...*/ } const handleViewItem = (boxID, itemID) => { @@ -372,6 +385,7 @@ function App() { {filteredData.map((box, index) => { return ( { +const Box = ({ boxData, boxHandler, itemHandler, isMoving }) => { const menu = useRef(null); useEffect(() => { document.addEventListener('mousedown', handleClick); @@ -40,10 +40,11 @@ const Box = ({ boxData, boxHandler, itemHandler }) => { ) } return ( -
  • boxHandler.handleDragStart(boxData, event)} onDragOver={boxHandler.handleDragOver} - onDrop={(event) => boxHandler.handleDrop(boxData, event)}> + onDrop={(event) => boxHandler.handleDrop(boxData, event)} + onClick={(event) => isMoving && boxHandler.handleSelectMove(boxData, event)}> {false && {boxData.sort}}
    {showMenu && moreMenu()}
    diff --git a/client/src/styles/app.css b/client/src/styles/app.css index 7313ecb..9258d50 100644 --- a/client/src/styles/app.css +++ b/client/src/styles/app.css @@ -114,7 +114,13 @@ li.box { list-style: none; } - +li.box.target { + border-color: green; +} +li.box.target:hover { + cursor: pointer; + border-width: 2px; +} .item-menu-more-container { z-index: 1; }