Sha256: 4c5e6e6cd67227625cf9c97d22684aed6c4107bfbbc84373a13f17829a66b924

Contents?: true

Size: 752 Bytes

Versions: 31

Compression:

Stored size: 752 Bytes

Contents

import { createHtmlElement } from "alchemy_admin/utils/dom_helpers"

export default class Spinner {
  constructor(size, color = "currentColor") {
    this.size = size
    this.color = color
    this.spinner = undefined
  }

  /**
   * @returns {HTMLElement|undefined}
   */
  get el() {
    return this.spinner
  }
  /**
   * @param {HTMLElement|undefined} parent
   */
  spin(parent) {
    if (typeof parent === "undefined") {
      parent = document.body
    }
    this.spinner = createHtmlElement(
      `<alchemy-spinner size="${this.size}" color="${this.color}"></alchemy-spinner>`
    )
    parent.append(this.spinner)
    return this
  }

  stop() {
    if (this.spinner) {
      this.spinner.remove()
      this.spinner = undefined
    }
  }
}

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
alchemy_cms-7.3.5 app/javascript/alchemy_admin/spinner.js
alchemy_cms-7.2.8 app/javascript/alchemy_admin/spinner.js
alchemy_cms-7.1.13 app/javascript/alchemy_admin/spinner.js
alchemy_cms-7.3.4 app/javascript/alchemy_admin/spinner.js
alchemy_cms-7.3.3 app/javascript/alchemy_admin/spinner.js
alchemy_cms-7.3.2 app/javascript/alchemy_admin/spinner.js
alchemy_cms-7.2.7 app/javascript/alchemy_admin/spinner.js
alchemy_cms-7.3.1 app/javascript/alchemy_admin/spinner.js
alchemy_cms-7.3.0 app/javascript/alchemy_admin/spinner.js
alchemy_cms-7.2.6 app/javascript/alchemy_admin/spinner.js
alchemy_cms-7.2.5 app/javascript/alchemy_admin/spinner.js
alchemy_cms-7.1.12 app/javascript/alchemy_admin/spinner.js
alchemy_cms-7.2.4 app/javascript/alchemy_admin/spinner.js
alchemy_cms-7.1.11 app/javascript/alchemy_admin/spinner.js
alchemy_cms-7.2.3 app/javascript/alchemy_admin/spinner.js
alchemy_cms-7.1.10 app/javascript/alchemy_admin/spinner.js
alchemy_cms-7.2.2 app/javascript/alchemy_admin/spinner.js
alchemy_cms-7.1.9 app/javascript/alchemy_admin/spinner.js
alchemy_cms-7.2.1 app/javascript/alchemy_admin/spinner.js
alchemy_cms-7.1.8 app/javascript/alchemy_admin/spinner.js