From 12630cbb17f0f891495df511f6c343394a0a682b Mon Sep 17 00:00:00 2001 From: bordun Date: Sun, 4 Oct 2020 19:42:29 +0200 Subject: [PATCH] modal: add `popupPadding` property to control the buttons and the container's padding independently --- CHANGELOG.md | 1 + src/client/widgets/containers/modal.js | 22 ++++++++++------------ src/scss/widgets/containers.scss | 8 ++++++-- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b18f060..c00dbd8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/client/widgets/containers/modal.js b/src/client/widgets/containers/modal.js index 4ce7b4b3..949b5856 100644 --- a/src/client/widgets/containers/modal.js +++ b/src/client/widgets/containers/modal.js @@ -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`` 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 diff --git a/src/scss/widgets/containers.scss b/src/scss/widgets/containers.scss index f8f0d0fd..f6c8c965 100644 --- a/src/scss/widgets/containers.scss +++ b/src/scss/widgets/containers.scss @@ -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; }