import style from './LoadingBar.less';

class LoadingBar {
  className: any;
  hodor: HTMLDivElement;
  constructor() {
    this.className = style['loading-bar'];
    this.hodor = document.createElement('div');
    this.hodor.className = this.className;
  }

  show() {
    document.body.appendChild(this.hodor);
  }

  hide() {
    if (this.hasAdded()) {
      document.body.removeChild(this.hodor);
    }
  }

  hasAdded() {
    return document.getElementsByClassName(this.className).length > 0;
  }
}

export default new LoadingBar();
