Sha256: 58d8abecd3cbefb123c48afedbbebe2642d0af57f8aed608e6d4143eb8e177b7

Contents?: true

Size: 1.2 KB

Versions: 41

Compression:

Stored size: 1.2 KB

Contents

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

41 entries across 41 versions & 1 rubygems

Version Path
coveragebook_components-0.10.0 app/components/coco/app/elements/toolbar/toolbar.js
coveragebook_components-0.9.1 app/components/coco/app/elements/toolbar/toolbar.js
coveragebook_components-0.9.0 app/components/coco/app/elements/toolbar/toolbar.js
coveragebook_components-0.8.9 app/components/coco/app/elements/toolbar/toolbar.js
coveragebook_components-0.8.8 app/components/coco/app/elements/toolbar/toolbar.js
coveragebook_components-0.8.7 app/components/coco/app/elements/toolbar/toolbar.js
coveragebook_components-0.8.6 app/components/coco/app/elements/toolbar/toolbar.js
coveragebook_components-0.8.5 app/components/coco/app/elements/toolbar/toolbar.js
coveragebook_components-0.8.4 app/components/coco/app/elements/toolbar/toolbar.js
coveragebook_components-0.8.3 app/components/coco/app/elements/toolbar/toolbar.js
coveragebook_components-0.8.2 app/components/coco/app/elements/toolbar/toolbar.js
coveragebook_components-0.8.1 app/components/coco/app/elements/toolbar/toolbar.js
coveragebook_components-0.8.0 app/components/coco/app/elements/toolbar/toolbar.js
coveragebook_components-0.8.0.beta.3 app/components/coco/app/elements/toolbar/toolbar.js
coveragebook_components-0.8.0.beta.2 app/components/coco/app/elements/toolbar/toolbar.js
coveragebook_components-0.8.0.beta.1 app/components/coco/app/elements/toolbar/toolbar.js
coveragebook_components-0.7.10 app/components/coco/app/elements/toolbar/toolbar.js
coveragebook_components-0.7.9 app/components/coco/app/elements/toolbar/toolbar.js
coveragebook_components-0.7.8 app/components/coco/app/elements/toolbar/toolbar.js
coveragebook_components-0.7.7 app/components/coco/app/elements/toolbar/toolbar.js