update popover position logic

This commit is contained in:
Jordan Blasenhauer 2024-08-15 11:37:37 +02:00
parent c15133a3b6
commit 47aa48f068
5 changed files with 16 additions and 7 deletions

View file

@ -323,7 +323,7 @@ def instances_new_form() -> dict:
popovers=[
{
"iconName": "exclamation",
"iconColor": "yellow-darker",
"color": "yellow-darker",
"text": "instances_hostname_warning_desc",
},
{

View file

@ -87,9 +87,18 @@ function showPopover() {
// Position popover relative to btn
const popoverBtnRect = popoverBtn.value.getBoundingClientRect();
popoverContainer.value.style.right = `${
window.innerWidth - popoverBtnRect.left - popoverBtnRect.width / 1.5
}px`;
const popoverContainerRect = popoverContainer.value.getBoundingClientRect();
const popoverGroup =
popoverBtn.value.parentElement.querySelectorAll(".popover-btn");
const popoverGroupNums = popoverGroup.length;
const popoverIndex = Array.from(popoverGroup).indexOf(popoverBtn.value);
popoverContainer.value.style.transform = `translateX(-${
popoverContainerRect.width / 2 -
(popoverBtnRect.width * popoverGroupNums) / 2 -
popoverBtnRect.width * (popoverIndex - popoverGroupNums)
}px) translateY(${
popoverContainerRect.height / 2 - popoverBtnRect.height / 2 + 4
}px)`;
// Show popover
setTimeout(() => {

File diff suppressed because one or more lines are too long

View file

@ -651,7 +651,7 @@ body {
}
.popover-container {
@apply pointer-events-none fixed max-w-[80vw] sm:max-w-[200px] justify-center items-center dark:brightness-90 transition rounded-md p-3;
@apply pointer-events-none fixed max-w-[80vw] sm:max-w-[200px] w-full justify-center items-center dark:brightness-90 transition rounded-md p-3;
}
.open.popover-container {

File diff suppressed because one or more lines are too long