Gallery.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <div class="gallery">
  3. <b-button v-b-toggle.gallery-map-side variant="creation" class="btn-side left">
  4. {{ $t('map') }}
  5. </b-button>
  6. <side-view id="gallery-map-side" :visible="mapIsVisible">
  7. <template #default="{ hide, visible }">
  8. <gallery-map
  9. v-if="creations && creation"
  10. :nodes="creations" :node="creation"
  11. :visible="visible"
  12. @open-creation="openCreation($event, hide)"
  13. />
  14. </template>
  15. </side-view>
  16. <gallery-view
  17. v-if="creation"
  18. :node="creation" :key="creation ? creation.id : 0"
  19. @open-creation="openCreation"
  20. @view-origin="openLibrary"
  21. />
  22. <b-button v-b-toggle.gallery-index variant="creation" class="btn-side right">
  23. {{ $t('index') }}
  24. </b-button>
  25. <side-view id="gallery-index" right>
  26. <template #default="{ hide }">
  27. <page-view
  28. v-if="intro"
  29. :page="intro" no-close slug="intro"
  30. class="small"
  31. />
  32. <ul v-if="creations">
  33. <li v-for="crea in creations" :key="crea.id">
  34. <node-view-title
  35. :node="crea"
  36. tag="h4" link no-date
  37. @open-node="openCreation(crea.id, hide)"
  38. />
  39. </li>
  40. </ul>
  41. </template>
  42. </side-view>
  43. <b-modal
  44. v-if="creation && (creation.iframeUrl || creation.mediaItem)"
  45. :id="'modal-creation' + creation.id"
  46. class="modal-creation"
  47. static hide-footer hide-header
  48. >
  49. <template #default="{ hide, visible }">
  50. <button-expand expanded @click="hide()" />
  51. <template v-if="visible">
  52. <iframe
  53. v-if="creation.iframeUrl"
  54. :src="creation.iframeUrl"
  55. width="100%" height="100%"
  56. />
  57. <component
  58. v-else-if="creation.mediaItem"
  59. :is="creation.mediaItem.is"
  60. :src="creation.mediaItem.src"
  61. controls
  62. />
  63. </template>
  64. </template>
  65. </b-modal>
  66. <b-overlay
  67. :show="!creations || !creation"
  68. spinner-variant="creation"
  69. no-wrap
  70. />
  71. </div>
  72. </template>
  73. <script>
  74. import { mapGetters } from 'vuex'
  75. import { getRelation } from '@/store/utils'
  76. import { PageView, SideView } from '@/components/layouts'
  77. import { NodeViewTitle } from '@/components/nodes'
  78. import { GalleryView, GalleryMap } from '@/pages/gallery'
  79. export default {
  80. name: 'Gallery',
  81. components: {
  82. PageView,
  83. SideView,
  84. GalleryView,
  85. GalleryMap,
  86. NodeViewTitle
  87. },
  88. props: {
  89. id: { type: [Number, String], default: undefined }
  90. },
  91. data () {
  92. return {
  93. intro: null,
  94. mapIsVisible: false
  95. }
  96. },
  97. computed: {
  98. ...mapGetters(['creations', 'creation'])
  99. },
  100. methods: {
  101. openCreation (id, hideSideView) {
  102. this.$store.dispatch('OPEN_CREATION', { id })
  103. if (hideSideView) hideSideView()
  104. },
  105. openLibrary () {
  106. this.$store.dispatch('OPEN_NODE', getRelation(this.creation))
  107. }
  108. },
  109. watch: {
  110. id (id, prev) {
  111. this.$store.dispatch('DISPLAY_CREATION', parseInt(this.id))
  112. }
  113. },
  114. created () {
  115. if (this.$route.hash === '#map') {
  116. this.mapIsVisible = true
  117. }
  118. this.$store.dispatch('INIT_GALLERY', parseInt(this.id))
  119. this.$store.dispatch('QUERY_PAGE', 'gallery').then(page => {
  120. this.intro = page
  121. })
  122. }
  123. }
  124. </script>
  125. <style lang="scss" scoped>
  126. .gallery {
  127. position: relative;
  128. width: 100%;
  129. height: 100%;
  130. display: flex;
  131. flex-direction: column;
  132. justify-content: space-between;
  133. @media (orientation: landscape) {
  134. flex-direction: row;
  135. }
  136. .btn-side {
  137. position: absolute;
  138. border-radius: 0 !important;
  139. align-self: center;
  140. min-height: 35px;
  141. min-width: 65px;
  142. text-align: center;
  143. border: $line;
  144. font-weight: $font-weight-bold;
  145. line-height: 0;
  146. @include media-breakpoint-up($size-bp) {
  147. min-height: 50px;
  148. min-width: 80px;
  149. }
  150. &.left {
  151. border-top: 0;
  152. @media (orientation: portrait) {
  153. top: 0;
  154. }
  155. @media (orientation: landscape) {
  156. transform: rotate(-90deg) translate(0, -15px);
  157. margin-right: -30px;
  158. }
  159. }
  160. &.right {
  161. @media (orientation: portrait) {
  162. bottom: 0;
  163. border-bottom: 0;
  164. }
  165. @media (orientation: landscape) {
  166. border-top: 0;
  167. transform: rotate(90deg) translate(0, -15px);
  168. margin-left: -30px;
  169. right: 0;
  170. }
  171. }
  172. }
  173. }
  174. ::v-deep #gallery-map-side {
  175. width: 100%;
  176. .btn-close {
  177. float: unset;
  178. }
  179. }
  180. #gallery-index {
  181. ul {
  182. padding: 0;
  183. list-style: none;
  184. font-family: $font-family-text;
  185. }
  186. }
  187. .modal-creation {
  188. z-index: 1100 !important;
  189. width: 100%;
  190. height: 100%;
  191. pointer-events: none;
  192. ::v-deep .modal {
  193. position: absolute;
  194. background-color: transparent;
  195. width: 100%;
  196. max-height: 100%;
  197. overflow: hidden;
  198. &-dialog {
  199. max-width: 100%;
  200. height: 100%;
  201. margin: 0;
  202. }
  203. &-content {
  204. height: 100%;
  205. border: 0;
  206. }
  207. &-body {
  208. padding: 0;
  209. display: flex;
  210. }
  211. &-backdrop {
  212. display: none;
  213. }
  214. iframe {
  215. border: 0;
  216. }
  217. .btn-expand {
  218. position: absolute;
  219. top: 0;
  220. right: 0;
  221. }
  222. audio {
  223. width: 80%;
  224. margin: auto;
  225. }
  226. video {
  227. width: 100%;
  228. height: 100%;
  229. }
  230. }
  231. }
  232. </style>