aboutsummaryrefslogtreecommitdiff
path: root/src/components/media_modal
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/media_modal')
-rw-r--r--src/components/media_modal/media_modal.js38
-rw-r--r--src/components/media_modal/media_modal.vue38
2 files changed, 76 insertions, 0 deletions
diff --git a/src/components/media_modal/media_modal.js b/src/components/media_modal/media_modal.js
new file mode 100644
index 00000000..14ae19d4
--- /dev/null
+++ b/src/components/media_modal/media_modal.js
@@ -0,0 +1,38 @@
+import StillImage from '../still-image/still-image.vue'
+import VideoAttachment from '../video_attachment/video_attachment.vue'
+import fileTypeService from '../../services/file_type/file_type.service.js'
+
+const MediaModal = {
+ components: {
+ StillImage,
+ VideoAttachment
+ },
+ computed: {
+ showing () {
+ return this.$store.state.mediaViewer.activated
+ },
+ currentIndex () {
+ return this.$store.state.mediaViewer.currentIndex
+ },
+ currentMedia () {
+ return this.$store.state.mediaViewer.media[this.currentIndex]
+ },
+ type () {
+ return this.currentMedia ? fileTypeService.fileType(this.currentMedia.mimetype) : null
+ }
+ },
+ created () {
+ document.addEventListener('keyup', e => {
+ if (e.keyCode === 27 && this.showing) { // escape
+ this.hide()
+ }
+ })
+ },
+ methods: {
+ hide () {
+ this.$store.dispatch('closeMediaViewer')
+ }
+ }
+}
+
+export default MediaModal
diff --git a/src/components/media_modal/media_modal.vue b/src/components/media_modal/media_modal.vue
new file mode 100644
index 00000000..796d4e40
--- /dev/null
+++ b/src/components/media_modal/media_modal.vue
@@ -0,0 +1,38 @@
+<template>
+ <div class="modal-view" v-if="showing" @click.prevent="hide">
+ <img class="modal-image" v-if="type === 'image'" :src="currentMedia.url"></img>
+ <VideoAttachment
+ class="modal-image"
+ v-if="type === 'video'"
+ :attachment="currentMedia"
+ :controls="true"
+ @click.stop.native="">
+ </VideoAttachment>
+ </div>
+</template>
+
+<script src="./media_modal.js"></script>
+
+<style lang="scss">
+@import '../../_variables.scss';
+
+.modal-view {
+ z-index: 1000;
+ position: fixed;
+ width: 100vw;
+ height: 100vh;
+ top: 0;
+ left: 0;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ background-color: rgba(0, 0, 0, 0.5);
+ cursor: pointer;
+}
+
+.modal-image {
+ max-width: 90%;
+ max-height: 90%;
+ box-shadow: 0px 5px 15px 0 rgba(0, 0, 0, 0.5);
+}
+</style>