Skip to content

Commit

Permalink
Merge pull request #1949 from huggla/patch-1
Browse files Browse the repository at this point in the history
Added minimize button to popup
  • Loading branch information
huggla committed Mar 20, 2024
2 parents 03cf143 + e550bf0 commit 1bc7516
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ function render(target) {
<div class="o-popup o-card">
<div class="flex row justify-end">
<div id="o-card-title" class="justify-start margin-y-smaller margin-left text-weight-bold" style="width:100%;"></div>
<button id="o-minimize-button" class="small round margin-top-smaller margin-bottom-auto margin-left-small margin-right-small icon-smallest grey-lightest no-shrink" aria-label="Minimera">
<span class="icon ">_</span>
</button>
<button id="o-close-button" class="small round margin-top-smaller margin-bottom-auto margin-right-small icon-smallest grey-lightest no-shrink" aria-label="Stäng">
<span class="icon ">
<svg>
Expand Down Expand Up @@ -57,6 +60,18 @@ function setContent(config) {
}
}

function minimizePopup() {
const oidentify = document.getElementById('o-identify');
const opopup = document.getElementById('o-popup');
const ocardtitle = document.getElementById('o-card-title');
oidentify.style.display = oidentify.style.display === 'none' ? 'block' : 'none';
opopup.style.width = oidentify.style.display === 'none' ? 'auto' : null;
opopup.style.height = oidentify.style.display === 'none' ? '58px' : '78px';
opopup.children[0].style.position = oidentify.style.display === 'none' ? 'sticky' : null;
opopup.children[0].style.width = oidentify.style.display === 'none' ? 'auto' : null;
ocardtitle.style.display = oidentify.style.display === 'none' ? 'none' : null;
}

/**
* Closes the window and optionally calls a callback set at init
* @param {any} cb
Expand Down Expand Up @@ -85,6 +100,11 @@ export default function popup(target, opts = {}) {
closePopupInternal(closeCb);
evt.preventDefault();
});
const minel = document.querySelector('#o-popup .o-popup #o-minimize-button');
minel.addEventListener('click', (evt) => {
minimizePopup();
evt.preventDefault();
});
}

render(target);
Expand Down

0 comments on commit 1bc7516

Please sign in to comment.