@jjlmoya/utils-pets 1.25.0 → 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -45,6 +45,7 @@ const ui = getCategoryUi(locale);
|
|
|
45
45
|
</ProductionPage>
|
|
46
46
|
|
|
47
47
|
<script>
|
|
48
|
+
import { observeWidgetHeight } from "../mfe/widget-height";
|
|
48
49
|
const isWidget = new URLSearchParams(window.location.search).get("widget") === "true";
|
|
49
50
|
const page = document.querySelector<HTMLElement>(".utility-production");
|
|
50
51
|
const container = document.querySelector<HTMLElement>(".utility-tool-production");
|
|
@@ -60,11 +61,10 @@ const ui = getCategoryUi(locale);
|
|
|
60
61
|
document.querySelector('[data-zoom="reset"]')?.addEventListener("click", () => { zoom = 1; applyZoom(); localStorage.removeItem("gamebob-utility-zoom"); });
|
|
61
62
|
if (isWidget) {
|
|
62
63
|
document.body.classList.add("utility-widget-body");
|
|
63
|
-
|
|
64
|
-
page.classList.add("utility-widget-mode");
|
|
65
|
-
}
|
|
64
|
+
page?.classList.add("utility-widget-mode");
|
|
66
65
|
}
|
|
67
66
|
applyZoom();
|
|
67
|
+
if (isWidget && container) observeWidgetHeight(container);
|
|
68
68
|
</script>
|
|
69
69
|
|
|
70
70
|
<style>
|
|
@@ -88,7 +88,7 @@ const ui = getCategoryUi(locale);
|
|
|
88
88
|
margin-top: 0;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
.utility-production.utility-widget-mode .utility-production-inner > :not(.utility-tool-production) {
|
|
91
|
+
:global(.utility-production.utility-widget-mode .utility-production-inner > :not(.utility-tool-production)) {
|
|
92
92
|
display: none;
|
|
93
93
|
}
|
|
94
94
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function observeWidgetHeight(container: HTMLElement): void {
|
|
2
|
+
if (window.parent === window) return;
|
|
3
|
+
|
|
4
|
+
const pathSlug = window.location.pathname.split("/").filter(Boolean).pop() ?? "utility";
|
|
5
|
+
const widgetId = new URLSearchParams(window.location.search).get("id") ?? `jj-widget-${pathSlug}`;
|
|
6
|
+
const reportHeight = (height: number) => {
|
|
7
|
+
if (height > 50) {
|
|
8
|
+
window.parent.postMessage({ jjlmoyaHeight: Math.ceil(height), jjlmoyaId: widgetId }, "*");
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
const observer = new ResizeObserver(([entry]) => reportHeight(entry?.contentRect.height ?? 0));
|
|
12
|
+
|
|
13
|
+
observer.observe(container);
|
|
14
|
+
}
|