led: simplify

This commit is contained in:
jean-emmanuel 2017-06-22 09:15:57 +02:00
parent 00dc551eea
commit 94864ac551
3 changed files with 16 additions and 30 deletions

View file

@ -40,14 +40,11 @@ module.exports = class Led extends _widgets_base {
var html = `
<div class="led">
<div><span></span></div>
</div>
`
super({...options, html: html})
this.led = this.widget.find('span')
if (this.getProp('widgetId').length) $('body').on(`sync.${this.hash}`,this.syncHandle.bind(this))
this.setValue(this.getProp('range').min)
@ -77,7 +74,7 @@ module.exports = class Led extends _widgets_base {
setValue(v) {
if (typeof v != 'number') return
this.led.css('opacity',mapToScale(v,[this.getProp('range').min,this.getProp('range').max],[0,1],false,this.getProp('logScale'),true))
this.widget[0].style.setProperty('--opacity', mapToScale(v,[this.getProp('range').min,this.getProp('range').max],[0,1],false,this.getProp('logScale'),true))
}

View file

@ -38,14 +38,11 @@ module.exports = class Led extends _widgets_base {
var html = `
<div class="led">
<div><span></span></div>
</div>
`
super({...options, html: html})
this.led = this.widget.find('span')
if (this.getProp('widgetId').length) $('body').on(`sync.${this.hash}`,this.syncHandle.bind(this))
this.setValue([0,0,0,0])
@ -84,7 +81,7 @@ module.exports = class Led extends _widgets_base {
v[3] = clip(v[3] != undefined ? v[3] : 1,[0,1])
this.led[0].style.setProperty('--color-custom',`rgba(${v[0]}, ${v[1]}, ${v[2]}, ${v[3]})`)
this.widget[0].style.setProperty('--color-custom',`rgba(${v[0]}, ${v[1]}, ${v[2]}, ${v[3]})`)
}

View file

@ -1,29 +1,20 @@
.led-container, .rgbled-container {
width:100rem;
height:100rem;
padding:1rem;
.led {
display: flex;
align-items: center;
height: 100%;
overflow: hidden;
padding:2rem;
border-radius: inherit;
div {
flex-direction: row;
flex:1;
background: var(--color-track);
border:1rem solid var(--color-bg);
--opacity: 0;
&:after {
content:"";
width:100%;
height:100%;
position: relative;
border-radius: inherit;
background:var(--color-track);
border:1rem solid var(--color-bg);
span {
width:100%;
height:100%;
position: relative;
display:block;
background-color:var(--color-custom);
border-radius: inherit;
}
height: 100%;
background: var(--color-custom);
opacity: var(--opacity);
}
}
}
@ -83,13 +74,14 @@
}
}
.panel:not(.tab) > .led-container,
.panel:not(.tab) > .rgbled-container,
.panel:not(.tab) > .text-container,
.panel:not(.tab) > .visualizer-container,
.panel:not(.tab) > .eq-container,
.panel:not(.tab) > .plot-container {
--color-border:transparent;
.plot, .text {
.plot, .text, .led {
padding: 1rem;
background-clip: content-box;
border:1rem solid var(--color-light);