panels: reorganize props, add innerPadding property to allow removing panel's inner padding while keeping children spacing

scss: better --widget-spacing def
This commit is contained in:
bordun 2020-04-22 15:30:47 +02:00
parent 892aa02ceb
commit d8de340ed0
8 changed files with 81 additions and 35 deletions

View file

@ -17,20 +17,25 @@ class Matrix extends StaticProperties(Panel, {scroll: false}) {
return Widget.defaults({
_matrix: 'matrix',
_matrix: 'matrix: widgets',
widgetType: {type: 'string', value: 'button', help: 'Defines the type of the widgets in the matrix'},
colorPanel: {type: 'string', value: 'auto', help: 'Panel background color. Set to "auto" to inherit from parent widget.'},
layout: {type: 'string', value: 'horizontal', choices: ['horizontal', 'vertical', 'grid'], help: 'Defines how children are laid out.'},
gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'},
quantity: {type: 'number', value: 4, help: 'Defines the number of widgets in the matrix'},
start: {type: 'integer', value: 0, help: 'First widget\'s index'},
traversing: {type: 'boolean', value: true, help: 'Set to `false` to disable traversing gestures'},
props: {type: 'object', value: {}, help: [
'Defines a set of property to override the widgets\' defaults.',
'Formulas in this field are resolved with an extra variable representing each widget\'s index: `$`',
'Note: by default, the widgets inherit from the matrix\' `id` and osc properties (`id` and `address` are appended with `/$`)'
]}
]},
_matrixLayout: 'matrix: layout',
colorPanel: {type: 'string', value: 'auto', help: 'Panel background color. Set to "auto" to inherit from parent widget.'},
layout: {type: 'string', value: 'horizontal', choices: ['horizontal', 'vertical', 'grid'], help: 'Defines how children are laid out.'},
gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'},
traversing: {type: 'boolean', value: true, help: 'Set to `false` to disable traversing gestures'},
}, [], {})

View file

