-
Notifications
You must be signed in to change notification settings - Fork 0
/
Label.js
54 lines (49 loc) · 1.23 KB
/
Label.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
import Component from "./Component.js"
import ObjectHelper from "./Helpers/ObjectHelper.js"
export default class Label extends Component {
constructor() {
super()
this.text = ""
this.color = undefined
this.textCentered = true
this.options.pointerEvents = false
}
setColor(color) {
this.color = color
if (this.isBuilt) this.loadValues()
return this
}
setText(text) {
this.text = text
if (this.isBuilt) this.loadValues()
return this
}
centerText(centered = true) {
this.textCentered = centered
if (this.isBuilt) {
this.container.style.textAlign = centered ? "center" : "left"
}
return this
}
createAndConfigureContainer() {
super.createAndConfigureContainer()
this.container.style.textAlign = this.textCentered ? "center" : "left"
}
loadValues() {
this.container.innerHTML = this.text
this.container.style.color = this.color
}
static copyConfig = ObjectHelper.merge(Component.copyConfig, {
includeProperties: {
text: true,
color: true,
textCentered: true,
},
})
build() {
// this.setParentSize()
super.build()
this.loadValues()
return this
}
}