buttons: add led option to toggle, remove useless .light dom elements

This commit is contained in:
jean-emmanuel 2017-07-13 10:35:55 +02:00
parent 513eda1af2
commit 1be9cecaa7
7 changed files with 58 additions and 29 deletions

View file

@ -12,6 +12,11 @@ Buttons are exactly what you think they are.
}
```
### `led`
- type: `boolean`
- default: `false`
- usage: set to `true` to display the toggle's state with a led
### `on`
- type: `string|number|object`
- default: `1`

View file

@ -35,7 +35,7 @@ module.exports = class Push extends _widgets_base {
constructor(options) {
super({...options, html: '<div class="toggle"><div class="light"></div></div>'})
super({...options, html: '<div class="toggle"></div>'})
this.state = 0
this.active = 0

View file

@ -16,6 +16,7 @@ module.exports = class Toggle extends _widgets_base {
top:'auto',
width:'auto',
height:'auto',
led: false,
color:'auto',
css:'',
@ -34,7 +35,7 @@ module.exports = class Toggle extends _widgets_base {
constructor(options) {
super({...options, html: '<div class="toggle"><div class="light"></div></div>'})
super({...options, html: '<div class="toggle"></div>'})
this.widget.value = this.widget.find('span')
this.widget.state = 0
@ -45,6 +46,8 @@ module.exports = class Toggle extends _widgets_base {
this.fakeclick()
})
if (this.getProp('led')) this.container.addClass('led')
this.classHolders = this.widget.add(this.container)
this.value = this.getProp('off')

View file

@ -79,7 +79,7 @@ module.exports = class Modal extends Panel {
this.setValue(0, {sync:true, send:true})
})
this.light = $('<div class="toggle"><div class="light"></div></div>').appendTo(this.container)
this.light = $('<div class="toggle"></div>').appendTo(this.container)
if (this.getProp('doubleTap')) {
doubletabreset(this.light, ()=>{

View file

@ -183,24 +183,26 @@
.modal-container {
@extend .toggle-container;
> .toggle .light:after {
content:"\f0da";
> .toggle:after {
content:"\f0da"!important;
font-family: FontAwesome;
transform: rotateZ(-45deg);
font-size: 20rem;
display: block;
width:8rem;
height:6rem;
right:2rem;
top:1rem;
left:auto;
right:2rem!important;
top:1rem!important;
left:auto!important;
bottom:auto!important;
line-height: 10rem;
text-align: center;
float:right;
position: absolute;;
position: absolute;
box-shadow: none;
background: none;
background: none!important;
color:var(--color-text-fade);
opacity: 1!important;
}
> .panel {
@ -245,7 +247,7 @@
}
&.on {
z-index: 99999;
> .toggle .light:after {
> .toggle:after {
color:var(--color-custom);
}
}

View file

@ -14,8 +14,10 @@
background: radial-gradient( ellipse at center, transparent, var(--color-bg));
}
}
.light:after{
display: none;
&.on:not(.active) {
&:after {
opacity: 0;
}
}
}

View file

@ -14,22 +14,12 @@
border-radius: inherit;
.light {
&:before {
content:"";
flex:1;
display: flex;
opacity: 1;
box-shadow: 0 0 0 1rem var(--color-light) inset;
pointer-events: none;
border-radius: inherit;
&:before {
content:"";
flex:1;
opacity: 0;
box-shadow: 0 0 0 1rem var(--color-custom) inset;
border-radius: inherit;
}
}
&.on {
@ -44,8 +34,9 @@
background: radial-gradient( ellipse at center, transparent, var(--color-bg));
}
.light:before {
&:before {
opacity: 0.3;
box-shadow: 0 0 0 1rem var(--color-custom) inset;
}
}
@ -70,9 +61,7 @@
align-items: center;
z-index: 2;
font-family: roboto;
// font-weight: bold;
color:var(--color-text);
// letter-spacing: 1rem;
}
&.on > .label {
@ -80,4 +69,32 @@
opacity: 1;
}
&.led {
.toggle:after {
content:"";
opacity: 1;
position: absolute;
display: block;
top:3rem;
left:3rem;
right:3rem;
height: 4rem;
background: var(--color-track);
box-shadow: 0 0 0 1rem var(--color-light), 0 0 0 1rem var(--color-bg) inset;
z-index: 1;
border-radius: inherit;
opacity: 0.7;
}
.toggle.on:after {
background: var(--color-custom);
}
.toggle:before {
box-shadow: 0 0 0 1rem var(--color-light) inset;
opacity: 1;
}
> .label {
top:7rem;
}
}
}