@jjlmoya/utils-tabletop 1.43.0 → 1.45.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
|
@@ -38,13 +38,14 @@ const ui = getCategoryUi(locale);
|
|
|
38
38
|
<ProductionStructuredData locale={locale} {content} {publicPath} categoryTitle={categoryTitle} categoryHref={categoryHref || publicCategoryPath} />
|
|
39
39
|
</Fragment>
|
|
40
40
|
<section class="utility-section-production"><SEOComponent locale={locale} /></section>
|
|
41
|
-
{content.bibliography
|
|
41
|
+
{(content.bibliography?.length ?? 0) > 0 && <section class="utility-section-production"><BibliographyComponent locale={locale} /></section>}
|
|
42
42
|
{relatedTools.length > 0 && <section class="utility-related-production" aria-labelledby="related-tools-title"><div class="utility-related-heading"><span class="utility-related-eyebrow">{ui.relatedEyebrow}</span><h2 id="related-tools-title">{ui.moreToolsIn} {categoryTitle}</h2></div><div class="utility-related-grid">{relatedTools.map((tool, index) => <a href={tool.href} class="utility-related-card"><span class="utility-related-index">{String(index + 1).padStart(2, "0")}</span><span class="utility-related-icon"><Icon name={tool.icon} /></span><h3>{tool.title}</h3><p>{tool.description}</p><span class="utility-related-cta">{ui.openTool} <Icon name="mdi:arrow-top-right" /></span></a>)}</div></section>}
|
|
43
43
|
</div>
|
|
44
44
|
</div>
|
|
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
|
+
}
|