Gallery.vue 5.2 KB

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