Sha256: e8d547ae32b44ff3b5b2582313052101f8b19dc376312e9e04a2b78372bac312

Contents?: true

Size: 1.22 KB

Versions: 23

Compression:

Stored size: 1.22 KB

Contents

import { CocoComponent } from "@assets/js/coco/component";
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

23 entries across 23 versions & 1 rubygems

Version Path
coveragebook_components-0.19.9 app/components/coco/buttons/toolbar/toolbar.js
coveragebook_components-0.19.8 app/components/coco/buttons/toolbar/toolbar.js
coveragebook_components-0.19.7 app/components/coco/buttons/toolbar/toolbar.js
coveragebook_components-0.19.6 app/components/coco/buttons/toolbar/toolbar.js
coveragebook_components-0.19.5 app/components/coco/buttons/toolbar/toolbar.js
coveragebook_components-0.19.4 app/components/coco/buttons/toolbar/toolbar.js
coveragebook_components-0.19.3 app/components/coco/buttons/toolbar/toolbar.js
coveragebook_components-0.19.2 app/components/coco/buttons/toolbar/toolbar.js
coveragebook_components-0.19.1 app/components/coco/buttons/toolbar/toolbar.js
coveragebook_components-0.19.0 app/components/coco/buttons/toolbar/toolbar.js
coveragebook_components-0.18.8 app/components/coco/buttons/toolbar/toolbar.js
coveragebook_components-0.18.7 app/components/coco/buttons/toolbar/toolbar.js
coveragebook_components-0.18.0 app/components/coco/buttons/toolbar/toolbar.js
coveragebook_components-0.17.7 app/components/coco/buttons/toolbar/toolbar.js
coveragebook_components-0.17.6 app/components/coco/buttons/toolbar/toolbar.js
coveragebook_components-0.17.5 app/components/coco/buttons/toolbar/toolbar.js
coveragebook_components-0.17.4 app/components/coco/buttons/toolbar/toolbar.js
coveragebook_components-0.17.3 app/components/coco/buttons/toolbar/toolbar.js
coveragebook_components-0.17.2 app/components/coco/buttons/toolbar/toolbar.js
coveragebook_components-0.17.1 app/components/coco/buttons/toolbar/toolbar.js