@ -18,20 +18,24 @@ class Modal extends Panel {
return Widget.defaults({
_modal:'modal',
_modal: 'modal',
doubleTap: {type: 'boolean', value: false, help: 'Set to `true` to make the modal require a double tap to open instead of a single tap'},
variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'},
_modalWidgets: 'modal: popup',
popupLabel: {type: 'string', value: '', help: 'Alternative label for the modal popup'},
popupWidth: {type: 'number|percentage', value: '80%', help: 'Modal popup\'s size'},
popupHeight: {type: 'number|percentage', value: '80%', help: 'Modal popup\'s size'},
popupLeft: {type: 'number|percentage', value: 'auto', help: 'Modal popup\'s position'},
popupTop: {type: 'number|percentage', value: 'auto', help: 'Modal popup\'s position'},
colorPanel: {type: 'string', value: 'auto', help: 'Panel background color. Set to "auto" to inherit from parent widget.'},
layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help: 'Defines how children are laid out.'},
gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'},
traversing: {type: 'boolean', value: false, help: 'Set to `true` to enable traversing gestures in this widget. Set to `smart` or `auto` to limit affected widgets by the type of the first touched widget'},
scroll: {type: 'boolean', value: true, help: 'Set to `false` to disable scrollbars'},
variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'},
}, [], {

View file

@ -17,16 +17,23 @@ class Panel extends Container() {
return super.defaults({
_panel:'panel',
_panel: 'panel',
colorPanel: {type: 'string', value: 'auto', help: 'Panel background color. Set to "auto" to inherit from parent widget.'},
variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'},
traversing: {type: 'boolean', value: false, help: 'Set to `true` to enable traversing gestures in this widget. Set to `smart` or `auto` to limit affected widgets by the type of the first touched widget'},
_panel_widgets: 'panel: widget container',
layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:'Defines how children are laid out.'},
justify: {type: 'string', value: 'start', choices: ['start', 'end', 'center', 'space-around', 'space-between'], help:'If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.'},
gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'},
verticalTabs: {type: 'boolean', value: false, help: 'Set to `true` to display for vertical tab layout'},
traversing: {type: 'boolean', value: false, help: 'Set to `true` to enable traversing gestures in this widget. Set to `smart` or `auto` to limit affected widgets by the type of the first touched widget'},
scroll: {type: 'boolean', value: true, help: 'Set to `false` to disable scrollbars'},
variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'},
innerPadding: {type : 'boolean', value: true, help: 'Set to `false` to make the `padding` property apply only between children and not at the container\'s inner boundaries.'},
_panel_tabs: 'panel: tab container',
verticalTabs: {type: 'boolean', value: false, help: 'Set to `true` to display for vertical tab layout'},
}, [], {
@ -36,7 +43,7 @@ class Panel extends Container() {
tabs: {type: 'array', value: [], help: 'Each element of the array must be a tab object. A panel cannot contain widgets and tabs simultaneously'},
value: {type: 'integer', value: '', help: [
'Defines currently widgeted tab in the widget',
'Defines currently selected tab in the widget',
'A tab can be opened only by setting its parent\'s value'
]},
@ -52,6 +59,7 @@ class Panel extends Container() {
this.childrenType = ''
this.container.classList.toggle('no-inner-padding', !this.getProp('innerPadding'))
this.container.classList.toggle('no-scroll', !this.getProp('scroll'))
this.container.classList.add('layout-' + this.getProp('layout'))

View file

@ -14,17 +14,23 @@ class Root extends StaticProperties(Panel, {visible: true, label: false, id: 'ro
return Widget.defaults({
_panel:'panel',
_panel: 'panel',
colorPanel: {type: 'string', value: 'auto', help: 'Panel background color. Set to "auto" to inherit from parent widget.'},
variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'},
traversing: {type: 'boolean', value: false, help: 'Set to `true` to enable traversing gestures in this widget. Set to `smart` or `auto` to limit affected widgets by the type of the first touched widget'},
_panel_widgets: 'panel: widget container',
layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:'Defines how children are laid out.'},
justify: {type: 'string', value: 'start', choices: ['start', 'end', 'center', 'space-around', 'space-between'], help:'If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.'},
gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'},
verticalTabs: {type: 'boolean', value: false, help: 'Set to `true` to display for vertical tab layout'},
traversing: {type: 'boolean', value: false, help: 'Set to `true` to enable traversing gestures in this widget. Set to `smart` or `auto` to limit affected widgets by the type of the first touched widget'},
scroll: {type: 'boolean', value: true, help: 'Set to `false` to disable scrollbars'},
variables: {type: '*', value: '', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'},
innerPadding: {type : 'boolean', value: true, help: 'Set to `false` to make the `padding` property apply only between children and not at the container\'s inner boundaries.'},
_panel_tabs: 'panel: tab container',
verticalTabs: {type: 'boolean', value: false, help: 'Set to `true` to display for vertical tab layout'},
}, [
'visible', 'label',

View file

@ -14,17 +14,25 @@ module.exports = class Tab extends Panel {
return Widget.defaults({
_tab:'tab',
// detached: {type: 'boolean', value: true, help: 'Set to `false` if the tab contains `frame` widgets that should not be reloaded when the tab opens'},
_panel: 'panel',
colorPanel: {type: 'string', value: 'auto', help: 'Panel background color. Set to "auto" to inherit from parent widget.'},
variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'},
traversing: {type: 'boolean', value: false, help: 'Set to `true` to enable traversing gestures in this widget. Set to `smart` or `auto` to limit affected widgets by the type of the first touched widget'},
// detached: {type: 'boolean', value: true, help: 'Set to `false` if the tab contains `frame` widgets that should not be reloaded when the tab opens'},
_panel_widgets: 'panel: widget container',
layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:'Defines how children are laid out.'},
justify: {type: 'string', value: 'start', choices: ['start', 'end', 'center', 'space-around', 'space-between'], help:'If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.'},
gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'},
verticalTabs: {type: 'boolean', value: false, help: 'Set to `true` to display for vertical tab layout'},
traversing: {type: 'boolean', value: false, help: 'Set to `true` to enable traversing gestures in this widget. Set to `smart` or `auto` to limit affected widgets by the type of the first touched widget'},
scroll: {type: 'boolean', value: true, help: 'Set to `false` to disable scrollbars'},
variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'},
innerPadding: {type : 'boolean', value: true, help: 'Set to `false` to make the `padding` property apply only between children and not at the container\'s inner boundaries.'},
_panel_tabs: 'panel: tab container',
verticalTabs: {type: 'boolean', value: false, help: 'Set to `true` to display for vertical tab layout'},
}, [
'_geometry', 'left', 'top', 'width', 'height', 'expand',

View file

@ -21,7 +21,7 @@
left:0;
right:0;
bottom:0;
margin: calc(var(--widget-spacing) / 2);
margin: var(--widget-spacing);
flex: 1;
display: flex;
flex-direction: column;

View file

@ -24,21 +24,34 @@
> inner {
--widget-spacing: var(--widget-padding);
flex: 1;
position: relative;
overflow: auto;
margin: calc(var(--widget-spacing) / 2) calc(1rem + var(--widget-spacing) / 2) calc(1rem + var(--widget-spacing) / 2);
}
&.no-scroll > inner {
overflow: hidden;
}
&.contains-widgets {
> inner {
--widget-spacing: calc(var(--widget-padding) / 2);
margin: var(--widget-spacing)
calc(1rem + var(--widget-spacing))
calc(1rem + var(--widget-spacing));
}
&.no-inner-padding > inner {
margin: calc(-1rem + var(--widget-spacing) * -1)
calc(var(--widget-spacing) * -1)
calc(var(--widget-spacing) * -1);
}
> inner > .widget {
padding: calc(var(--widget-spacing) / 2);
padding: var(--widget-spacing);
}
&.layout-default > inner {
@ -156,7 +169,7 @@
@include pseudo-stroke($z: 1);
&:before {
margin: calc(var(--widget-spacing) / 2);
margin: var(--widget-spacing);
}
> label {
@ -201,7 +214,7 @@
bottom:0;
> inner {
margin: calc(var(--widget-spacing) / 2);
margin: var(--widget-spacing);
// optimize layout recalc
position: absolute;
@ -384,7 +397,7 @@
left:0;
right:0;
bottom:0;
margin: calc(var(--widget-spacing) / 2);
margin: var(--widget-spacing);
flex: 1;
display: flex;
flex-direction: column;
@ -426,7 +439,7 @@
background: none!important;
color: var(--color-stroke);
opacity: var(--alpha-stroke);
margin: calc(var(--widget-spacing) / 2);
margin: var(--widget-spacing);
}
}
@ -470,7 +483,9 @@
}
> inner {
margin: calc(var(--widget-spacing) / 2) calc(var(--widget-spacing) / 2) calc(var(--widget-spacing) / 2);
margin: var(--widget-spacing)
var(--widget-spacing)
var(--widget-spacing);
}
}
}

View file

@ -52,7 +52,7 @@
--widget-spacing: var(--widget-padding);
padding: calc(var(--widget-spacing) / 2 + 1rem);
padding: calc(var(--widget-spacing) + 1rem);
grid-template:
"a a b" auto / 1fr;
@ -68,8 +68,8 @@
.widget {
height: auto;
width: auto;
margin: calc(var(--widget-spacing) / 2);
--widget-padding: 2rem;//calc(var(--widget-spacing) / 2);
margin: var(--widget-spacing);
--widget-padding: 2rem;
}
.pad {