import tokens from "@config/tokens.cjs"; import { CocoComponent } from "@js/coco"; const mobileMaxWidth = parseInt(tokens.app.screens.sm, 10); export default CocoComponent("appSidebarNav", () => { return { sizeObserver: null, mobileLayout: true, init() { this.sizeObserver = new ResizeObserver( Alpine.throttle((entries) => { this.$nextTick(() => { const bodyWidth = entries[0].contentRect.width; this.mobileLayout = bodyWidth < mobileMaxWidth; }); }, 20) ); this.sizeObserver.observe(document.documentElement); }, destroy() { this.sizeObserver && this.sizeObserver.disconnect(); }, }; });