1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 09:46:22 +00:00

change color with hover during dragging

This commit is contained in:
Sosuke Suzuki
2017-04-05 10:08:09 +09:00
parent 720f07f62c
commit 50cd0b794b
2 changed files with 21 additions and 1 deletions

View File

@@ -15,11 +15,13 @@ import { isNumber } from 'lodash'
* @param {boolean} isFolded
* @param {number} noteCount
* @param {Function} handleDrop
* @param {Function} handleDragEnter
* @param {Function} handleDragOut
* @return {React.Component}
*/
const StorageItem = ({
isActive, handleButtonClick, handleContextMenu, folderName,
folderColor, isFolded, noteCount, handleDrop
folderColor, isFolded, noteCount, handleDrop, handleDragEnter, handleDragLeave
}) => (
<button styleName={isActive
? 'folderList-item--active'
@@ -28,6 +30,8 @@ const StorageItem = ({
onClick={handleButtonClick}
onContextMenu={handleContextMenu}
onDrop={handleDrop}
onDragEnter={handleDragEnter}
onDragLeave={handleDragLeave}
>
<span styleName={isFolded
? 'folderList-item-name--folded' : 'folderList-item-name'
@@ -54,6 +58,8 @@ StorageItem.propTypes = {
folderName: PropTypes.string.isRequired,
folderColor: PropTypes.string,
isFolded: PropTypes.bool.isRequired,
handleDragEnter: PropTypes.func.isRequired,
handleDragLeave: PropTypes.func.isRequired,
noteCount: PropTypes.number
}

View File

@@ -132,7 +132,19 @@ class StorageItem extends React.Component {
}
}
handleDragEnter (e) {
e.dataTransfer.setData("defaultColor", e.target.style.backgroundColor)
e.target.style.backgroundColor = "rgba(129, 130, 131, 0.08)"
}
handleDragLeave (e) {
e.target.style.opacity = "1"
e.target.style.backgroundColor = e.dataTransfer.getData("defaultColor")
}
handleDrop (e, storage, folder, dispatch, location) {
e.target.style.opacity = "1"
e.target.style.backgroundColor = e.dataTransfer.getData("defaultColor")
const noteData = JSON.parse(e.dataTransfer.getData("note"))
if (folder.key !== noteData.folder) {
dataApi
@@ -197,6 +209,8 @@ class StorageItem extends React.Component {
isFolded={isFolded}
noteCount={noteCount}
handleDrop={(e) => this.handleDrop(e, storage, folder, dispatch, location)}
handleDragEnter={this.handleDragEnter}
handleDragLeave={this.handleDragLeave}
/>
)
})