<template>
  <div class="genially-block">
    <div class="genially-block__wrapper">
      <iframe
        :src="src"
        class="genially-block__iframe"
        frameborder="0"
        width="800px"
        height="600px"
        type="text/html"
        allowscriptaccess="always"
        allowfullscreen="true"
        scrolling="yes"
        allownetworking="all"/>
    </div>
  </div>
</template>

<script>
  export default {
    props: ['value'],

    computed: {
      src() {
        return `https://view.genial.ly/${this.value.id}`;
      }
    },

    methods: {
      openFullscreen() {
        this.$store.dispatch('showFullscreenInfographic', {
          id: this.value.id,
          type: 'genially-block'
        });
      }
    }
  };
</script>

<style scoped lang="scss">
  @import "@/styles/_variables.scss";

  // Styling and structure taken from original iframe
  .genially-block {
    width: 100%;
    margin-bottom: $large-spacing;

    &__wrapper {
      position: relative;
      padding-bottom: 75%;
      padding-top: 0;
      height: 0;
    }

    &__iframe {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
    }

    &__link {
      cursor: pointer;
    }
  }
</style>
