Small Embed Fixes (#7513)

* Fix bg beyond rounded border in embed

* Consider margin as well for mainElement height

* Fix loader positioning

* Give better name to embed artifacts

---------

Co-authored-by: Alex van Andel <[email protected]>
This commit is contained in:
Hariom BalharaandAlex van Andel authored and GitHub committed 2023-03-04 16:11:04 +00:00
1 parent 9d7cd73c7f
commit 07399974ce
3 files changed
+13 -6

No files matched your search

@@ -1,5 +1,5 @@
const html = `<div id="wrapper" style="top:50%; left:50%" class="absolute z-highest">
<div style="transform:translate(-50%,-50%)" class="loader border-brand dark:border-darkmodebrand">
const html = `<div id="wrapper" style="top:50%; left:50%;transform:translate(-50%,-50%)" class="absolute z-highest">
<div class="loader border-brand dark:border-darkmodebrand">
<span class="loader-inner bg-brand dark:bg-darkmodebrand"></span>
</div>
<div id="error" style="transform:translate(-50%,-50%)" class="hidden">
@@ -340,8 +340,15 @@ function keepParentInformedAboutDimensionChanges() {
throw new Error("Main element should be an HTMLElement");
}
const contentHeight = mainElement.offsetHeight;
const contentWidth = mainElement.offsetWidth;
const mainElementStyles = getComputedStyle(mainElement);
const contentHeight =
mainElement.offsetHeight +
parseInt(mainElementStyles.marginTop) +
parseInt(mainElementStyles.marginBottom);
const contentWidth =
mainElement.offsetWidth +
parseInt(mainElementStyles.marginLeft) +
parseInt(mainElementStyles.marginRight);
// During first render let iframe tell parent that how much is the expected height to avoid scroll.
// Parent would set the same value as the height of iframe which would prevent scroll.