modal: add popupLeft and popupTop properties (#265)
This commit is contained in:
parent
ea4a21cf2d
commit
bec71b5c1b
5 changed files with 48 additions and 10 deletions
|
|
@ -6,6 +6,9 @@
|
|||
- dropped supported for `.js` sessions (deprecated in 0.20.0)
|
||||
- bug fixes
|
||||
- zeroconf: unpublish when shutting down
|
||||
- widgets
|
||||
- modal: added `popupLeft` and `popupTop` properties
|
||||
|
||||
|
||||
## 0.28.3
|
||||
|
||||
|
|
|
|||
|
|
@ -124,6 +124,12 @@ Modals are buttons that turn into a centered popup panels when enabled. They can
|
|||
- default: `100%`
|
||||
- usage: sets the modal's size once opened
|
||||
|
||||
### `popupLeft` / `popupTop`
|
||||
- type: `number|percentage`
|
||||
- default: `auto`
|
||||
- usage: sets the modal's position once opened (centered by default)
|
||||
|
||||
|
||||
### `popupLabel`
|
||||
- type: `string`
|
||||
- default: `empty`
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ module.exports = class Modal extends Panel {
|
|||
popupLabel:'',
|
||||
popupWidth:'80%',
|
||||
popupHeight:'80%',
|
||||
popupLeft:'auto',
|
||||
popupTop:'auto',
|
||||
layout:'',
|
||||
spacing:0,
|
||||
|
||||
|
|
@ -74,11 +76,23 @@ module.exports = class Modal extends Panel {
|
|||
this.container.appendChild(this.popup)
|
||||
|
||||
// convert dimensions / coordinates to rem
|
||||
var width = parseFloat(this.getProp('popupWidth'))==this.getProp('popupWidth')?parseFloat(this.getProp('popupWidth'))+'rem' : this.getProp('popupWidth'),
|
||||
height = parseFloat(this.getProp('popupHeight'))==this.getProp('popupHeight')?parseFloat(this.getProp('popupHeight'))+'rem' : this.getProp('popupHeight')
|
||||
var geometry = {}
|
||||
for (var g of ['Width', 'Height', 'Left', 'Top']) {
|
||||
geometry[g] = parseFloat(this.getProp('popup' + g)) == this.getProp('popup' + g) ? parseFloat(this.getProp('popup' + g)) + 'rem' : this.getProp('popup' + g)
|
||||
}
|
||||
|
||||
this.popup.style.setProperty('--width', width)
|
||||
this.popup.style.setProperty('--height', height)
|
||||
this.popup.style.setProperty('--width', geometry.Width)
|
||||
this.popup.style.setProperty('--height', geometry.Height)
|
||||
|
||||
if (geometry.Left !== 'auto') {
|
||||
this.popup.style.setProperty('--left', geometry.Left)
|
||||
this.popup.classList.add('x-positionned')
|
||||
}
|
||||
|
||||
if (geometry.Top !== 'auto') {
|
||||
this.popup.style.setProperty('--top', geometry.Top)
|
||||
this.popup.classList.add('y-positionned')
|
||||
}
|
||||
|
||||
DOM.get(this.popup, '.closer')[0].addEventListener('fast-click', (e)=>{
|
||||
e.detail.preventDefault = true
|
||||
|
|
|
|||
|
|
@ -496,7 +496,8 @@ body {
|
|||
right:0;
|
||||
bottom:0;
|
||||
padding:10%;
|
||||
align-items: center;
|
||||
align-items:center;
|
||||
justify-content: center;
|
||||
z-index:1000000;
|
||||
transform: translate3d(0,0,0);
|
||||
display: none;
|
||||
|
|
@ -506,10 +507,10 @@ body {
|
|||
&:before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top:-40rem;
|
||||
left:-40rem;
|
||||
right:-40rem;
|
||||
bottom:-40rem;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
background:var(--color-bg);
|
||||
opacity: .5;
|
||||
}
|
||||
|
|
@ -544,7 +545,6 @@ body {
|
|||
align-items: stretch;
|
||||
width:auto;
|
||||
max-width:600rem;
|
||||
margin:0 auto;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
box-shadow: 1rem 0 0 0 var(--color-bg),
|
||||
|
|
|
|||
|
|
@ -201,6 +201,7 @@
|
|||
}
|
||||
> .popup {
|
||||
padding:0;
|
||||
|
||||
> .popup-wrapper {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
|
|
@ -224,6 +225,20 @@
|
|||
z-index: 1;
|
||||
}
|
||||
}
|
||||
|
||||
&.x-positionned {
|
||||
justify-content: flex-start;
|
||||
> .popup-wrapper {
|
||||
margin-left: var(--left);
|
||||
}
|
||||
}
|
||||
&.y-positionned {
|
||||
align-items:flex-start;
|
||||
> .popup-wrapper {
|
||||
margin-top: var(--top);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
&.editing .popup-wrapper:after {
|
||||
content:"";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue