-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtouchbar-item.js
124 lines (109 loc) · 3.67 KB
/
touchbar-item.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/** @babel */
/** @jsx etch.dom */
import {Disposable} from 'atom'
import etch from 'etch'
const types = [
{
value: "button",
label: "Button"
},
{
value: "button-insert",
label: "Button Text Insert"
},
{
value: "label",
label: "Label"
},
{
value: "spacer",
label: "Spacer"
},
{
value: "color-picker",
label: "Color Picker"
},
{
value: "emoji",
label: "Emoji Scrubber"
},
{
value: "group",
label: "Group"
},
{
value: "popover",
label: "Popover"
},
{
value: "segment",
label: "Segment"
}
]
export default class TouchBarItem {
constructor(props) {
this.props = props
etch.initialize(this)
console.log(this.props.items === undefined)
}
update(props) {
this.props = props
return etch.update(this)
}
onLabelChanged() {
this.props.onLabelChanged(document.getElementById(`${this.props.name}input_label`).value)
}
onIconChanged() {
this.props.onIconChanged(document.getElementById(`${this.props.name}input_icon`).value)
}
onIconColorChanged() {
this.props.onIconColorChanged(document.getElementById(`${this.props.name}_select_icon_color`).value)
}
onTypeChanged() {
this.props.onTypeChanged(document.getElementById(`${this.props.name}_select_type`).value)
}
onCommandChanged() {
this.props.onCommandChanged(document.getElementById(`${this.props.name}input_command`).value)
}
onColorChanged() {
this.props.onColorChanged(document.getElementById(`${this.props.name}input_color`).value)
}
onRemove() {
this.props.onRemove()
}
onDragStarted(e) {
e.dataTransfer.dropEffect = 'move';
this.props.onDragStarted()
}
onDropped() {
this.props.onDropped()
}
render() {
return (
<atom-panel class='padded native-key-bindings' draggable="true" ondragstart={(e) => this.onDragStarted(e)} ondrop={() => this.onDropped()}>
<div class="inset-panel padded block">
<span class="drag-wrapper icon icon-grabber inline-block"></span>
<select id={`${this.props.name}_select_type`} class="input-select inline-block" onchange={() => this.onTypeChanged()}>
{types.map((e) => {
if(this.props.type === e.value) {
return <option value={e.value} selected>{e.label}</option>
} else {
return <option value={e.value}>{e.label}</option>
}
})}
</select>
<input type="text" class="input-text inline-block label" id={`${this.props.name}input_label`} value={ this.props.label || "" } placeholder="No label" onKeyUp={this.onLabelChanged}></input>
<input type="text" class="input-text inline-block icon-input" id={`${this.props.name}input_icon`} value={ this.props.icon || "" } placeholder="No icon" onKeyUp={this.onIconChanged}></input>
<select id={`${this.props.name}_select_icon_color`} class="input-select inline-block" onchange={() => this.onIconColorChanged()}>
<option value="default" selected>Default</option>
<option value="white">White</option>
<option value="black">Black</option>
</select>
<input type="text" class="input-text inline-block command" id={`${this.props.name}input_command`} value={ this.props.command || "" } placeholder="No command" onKeyUp={this.onCommandChanged}></input>
<input type="color" class="input-color inline-block" id={`${this.props.name}input_color`} value={ this.props.color || "" } onchange={() => this.onColorChanged()}></input>
<span class="remove icon icon-trashcan inline-block" onClick={() => this.onRemove()} value="Remove"/>
</div>
</atom-panel>
)
}
}