Sha256: 25581284b843e0666fc53819011faf2a38a3569c4500544857255a0d956e88c4

Contents?: true

Size: 991 Bytes

Versions: 1

Compression:

Stored size: 991 Bytes

Contents

import tippy from "@libs/tippy";
import { CocoComponent } from "@js/coco";
import { navigateTo } from "@helpers/location";

export default CocoComponent("appSidebarNavItem", () => {
  return {
    menu: null,

    init() {
      this.navigateTo = navigateTo;

      if (this.$refs.menu) {
        this.menu = tippy(this.$el, {
          theme: "coco-naked-dropdown",
          placement: this.menuPlacement,
          arrow: false,
          offset: [0, 0],
          trigger: "click",
          interactive: true,
          maxWidth: null,
          content: () => {
            return this.$refs.menu.innerHTML;
          },
        });
      }

      this.$watch("mobileLayout", () => {
        this.onOrientationChange();
      });
    },

    onOrientationChange() {
      if (this.menu) {
        this.menu.setProps({
          placement: this.menuPlacement,
        });
      }
    },

    get menuPlacement() {
      return this.mobileLayout ? "top" : "right-start";
    },
  };
});

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
coveragebook_components-0.8.2 app/components/coco/app/blocks/sidebar_nav_item/sidebar_nav_item.js