You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
680 B
JavaScript
29 lines
680 B
JavaScript
class LedWidget extends BaseWidget {
|
|
$el;
|
|
|
|
constructor(data, renderer) {
|
|
super(data, renderer);
|
|
|
|
this.makeLayout({
|
|
type: 'div',
|
|
class: 'w_led',
|
|
name: 'el',
|
|
});
|
|
|
|
this.update(data);
|
|
}
|
|
|
|
update(data) {
|
|
super.update(data);
|
|
|
|
if ('color' in data) this.$el.style.setProperty('--on-color', intToCol(data.color));
|
|
if ('disable' in data) this.disable(this.$el, data.disable);
|
|
if ('value' in data) {
|
|
if (data.value) this.$el.classList.add('w_led_on');
|
|
else this.$el.classList.remove('w_led_on');
|
|
}
|
|
}
|
|
}
|
|
|
|
Renderer.register('led', LedWidget);
|