Sha256: 77a82dd53c12422cd991680e717962e47553e24f2eb075245ac680a578c33ba6

Contents?: true

Size: 1.63 KB

Versions: 22

Compression:

Stored size: 1.63 KB

Contents

import tippy from "~/assets/js/lib/tippy";
import { initTooltip } from "~/assets/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.dropdownContent) {
        dropdown = tippy(this.$el, {
          content: this.dropdownContent,
          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 }),
        });
      }
    },

    get dropdownContent() {
      if (this.$root && this.$root.id) {
        const dropdown = document.querySelector(
          `[data-dropdown-id="${this.$root.id}"]`
        );
        return dropdown ? dropdown.innerHTML : null;
      }
      return null;
    },

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

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

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

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

    get _tooltip() {
      return tooltip;
    },

    _spinning: false,
  };
}

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
lookbook-2.3.4 app/components/lookbook/button/component.js
lookbook-2.3.3 app/components/lookbook/button/component.js
lookbook-2.3.2 app/components/lookbook/button/component.js
lookbook-2.3.0 app/components/lookbook/button/component.js
lookbook-2.2.2 app/components/lookbook/button/component.js
lookbook-2.2.1 app/components/lookbook/button/component.js
lookbook-2.2.0 app/components/lookbook/button/component.js
lookbook-2.1.1 app/components/lookbook/button/component.js
lookbook-2.1.0 app/components/lookbook/button/component.js
lookbook-2.0.5 app/components/lookbook/button/component.js
lookbook-2.0.4 app/components/lookbook/button/component.js
lookbook-2.0.3 app/components/lookbook/button/component.js
lookbook-2.0.2 app/components/lookbook/button/component.js
lookbook-2.0.1 app/components/lookbook/button/component.js
lookbook-2.0.0 app/components/lookbook/button/component.js
lookbook-2.0.0.rc.3 app/components/lookbook/button/component.js
lookbook-2.0.0.rc.2 app/components/lookbook/button/component.js
lookbook-2.0.0.rc.1 app/components/lookbook/button/component.js
lookbook-2.0.0.beta.9 app/components/lookbook/button/component.js
lookbook-2.0.0.beta.8 app/components/lookbook/button/component.js