Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added drag handle to the folder item
  • Loading branch information
PrimaMateria committed Sep 7, 2017
commit 0fea85e2f27e33a76b7e36ed0cfc2d9045662443
30 changes: 27 additions & 3 deletions browser/main/modals/PreferencesModal/FolderItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import styles from './FolderItem.styl'
import dataApi from 'browser/main/lib/dataApi'
import store from 'browser/main/store'
import { SketchPicker } from 'react-color'
import { SortableElement } from 'react-sortable-hoc'
import { SortableElement, SortableHandle } from 'react-sortable-hoc'

class FolderItem extends React.Component {
constructor (props) {
Expand Down Expand Up @@ -274,6 +274,30 @@ FolderItem.propTypes = {
})
}

const StyledFolderItem = CSSModules(FolderItem, styles)
class Handle extends React.Component {
render() {
return (
<div styleName='folderItem-drag-handle'>
<i className="fa fa-reorder" />
</div>
)
}
}

class SortableFolderItemComponent extends React.Component {
render() {
const StyledHandle = CSSModules(Handle, this.props.styles)
const DragHandle = SortableHandle(StyledHandle)

const StyledFolderItem = CSSModules(FolderItem, this.props.styles)

return (
<div>
<DragHandle />
<StyledFolderItem {...this.props} />
</div>
)
}
}

export default SortableElement(StyledFolderItem)
export default CSSModules(SortableElement(SortableFolderItemComponent), styles)
9 changes: 9 additions & 0 deletions browser/main/modals/PreferencesModal/FolderItem.styl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
padding 2.5px 15px
&:hover
background-color darken(white, 3%)

.folderItem-drag-handle
height 35px
border none
padding 0 10px
line-height 35px
float left
cursor row-resize

.folderItem-left
height 30px
border-left solid 2px transparent
Expand Down
2 changes: 1 addition & 1 deletion browser/main/modals/PreferencesModal/FolderList.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class SortableFolderListComponent extends React.Component {

render() {
return (
<SortableFolderList onSortEnd={this.onSortEnd} {...this.props} />
<SortableFolderList onSortEnd={this.onSortEnd} userDragHandle={true} {...this.props} />
)
}
}
Expand Down