Sha256: 6846e90c7078fca7cd87ebd111db0e5fd9956cadf078e16e9de5c54a904fecb1

Contents?: true

Size: 1.22 KB

Versions: 7

Compression:

Stored size: 1.22 KB

Contents

import { CocoComponent } from "@assets/js/shared/coco";
import { getComponent } from "@helpers/alpine";

export default CocoComponent("appToolbar", () => {
  return {
    ready: false,
    startSectionWidth: null,
    endSectionWidth: null,

    get startGroupEl() {
      return this.$refs.startSection.firstElementChild;
    },

    get endGroupEl() {
      return this.$refs.endSection.firstElementChild;
    },

    get groups() {
      return [this.startGroupEl, this.endGroupEl]
        .filter((g) => g)
        .map((el) => getComponent(el, false));
    },

    init() {
      const toolbarWidth = this.$el.offsetWidth;
      let startSectionWidth = 0;
      let endSectionWidth = 0;

      if (this.startGroupEl) {
        startSectionWidth = Math.ceil(
          (this.startGroupEl.offsetWidth / toolbarWidth) * 100
        );
      }

      if (this.endGroupEl) {
        endSectionWidth = Math.ceil(
          (this.endGroupEl.offsetWidth / toolbarWidth) * 100
        );
      }

      this.$nextTick(() => {
        this.startSectionWidth = `${startSectionWidth}%`;
        this.endSectionWidth = `${endSectionWidth}%`;
        this.groups.forEach((group) => group.onResize());
        this.ready = true;
      });
    },
  };
});

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
coveragebook_components-0.12.2 app/components/coco/app/elements/toolbar/toolbar.js
coveragebook_components-0.12.1 app/components/coco/app/elements/toolbar/toolbar.js
coveragebook_components-0.12.0 app/components/coco/app/elements/toolbar/toolbar.js
coveragebook_components-0.11.0 app/components/coco/app/elements/toolbar/toolbar.js
coveragebook_components-0.10.1.beta.2 app/components/coco/app/elements/toolbar/toolbar.js
coveragebook_components-0.10.1.beta.1 app/components/coco/app/elements/toolbar/toolbar.js
coveragebook_components-0.10.1.beta.0 app/components/coco/app/elements/toolbar/toolbar.js