Sha256: 8d0dd74f94e8fd4ee28cae896bfad63247a7a97c9fa24355fd8643d7b054766f

Contents?: true

Size: 721 Bytes

Versions: 7

Compression:

Stored size: 721 Bytes

Contents

import tokens from "@config/tokens.cjs";
import { CocoComponent } from "@assets/js/shared/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();
    },
  };
});

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
coveragebook_components-0.12.2 app/components/coco/app/blocks/sidebar_nav/navbar/navbar.js
coveragebook_components-0.12.1 app/components/coco/app/blocks/sidebar_nav/navbar/navbar.js
coveragebook_components-0.12.0 app/components/coco/app/blocks/sidebar_nav/navbar/navbar.js
coveragebook_components-0.11.0 app/components/coco/app/blocks/sidebar_nav/navbar/navbar.js
coveragebook_components-0.10.1.beta.2 app/components/coco/app/blocks/sidebar_nav/navbar/navbar.js
coveragebook_components-0.10.1.beta.1 app/components/coco/app/blocks/sidebar_nav/navbar/navbar.js
coveragebook_components-0.10.1.beta.0 app/components/coco/app/blocks/sidebar_nav/navbar/navbar.js