Skip to content
Snippets Groups Projects
AttachmentPreview.vue 997 B
Newer Older
<template>
  <div :class="['attachment-preview', { is_pdf }]">  
    <embed
      v-if="is_pdf"
      :src="src"
      type="application/pdf"
    >
    <div v-else>
      <img
        :src="src"
        :alt="`Aperçu ${is_pdf ? 'd\'un document pdf' : 'd\'une image'}`"
      >
    </div>
  </div>
</template>

<script>


export default {
  name: 'AttachmentPreview',

  computed: {
    src() {
      return this.$route.query.file;
    },
    is_pdf() {
      return this.src && this.src.includes('pdf');
    }
  },
};
</script>

<style lang="less">
.attachment-preview {
  width: 100vw;
  &.is_pdf {
    @media screen and (min-width: 726px) {
      height: calc(100vh - 70px - 1em);
      margin: .5em auto;
      box-shadow: 1px 2px 10px grey;
    }
    @media screen and (max-width: 725px) {
      height: calc(100vh - 110px);
      margin: 0 auto;
    }
    height: 100%;
    width: 100%;
  }
  > div {
    display: flex;
    justify-content: center;
  }
}
</style>