Sha256: c6467ad574f68ce1f0173b00567f18a3445e93baae4e81547a17657e54fdcaa3

Contents?: true

Size: 1.22 KB

Versions: 24

Compression:

Stored size: 1.22 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();
      }
    },

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

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

    get _tooltip() {
      return tooltip;
    },

    _spinning: false,
  };
}

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
lookbook-1.2.0 app/components/lookbook/button/component.js
lookbook-1.1.1 app/components/lookbook/button/component.js
lookbook-1.1.0 app/components/lookbook/button/component.js
lookbook-1.0.8 app/components/lookbook/button/component.js
lookbook-1.0.7 app/components/lookbook/button/component.js
lookbook-1.0.6 app/components/lookbook/button/component.js
lookbook-1.0.5 app/components/lookbook/button/component.js
lookbook-1.0.4 app/components/lookbook/button/component.js
lookbook-1.0.3 app/components/lookbook/button/component.js
lookbook-1.0.2 app/components/lookbook/button/component.js
lookbook-1.0.1 app/components/lookbook/button/component.js
lookbook-1.0.0 app/components/lookbook/button/component.js
lookbook-1.0.0.rc.3 app/components/lookbook/button/component.js
lookbook-1.0.0.rc.2 app/components/lookbook/button/component.js
lookbook-1.0.0.rc.1 app/components/lookbook/button/component.js
lookbook-1.0.0.beta.8 app/components/lookbook/button/component.js
lookbook-1.0.0.beta.7 app/components/lookbook/button/component.js
lookbook-1.0.0.beta.6 app/components/lookbook/button/component.js
lookbook-1.0.0.beta.5 app/components/lookbook/button/component.js
lookbook-1.0.0.beta.4 app/components/lookbook/button/component.js