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.

43 lines
1.1 KiB
JavaScript

class Label extends BaseWidget {
$lbl_cont;
$lbl_icon;
$lbl;
constructor(data, renderer) {
super(data, renderer);
this.makeLayout({
type: 'div',
class: 'w_label',
name: 'lbl_cont',
style: {
fontSize: '33px'
},
children: [
{
type: 'span',
class: 'w_icon',
name: 'lbl_icon',
},
{
type: 'label',
name: 'lbl',
}
]
});
this.update(data);
}
update(data) {
super.update(data);
if ('value' in data) this.$lbl.textContent = data.value;
if ('color' in data) this.$lbl_cont.style.color = intToCol(data.color);
if ('fsize' in data) this.$lbl_cont.style.fontSize = data.fsize + 'px';
if ('align' in data) this.align(data.align);
if ('icon' in data) this.$lbl_icon.innerHTML = data.icon ? (getIcon(data.icon) + ' ') : '';
}
}
Renderer.register('label', Label);