1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-16 00:00:03 +01:00

wip: fix for value widget:more elegant solution for display issues #192

This commit is contained in:
Laura Fuentes Grau 2020-04-26 22:58:00 +02:00
parent cfcdbc412f
commit 9eb4246633
2 changed files with 8 additions and 4 deletions

View file

@ -249,6 +249,7 @@ span.signal-unit::after {
width: 100%;
height: 100%;
display: flex;
flex: none;
word-wrap: break-word;
}

View file

@ -68,13 +68,16 @@ class WidgetValue extends Component {
}
render() {
let unit = " [" + this.state.unit + "]";
let value_to_render = Number(this.state.value);
let value_width = this.props.widget.customProperties.textSize*0.55* (this.state.value.length +2);
let unit_width = this.props.widget.customProperties.textSize*2;
return (
<div className="single-value-widget">
<strong style={{ fontSize: this.props.widget.customProperties.textSize + 'px' }}>{this.props.widget.name}</strong>
<span style={{ fontSize: this.props.widget.customProperties.textSize + 'px'}}>{Number.isNaN(value_to_render) ? NaN : format('.3s')(value_to_render)}
{this.props.widget.customProperties.showUnit && unit }</span>
<strong style={{ fontSize: this.props.widget.customProperties.textSize + 'px'}}>{this.props.widget.name}</strong>
<span style={{ fontSize: this.props.widget.customProperties.textSize + 'px',width: value_width }}>{Number.isNaN(value_to_render) ? NaN : format('.3s')(value_to_render)}</span>
{this.props.widget.customProperties.showUnit &&
<span style={{ fontSize: this.props.widget.customProperties.textSize + 'px', width: unit_width}}>[{this.state.unit}]</span>
}
</div>
);
}