Sha256: 715e86db6bed9c306854d5252b723fbeac1e7c9277d1ed93b7e838955b6d51b7

Contents?: true

Size: 1.41 KB

Versions: 17

Compression:

Stored size: 1.41 KB

Contents

import tippy from "~/app/assets/lookbook/js/lib/tippy";
import { initTooltip } from "~/app/assets/lookbook/js/components/tooltip";

export default function buttonComponent() {
  let tooltip = null;
  let dropdown = null;

  return {
    init() {
      if (this.$refs.tooltip) {
        tooltip = initTooltip(this, {
          target: this.$refs.icon,
        });
      }

      if (this.$refs.dropdown) {
        dropdown = tippy(this.$el, {
          content: this.$refs.dropdown.innerHTML,
          trigger: "click",
          theme: "menu",
          triggerTarget: this.$el,
          interactive: true,
          zIndex: 99999,
          onShow: () => {
            if (!this.$store.settings.showTooltips) {
              return false;
            }
            this.$dispatch("dropdown:show", { dropdown: this });
          },
          onHide: () => this.$dispatch("dropdown:hide", { dropdown: this }),
        });
      }
    },

    hideDropdown() {
      if (dropdown) {
        dropdown.hide();
      }
    },

    updateDropdown() {
      if (dropdown) {
        dropdown.hide();
        this.$nextTick(() => {
          dropdown.setContent(this.$refs.dropdown.innerHTML);
        });
      }
    },

    startSpin() {
      this._spinning = true;
    },

    stopSpin(delay = 0) {
      setTimeout(() => (this._spinning = false), delay);
    },

    get _tooltip() {
      return tooltip;
    },

    _spinning: false,
  };
}

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
lookbook-1.5.5 app/components/lookbook/button/component.js
lookbook-1.5.4 app/components/lookbook/button/component.js
lookbook-1.5.3 app/components/lookbook/button/component.js
lookbook-1.5.2 app/components/lookbook/button/component.js
lookbook-1.5.1 app/components/lookbook/button/component.js
lookbook-1.5.0 app/components/lookbook/button/component.js
lookbook-1.4.5 app/components/lookbook/button/component.js
lookbook-1.4.4 app/components/lookbook/button/component.js
lookbook-1.4.3 app/components/lookbook/button/component.js
lookbook-1.4.2 app/components/lookbook/button/component.js
lookbook-1.4.1 app/components/lookbook/button/component.js
lookbook-1.4.0 app/components/lookbook/button/component.js
lookbook-1.3.4 app/components/lookbook/button/component.js
lookbook-1.3.3 app/components/lookbook/button/component.js
lookbook-1.3.1 app/components/lookbook/button/component.js
lookbook-1.3.0 app/components/lookbook/button/component.js
lookbook-1.2.1 app/components/lookbook/button/component.js