-
Notifications
You must be signed in to change notification settings - Fork 1
/
layout-example-note-list-item-view.js
62 lines (53 loc) · 1.4 KB
/
layout-example-note-list-item-view.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
'use babel'
import * as React from 'react'
import PropTypes from 'prop-types'
export default function LayoutExampleNoteListItemView(props) {
const { active, focused, note } = props
const { title } = note
function handleClick(e) {
props.onClick && props.onClick(e, props.note)
e.preventDefault()
e.stopPropagation()
}
function handleDblClick(e) {
props.onDblClick && props.onDblClick(e, props.note)
e.preventDefault()
e.stopPropagation()
}
function handleContextMenu(e) {
props.onContextMenu && props.onContextMenu(e, props.note)
e.preventDefault()
e.stopPropagation()
}
return (
<div
className={`layout-example note-list-item-view ${active &&
'active'} ${focused && 'focused'}`}
onClick={handleClick}
onDoubleClick={handleDblClick}
onContextMenu={handleContextMenu}
>
{title}
</div>
)
}
LayoutExampleNoteListItemView.propTypes = {
active: PropTypes.bool,
focused: PropTypes.bool,
note: PropTypes.object,
onClick: PropTypes.func,
onDblClick: PropTypes.func,
onContextMenu: PropTypes.func
}
export function registerAsNoteListItemView() {
inkdrop.components.registerClass(
LayoutExampleNoteListItemView,
'CustomNoteListItemView'
)
}
export function unregisterAsNoteListItemView() {
inkdrop.components.deleteClass(
LayoutExampleNoteListItemView.default,
'CustomNoteListItemView'
)
}