Sha256: 33b9a3c54cd999d7900ea3edcfb173a4bfaeba0cc28c58764ba57100609f66be

Contents?: true

Size: 719 Bytes

Versions: 2

Compression:

Stored size: 719 Bytes

Contents

import tokens from "@config/tokens.js";
import { CocoComponent } from "@assets/js/coco/component";

const mobileMaxWidth = parseInt(tokens.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

2 entries across 2 versions & 1 rubygems

Version Path
coveragebook_components-0.16.0 app/components/coco/app/sidebar_nav/navbar/navbar.js
coveragebook_components-0.15.0 app/components/coco/app/sidebar_nav/navbar/navbar.js