widgets: add new "modal" container

This commit is contained in:
jean-emmanuel 2016-12-05 20:00:18 +01:00
parent 74741eed4e
commit c39f42f28f
3 changed files with 135 additions and 22 deletions

View file

@ -30,6 +30,7 @@ var widgets = {
// containers
strip: require('./widgets/containers/strip'),
panel: require('./widgets/containers/panel'),
modal: require('./widgets/containers/modal'),
}
module.exports.categories = {
@ -38,7 +39,7 @@ module.exports.categories = {
'Pads':['xy','rgb','multixy'],
'Matrices':['multifader','multitoggle','multipush', 'keyboard'],
'Plots':['plot','eq','visualizer','led','meter','text'],
'Containers':['panel','strip']
'Containers':['panel','strip','modal']
}
module.exports.widgetOptions = function(){

View file

@ -0,0 +1,69 @@
var {Panel} = require('./panel')
module.exports.options = {
type:'modal',
id:'auto',
separator1:'style',
label:'auto',
left:'auto',
top:'auto',
width:'auto',
height:'auto',
scroll:true,
color:'auto',
css:'',
separator2:'chilren',
widgets:[],
tabs:[]
}
var Modal = module.exports.Modal = function(widgetData, container) {
Panel.apply(this,arguments)
this.container = container
container.append('<div class="light"></div>')
this.light = container.find('.light').first()
this.modal = this.widget.detach()
this.value = false
this.light.on('fake-click',()=>{
this.setValue(!this.value)
})
this.widget.setValue = this.setValue.bind(this)
this.widget.getValue = ()=>{
return this.value
}
}
Modal.prototype = Object.create(Panel.prototype)
Modal.prototype.constructor = Modal
Modal.prototype.setValue = function(v) {
if (v) {
this.container.addClass('on')
this.widget.addClass('on')
this.light.addClass('on')
this.value = true
} else {
this.container.removeClass('on')
this.widget.removeClass('on')
this.light.removeClass('on')
this.value = false
}
}
module.exports.create = function(widgetData, container) {
var modal = new Modal(widgetData, container)
return modal.widget
}

View file

@ -1,24 +1,4 @@
.panel-container {
width: 200rem;
height: 200rem;
border:0;
background: var(--color-fg);
&:before {
content:"";
position: absolute;
top:0;
bottom:0;
right: 0;
left: 0;
border-bottom: 1rem solid var(--color-bg);
border-right: 1rem solid var(--color-bg);
pointer-events: none;
z-index: 2;
}
.panel-container-base {
&.nolabel .panel {
top:0;
@ -62,3 +42,66 @@
background: transparent;
}
}
.panel-container {
@extend .panel-container-base;
width: 200rem;
height: 200rem;
border:0;
background: var(--color-fg);
&:before {
content:"";
position: absolute;
top:0;
bottom:0;
right: 0;
left: 0;
border-bottom: 1rem solid var(--color-bg);
border-right: 1rem solid var(--color-bg);
pointer-events: none;
z-index: 2;
}
}
.modal-container {
@extend .panel-container-base;
@extend .toggle-container;
&.on {
position: fixed;
top:0!important;
left:0!important;
right:0!important;
bottom:0!important;
width: auto!important;
height: auto!important;
border:0;
> .light, > .label {
min-height:auto!important;
height:var(--nav-height)!important;
}
}
.panel {
display: none!important;
background: var(--color-fg);
transform: translateZ(0);
&.on {
display: block!important;
&.has-tabs {
display: flex!important;
}
position: absolute;
top:var(--nav-height);
left:0;
right:0;
bottom:0;
border-right:0;
height: auto!important;
border-top:1rem solid var(--color-bg);
}
}
}