From 080319c1088ff7dced251a4abd8dbcc7b7f1b756 Mon Sep 17 00:00:00 2001 From: Dierk Koenig Date: Sun, 15 Dec 2024 22:38:08 +0100 Subject: [PATCH] popover: adapt the styling such that FF and Safari play nicely with the anchor positioning. More to understand about that. --- docs/css/kolibri-base.css | 26 ++++++++++++------- .../examples/workday/simpleDayProjector.js | 8 +++--- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/docs/css/kolibri-base.css b/docs/css/kolibri-base.css index 1359abf9..dd1689ac 100644 --- a/docs/css/kolibri-base.css +++ b/docs/css/kolibri-base.css @@ -238,6 +238,9 @@ a.skip-link:not(:focus):not(:active) { /* --- end of utility classes --- */ + +/* --- experimental popover and anchor positioning --- */ + [popover] { /* style that pops for all elements with popover attribute */ flex-direction: column; gap: .5em; @@ -257,24 +260,29 @@ a.skip-link:not(:focus):not(:active) { animation-timing-function: ease-in-out; animation-fill-mode: forwards; } - :popover-open::backdrop { - background-color: color-mix(in hsl, white, transparent 70%); - transition: background-color 1s linear; - @starting-style { - background-color: transparent; - } - } + + /*For the moment, don't do this as it makes the UI appear flickering when*/ + /*the popover closes. Sadly, there seems to be no way to transition back on close. Reserve for later.*/ + /*:popover-open::backdrop {*/ + /* background-color: color-mix(in hsl, white, transparent 70%);*/ + /* transition: background-color 1s linear;*/ + /* @starting-style {*/ + /* background-color: transparent;*/ + /* }*/ + /*}*/ .popover_anchor { /* anchor-name will be set on the element */ position: relative; + display: inline-flex; /* for FF and Safari or it does not always work */ } .popover_tooltip { /* position-anchor will be set on the element */ - position: absolute; /* override the popover-hidden default */ + position: absolute; /* override the popover-hidden default */ inset: unset; - top: anchor(bottom); + top: anchor(top); /* dirty trick for FF and Safari (anchor(bottom) does not work) */ left: anchor(left); + translate: 0 1.2lh; /* dirty trick for FF and Safari */ transform-origin: top center; /* makes expandY a drop-down */ } diff --git a/docs/src/examples/workday/simpleDayProjector.js b/docs/src/examples/workday/simpleDayProjector.js index 4d5b85f2..0bcb18b2 100644 --- a/docs/src/examples/workday/simpleDayProjector.js +++ b/docs/src/examples/workday/simpleDayProjector.js @@ -32,10 +32,10 @@ const projectDay = dayController => { /** @type {HTMLDivElement} */ const amDiv = elements[0]; /** @type {HTMLDivElement} */ const pmDiv = elements[1]; - amDiv.querySelector("#am_start").append(amStartViewLabel, amStartViewSpan); - amDiv.querySelector("#am_end") .append(amEndViewLabel, amEndViewSpan); - pmDiv.querySelector("#pm_start").append(pmStartViewLabel, pmStartViewSpan); - pmDiv.querySelector("#pm_end") .append(pmEndViewLabel, pmEndViewSpan); + amDiv.querySelector("#am_start").replaceWith(amStartViewLabel, amStartViewSpan); + amDiv.querySelector("#am_end") .replaceWith(amEndViewLabel, amEndViewSpan); + pmDiv.querySelector("#pm_start").replaceWith(pmStartViewLabel, pmStartViewSpan); + pmDiv.querySelector("#pm_end") .replaceWith(pmEndViewLabel, pmEndViewSpan); // no special view and data binding since that is all done by the simpleInputProjector