Skip to content

Commit

Permalink
🐛 (Tests): tests did not expected auto width
Browse files Browse the repository at this point in the history
  • Loading branch information
silencesys committed Jun 24, 2020
1 parent 0004c67 commit 74f7e0b
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 46 deletions.
33 changes: 20 additions & 13 deletions dist/vue-silentbox.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ var script$1 = {
return {
src: '',
alt: '',
thumbnailWidth: '200px',
thumbnailWidth: 'auto',
thumbnailHeight: 'auto',
thumbnail: '',
autoplay: false,
Expand Down Expand Up @@ -554,7 +554,7 @@ var script$1 = {
item: {
src: '',
alt: '',
thumbnailWidth: '200px',
thumbnailWidth: 'auto',
thumbnailHeight: 'auto',
thumbnail: '',
autoplay: false,
Expand Down Expand Up @@ -661,23 +661,30 @@ var __vue_render__$1 = function() {
}
},
[
_c("img", {
attrs: {
src: image.thumbnail,
alt: image.alt,
width: image.thumbnailWidth,
height: image.thumbnailHeight
}
})
]
_vm._t(
"silentbox-item",
[
_c("img", {
attrs: {
src: image.thumbnail,
alt: image.alt,
width: image.thumbnailWidth,
height: image.thumbnailHeight
}
})
],
{ silentboxItem: image }
)
],
2
)
}),
_vm._v(" "),
_c("silentbox-overlay", {
attrs: {
"overlay-item": _vm.overlay.item,
visible: _vm.overlay.visible,
"total-items": _vm.overlay.totalItems
"total-items": _vm.totalItems
},
on: {
closeSilentboxOverlay: _vm.hideOverlay,
Expand All @@ -695,7 +702,7 @@ __vue_render__$1._withStripped = true;
/* style */
const __vue_inject_styles__$1 = function (inject) {
if (!inject) return
inject("data-v-422c39d4_0", { source: ".silentbox-item {\n cursor: pointer;\n display: inline-block;\n text-decoration: underline;\n}\n\n/*# sourceMappingURL=gallery.vue.map */", map: {"version":3,"sources":["/Users/silencesys/Projects/Silencesys/silentbox-website/src/Silentbox/src/components/gallery.vue","gallery.vue"],"names":[],"mappings":"AAkKA;EACA,eAAA;EACA,qBAAA;EACA,0BAAA;ACjKA;;AAEA,sCAAsC","file":"gallery.vue","sourcesContent":["<template>\r\n <section id=\"silentbox-gallery\">\r\n <slot />\r\n <div\r\n v-for=\"(image, index) in galleryItems\"\r\n :key=\"image.src\"\r\n @click=\"openOverlay(image, index)\"\r\n class=\"silentbox-item\"\r\n >\r\n <img\r\n :src=\"image.thumbnail\"\r\n :alt=\"image.alt\"\r\n :width=\"image.thumbnailWidth\"\r\n :height=\"image.thumbnailHeight\"\r\n >\r\n </div>\r\n <silentbox-overlay\r\n :overlay-item=\"overlay.item\"\r\n :visible=\"overlay.visible\"\r\n :total-items=\"overlay.totalItems\"\r\n @closeSilentboxOverlay=\"hideOverlay\"\r\n @requestNextSilentBoxItem=\"showNextItem\"\r\n @requestPreviousSilentBoxItem=\"showPreviousItem\"\r\n />\r\n </section>\r\n</template>\r\n\r\n<script>\r\nimport overlay from './overlay.vue'\r\nimport itemMixin from './../mixins/item'\r\n\r\nexport default {\r\n name: 'silentboxGallery',\r\n mixins: [itemMixin],\r\n props: {\r\n gallery: {\r\n type: Array,\r\n default: () => {\r\n return []\r\n }\r\n },\r\n image: {\r\n type: Object,\r\n default: () => {\r\n return {\r\n src: '',\r\n alt: '',\r\n thumbnailWidth: '200px',\r\n thumbnailHeight: 'auto',\r\n thumbnail: '',\r\n autoplay: false,\r\n controls: true,\r\n description: ''\r\n }\r\n }\r\n }\r\n },\r\n components: {\r\n 'silentbox-overlay': overlay\r\n },\r\n mounted () {\r\n // Listen to key events.\r\n window.addEventListener('keyup', (event) => {\r\n // Escape: 27\r\n if (event.which === 27) {\r\n this.hideOverlay()\r\n }\r\n // Right arrow: 39\r\n if (event.which === 39) {\r\n this.showNextItem()\r\n }\r\n // Left arrow: 37\r\n if (event.which === 37) {\r\n this.showPreviousItem()\r\n }\r\n })\r\n },\r\n data () {\r\n return {\r\n overlay: {\r\n item: {\r\n src: '',\r\n alt: '',\r\n thumbnailWidth: '200px',\r\n thumbnailHeight: 'auto',\r\n thumbnail: '',\r\n autoplay: false,\r\n controls: true,\r\n description: ''\r\n },\r\n visible: false,\r\n currentItem: 0\r\n }\r\n }\r\n },\r\n computed: {\r\n totalItems () {\r\n return this.gallery.length || 1\r\n },\r\n galleryItems () {\r\n if (this.gallery.length > 0) {\r\n return this.gallery.map(item => {\r\n return {\r\n ...this.overlay.item,\r\n ...item,\r\n thumbnail: this.setThumbnail(item),\r\n autoplay: this.setAutoplay(item)\r\n }\r\n })\r\n } else {\r\n return [{\r\n ...this.overlay.item,\r\n ...this.image,\r\n thumbnail: this.setThumbnail(this.image)\r\n }]\r\n }\r\n }\r\n },\r\n methods: {\r\n openOverlay (image, index) {\r\n this.overlay.visible = true\r\n this.overlay.item = image\r\n this.overlay.currentItem = index\r\n this.$emit('silentbox-overlay-opened')\r\n },\r\n hideOverlay () {\r\n this.overlay.visible = false\r\n this.$emit('silentbox-overlay-hidden')\r\n },\r\n showNextItem () {\r\n let newItemIndex = this.overlay.currentItem + 1\r\n newItemIndex = newItemIndex <= this.galleryItems.length - 1\r\n ? newItemIndex : 0\r\n\r\n this.overlay.item = this.galleryItems[newItemIndex]\r\n this.overlay.currentItem = newItemIndex\r\n this.$emit('silentbox-overlay-next-item-displayed')\r\n },\r\n showPreviousItem () {\r\n let newItemIndex = this.overlay.currentItem - 1\r\n newItemIndex = newItemIndex > -1\r\n ? newItemIndex : this.galleryItems.length - 1\r\n\r\n this.overlay.item = this.galleryItems[newItemIndex]\r\n this.overlay.currentItem = newItemIndex\r\n this.$emit('silentbox-overlay-previous-item-displayed')\r\n },\r\n setAutoplay (item) {\r\n return item.autoplay ? 'autoplay' : ''\r\n },\r\n setThumbnail (item) {\r\n if (this.isEmbedVideo(item.src) && item.thumbnail === undefined) {\r\n return this.getThumbnail(item.src)\r\n }\r\n\r\n return item.thumbnail || item.src\r\n }\r\n }\r\n}\r\n</script>\r\n\r\n<style lang=\"scss\">\r\n .silentbox-item {\r\n cursor: pointer;\r\n display: inline-block;\r\n text-decoration: underline;\r\n }\r\n</style>\r\n",".silentbox-item {\n cursor: pointer;\n display: inline-block;\n text-decoration: underline;\n}\n\n/*# sourceMappingURL=gallery.vue.map */"]}, media: undefined });
inject("data-v-7f05ba59_0", { source: ".silentbox-item {\n cursor: pointer;\n display: inline-block;\n text-decoration: underline;\n}\n\n/*# sourceMappingURL=gallery.vue.map */", map: {"version":3,"sources":["/Users/silencesys/Projects/Silencesys/silentbox-website/src/Silentbox/src/components/gallery.vue","gallery.vue"],"names":[],"mappings":"AAuKA;EACA,eAAA;EACA,qBAAA;EACA,0BAAA;ACtKA;;AAEA,sCAAsC","file":"gallery.vue","sourcesContent":["<template>\r\n <section id=\"silentbox-gallery\">\r\n <slot />\r\n <div\r\n v-for=\"(image, index) in galleryItems\"\r\n :key=\"image.src\"\r\n @click=\"openOverlay(image, index)\"\r\n class=\"silentbox-item\"\r\n >\r\n <slot\r\n name=\"silentbox-item\"\r\n v-bind:silentboxItem=\"image\"\r\n >\r\n <img\r\n :src=\"image.thumbnail\"\r\n :alt=\"image.alt\"\r\n :width=\"image.thumbnailWidth\"\r\n :height=\"image.thumbnailHeight\"\r\n >\r\n </slot>\r\n </div>\r\n <silentbox-overlay\r\n :overlay-item=\"overlay.item\"\r\n :visible=\"overlay.visible\"\r\n :total-items=\"totalItems\"\r\n @closeSilentboxOverlay=\"hideOverlay\"\r\n @requestNextSilentBoxItem=\"showNextItem\"\r\n @requestPreviousSilentBoxItem=\"showPreviousItem\"\r\n />\r\n </section>\r\n</template>\r\n\r\n<script>\r\nimport overlay from './overlay.vue'\r\nimport itemMixin from './../mixins/item'\r\n\r\nexport default {\r\n name: 'silentboxGallery',\r\n mixins: [itemMixin],\r\n props: {\r\n gallery: {\r\n type: Array,\r\n default: () => {\r\n return []\r\n }\r\n },\r\n image: {\r\n type: Object,\r\n default: () => {\r\n return {\r\n src: '',\r\n alt: '',\r\n thumbnailWidth: 'auto',\r\n thumbnailHeight: 'auto',\r\n thumbnail: '',\r\n autoplay: false,\r\n controls: true,\r\n description: ''\r\n }\r\n }\r\n }\r\n },\r\n components: {\r\n 'silentbox-overlay': overlay\r\n },\r\n mounted () {\r\n // Listen to key events.\r\n window.addEventListener('keyup', (event) => {\r\n // Escape: 27\r\n if (event.which === 27) {\r\n this.hideOverlay()\r\n }\r\n // Right arrow: 39\r\n if (event.which === 39) {\r\n this.showNextItem()\r\n }\r\n // Left arrow: 37\r\n if (event.which === 37) {\r\n this.showPreviousItem()\r\n }\r\n })\r\n },\r\n data () {\r\n return {\r\n overlay: {\r\n item: {\r\n src: '',\r\n alt: '',\r\n thumbnailWidth: 'auto',\r\n thumbnailHeight: 'auto',\r\n thumbnail: '',\r\n autoplay: false,\r\n controls: true,\r\n description: ''\r\n },\r\n visible: false,\r\n currentItem: 0\r\n }\r\n }\r\n },\r\n computed: {\r\n totalItems () {\r\n return this.gallery.length || 1\r\n },\r\n galleryItems () {\r\n if (this.gallery.length > 0) {\r\n return this.gallery.map(item => {\r\n return {\r\n ...this.overlay.item,\r\n ...item,\r\n thumbnail: this.setThumbnail(item),\r\n autoplay: this.setAutoplay(item)\r\n }\r\n })\r\n } else {\r\n return [{\r\n ...this.overlay.item,\r\n ...this.image,\r\n thumbnail: this.setThumbnail(this.image)\r\n }]\r\n }\r\n }\r\n },\r\n methods: {\r\n openOverlay (image, index) {\r\n this.overlay.visible = true\r\n this.overlay.item = image\r\n this.overlay.currentItem = index\r\n this.$emit('silentbox-overlay-opened')\r\n },\r\n hideOverlay () {\r\n this.overlay.visible = false\r\n this.$emit('silentbox-overlay-hidden')\r\n },\r\n showNextItem () {\r\n let newItemIndex = this.overlay.currentItem + 1\r\n newItemIndex = newItemIndex <= this.galleryItems.length - 1\r\n ? newItemIndex : 0\r\n\r\n this.overlay.item = this.galleryItems[newItemIndex]\r\n this.overlay.currentItem = newItemIndex\r\n this.$emit('silentbox-overlay-next-item-displayed')\r\n },\r\n showPreviousItem () {\r\n let newItemIndex = this.overlay.currentItem - 1\r\n newItemIndex = newItemIndex > -1\r\n ? newItemIndex : this.galleryItems.length - 1\r\n\r\n this.overlay.item = this.galleryItems[newItemIndex]\r\n this.overlay.currentItem = newItemIndex\r\n this.$emit('silentbox-overlay-previous-item-displayed')\r\n },\r\n setAutoplay (item) {\r\n return item.autoplay ? 'autoplay' : ''\r\n },\r\n setThumbnail (item) {\r\n if (this.isEmbedVideo(item.src) && item.thumbnail === undefined) {\r\n return this.getThumbnail(item.src)\r\n }\r\n\r\n return item.thumbnail || item.src\r\n }\r\n }\r\n}\r\n</script>\r\n\r\n<style lang=\"scss\">\r\n .silentbox-item {\r\n cursor: pointer;\r\n display: inline-block;\r\n text-decoration: underline;\r\n }\r\n</style>\r\n",".silentbox-item {\n cursor: pointer;\n display: inline-block;\n text-decoration: underline;\n}\n\n/*# sourceMappingURL=gallery.vue.map */"]}, media: undefined });

};
/* scoped */
Expand Down
Loading

0 comments on commit 74f7e0b

Please sign in to comment.