Sha256: 8a617c7b60a91f7d709b2d1c45456009f67b298e4785474d7ceda4b36c6153fe

Contents?: true

Size: 1019 Bytes

Versions: 15

Compression:

Stored size: 1019 Bytes

Contents

import "iframe-resizer/js/iframeResizer";

export default function embedInspectorComponent(id, embedStore) {
  if (!embedStore[id]) {
    embedStore[id] = { width: "100%", height: "100%" };
  }

  return {
    iframe: null,

    viewportHeight: 0,

    targetPath: window.location.pathname,

    get viewportCssHeight() {
      return this.viewportHeight ? `${this.viewportHeight}px` : "100%";
    },

    get store() {
      return embedStore[id];
    },

    init() {
      const onResized = this.onResized.bind(this);

      this.iframe = this.$el.querySelector("iframe");
      window.iFrameResize({ onResized, checkOrigin: false }, this.iframe);

      this.$watch("targetPath", (value) => this.switchTarget(value));
    },

    switchTarget(newTargetPath) {
      this.navigateTo(`${newTargetPath}${window.location.search}`);
    },

    onResized({ height }) {
      if (height) {
        this.viewportHeight = height;
      }
    },

    resizeIframe() {
      this.iframe.iFrameResizer.resize();
    },
  };
}

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
lookbook-2.0.1 app/components/lookbook/embed/inspector/component.js
lookbook-2.0.0 app/components/lookbook/embed/inspector/component.js
lookbook-2.0.0.rc.3 app/components/lookbook/embed/inspector/component.js
lookbook-2.0.0.rc.2 app/components/lookbook/embed/inspector/component.js
lookbook-2.0.0.rc.1 app/components/lookbook/embed/inspector/component.js
lookbook-2.0.0.beta.9 app/components/lookbook/embed/inspector/component.js
lookbook-2.0.0.beta.8 app/components/lookbook/embed/inspector/component.js
lookbook-2.0.0.beta.7 app/components/lookbook/embed/inspector/component.js
lookbook-2.0.0.beta.6 app/components/lookbook/embed/inspector/component.js
lookbook-2.0.0.beta.5 app/components/lookbook/embed/inspector/component.js
lookbook-2.0.0.beta.4 app/components/lookbook/embed/inspector/component.js
lookbook-2.0.0.beta.3 app/components/lookbook/embed/inspector/component.js
lookbook-2.0.0.beta.2 app/components/lookbook/embed/inspector/component.js
lookbook-2.0.0.beta.1 app/components/lookbook/embed/inspector/component.js
lookbook-2.0.0.beta.0 app/components/lookbook/embed/inspector/component.js