app/assets/js/app.js in coveragebook_components-0.12.2 vs app/assets/js/app.js in coveragebook_components-0.13.0

- old
+ new

@@ -1,14 +1,30 @@ -import packageJSON from "@/package.json" assert { type: "json" }; +import { registerComponents } from "@helpers/alpine"; +import { navigateTo } from "@helpers/location"; +import { Alpine } from "./base/setup"; -console.info("Initializing Coco JS", packageJSON.version); +import components from "@components/**/*.js"; +registerComponents(components); -import "container-query-polyfill"; -import Alpine from "@assets/js/libs/alpine"; +// Global JS navigation handler. +// Optionally uses Turbo for the page navigation. +window.addEventListener("app:navigate", (event) => { + const url = event.detail.url; + if (url) { + delete event.detail.url; + navigateTo(url, event.detail); + } +}); -import "./app/setup"; - -import "./shared/components"; -import "./book/components"; -import "./app/components"; +// Uodate the value of the `--app-height` css variable +// when the viewport size changes. To help work around the +// issues when using 100vh on mobile safari (https://medium.com/quick-code/100vh-problem-with-ios-safari-92ab23c852a8) +function setAppHeightProperty() { + document.documentElement.style.setProperty( + "--app-height", + `${window.innerHeight}px` + ); +} +window.addEventListener("resize", setAppHeightProperty); +setAppHeightProperty(); Alpine.start();