Sha256: d328d3678d5d903fa810a3203bcd4ea4e44d81d112e62dcecaa2da6021066b4b

Contents?: true

Size: 1022 Bytes

Versions: 25

Compression:

Stored size: 1022 Bytes

Contents

import { CocoComponent } from "@js/coco";
import { getHiddenElementDimensions as getSize } from "@helpers/dom";
import tokens from "@config/tokens.cjs";

export default CocoComponent("appNavBar", () => {
  const mobileMaxWidth = parseInt(tokens.app.screens.md, 10);
  return {
    mobile: true,
    init() {
      const sizeObserver = new ResizeObserver(
        Alpine.throttle((entries) => {
          this.$nextTick(() => {
            const navWidth = entries[0].contentRect.width;
            const linksWidth = this.$refs.links.offsetWidth;
            const primaryWidth = getSize(this.$refs.primaryLinks, "flex").width;
            const secondaryWidth = getSize(
              this.$refs.secondaryLinks,
              "flex"
            ).width;
            const difference = linksWidth - primaryWidth - secondaryWidth;

            this.mobile =
              navWidth < mobileMaxWidth || this.mobudifference <= 50;
          });
        }, 20)
      );

      sizeObserver.observe(this.$root);
    },
  };
});

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
coveragebook_components-0.7.10 app/components/coco/app/blocks/nav_bar/nav_bar.js
coveragebook_components-0.7.9 app/components/coco/app/blocks/nav_bar/nav_bar.js
coveragebook_components-0.7.8 app/components/coco/app/blocks/nav_bar/nav_bar.js
coveragebook_components-0.7.7 app/components/coco/app/blocks/nav_bar/nav_bar.js
coveragebook_components-0.7.6 app/components/coco/app/blocks/nav_bar/nav_bar.js
coveragebook_components-0.7.5 app/components/coco/app/blocks/nav_bar/nav_bar.js
coveragebook_components-0.7.4 app/components/coco/app/blocks/nav_bar/nav_bar.js
coveragebook_components-0.7.3 app/components/coco/app/blocks/nav_bar/nav_bar.js
coveragebook_components-0.7.2 app/components/coco/app/blocks/nav_bar/nav_bar.js
coveragebook_components-0.7.1 app/components/coco/app/blocks/nav_bar/nav_bar.js
coveragebook_components-0.7.0 app/components/coco/app/blocks/nav_bar/nav_bar.js
coveragebook_components-0.6.5 app/components/coco/app/blocks/nav_bar/nav_bar.js
coveragebook_components-0.6.4 app/components/coco/app/blocks/nav_bar/nav_bar.js
coveragebook_components-0.6.3 app/components/coco/app/blocks/nav_bar/nav_bar.js
coveragebook_components-0.6.2 app/components/coco/app/blocks/nav_bar/nav_bar.js
coveragebook_components-0.6.1 app/components/coco/app/blocks/nav_bar/nav_bar.js
coveragebook_components-0.6.0 app/components/coco/app/blocks/nav_bar/nav_bar.js
coveragebook_components-0.5.7 app/components/coco/app/blocks/nav_bar/nav_bar.js
coveragebook_components-0.5.6 app/components/coco/app/blocks/nav_bar/nav_bar.js
coveragebook_components-0.5.5 app/components/coco/app/blocks/nav_bar/nav_bar.js