modal: add popupPadding property to control the buttons and the container's padding independently

This commit is contained in:
bordun 2020-10-04 19:42:29 +02:00
parent 809437ef28
commit 12630cbb17
3 changed files with 17 additions and 14 deletions

View file

@ -17,6 +17,7 @@
- keyboard: added `colorBlack` and `colorWhite` properties to customize key colors
- dropdown/menu: add `label` property (with support easy key/value display)
- dropdown/menu: add `icon` toggle property
- modal: add `popupPadding` property to control the buttons and the container's padding independently
## 1.4.1

View file

@ -34,6 +34,7 @@ class Modal extends Panel {
'- Icons can be transformed with the following suffixes: `.flip-[horizontal|vertical|both]`, `.rotate-[90|180|270]`, `.spin`, `.pulse`. Example: `^play.flip-horizontal`',
]},
popupLabel: {type: 'string|boolean', value: 'auto', help: 'Alternative label for the modal popup'},
popupPadding: {type: 'number', value: 'auto', help: 'Modal\'s inner spacing.'},
verticalTabs: null,
},
children: {
@ -115,7 +116,6 @@ class Modal extends Panel {
this.popupContent.classList.add('layout-' + this.getProp('layout'))
this.popupContent.style.setProperty('--widget-padding', this.getProp('padding') != 'auto' ? parseFloat(this.getProp('padding')) + 'rem' : '')
this.label = html`<label></label>`
this.updateLabel()
@ -247,7 +247,9 @@ class Modal extends Panel {
} else {
this.labelChange = true
}
return
case 'popupPadding':
this.setCssVariables()
return
}
@ -255,21 +257,17 @@ class Modal extends Panel {
}
setCssVariables() {
super.setCssVariables()
if (!this.popupContent) return
this.popupContent.style.setProperty('--widget-padding', this.getProp('padding') !== 'auto' ? parseFloat(this.getProp('padding')) + 'rem' : '')
}
}
Modal.cssVariables = Modal.prototype.constructor.cssVariables.concat(
{js: 'popupPadding', css: '--popup-padding', toCss: x=>parseFloat(x) + 'rem', toJs: x=>parseFloat(x) * PXSCALE},
)
Modal.dynamicProps = Modal.prototype.constructor.dynamicProps.concat(
'label',
'popupLabel'
'popupLabel',
'popupPadding'
)
module.exports = Modal

View file

@ -393,14 +393,16 @@
.modal-container {
--widget-padding: 4rem;
--widget-padding: -1rem;
--popup-padding: 4rem;
--color-text-on: var(--color-background);
--alpha-fill-off: 0.15;
--alpha-fill-on: .75;
> .toggle {
--widget-padding: -1rem;
// --widget-padding: -1rem;
position: absolute;
top:0;
@ -479,6 +481,8 @@
> .popup-content {
// contain:unset; // == no restrain
padding: 0;
--widget-padding: var(--popup-padding);
&:before {
content: none;
}