NEXT craftinamerica.org. Base setup for headless wordpress https://www.craftinamerica.org
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

gallery.vue 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template lang="pug">
  2. .gallery.active.f-col.center
  3. button(@click="hideGallery").hide hide gallery &#x25B2
  4. figure.f-col.center
  5. p {{images}}
  6. img(:src="Object.values(images)[selected]")
  7. p active: {{ selected }}
  8. .titledesc.t-left {{titledesc}}
  9. h2 Title goes here: Responsive block to fit different screen sizes. Hide/Show from bottom of the screen.
  10. p Description goes here: London. Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall. Implacable November weather. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Blue McRight is an inter-disciplinary artist influenced by nature, personal experience, and politics. At its core, her multi-media work focuses on water – and its lack – as an environmental issue; however her practice has expanded to address related ideas such as the body, circulatory systems, and marine science. McRight’s work is both elusive and interactive, inviting viewer engagement and contemplation.
  11. .controls.f-row
  12. button(v-if="selected > 0" @click="prev") &#x25C0prev
  13. .f-grow
  14. button(v-if="selected < Object.values(images).length - 1" @click="next") next &#x25B6
  15. </template>
  16. <script>
  17. export default {
  18. props: {
  19. activeImageIndex: { type: Number, required: true, default: 0 },
  20. images: { type: Object, required: true },
  21. },
  22. data() {
  23. return {
  24. selected: 0,
  25. }
  26. },
  27. methods: {
  28. prev() {
  29. this.selected > 0
  30. ? this.selected--
  31. : (this.selected = Object.keys(this.images).length - 1)
  32. },
  33. next() {
  34. this.selected < Object.keys(this.images).length - 1
  35. ? this.selected++
  36. : (this.selected = 0)
  37. },
  38. hideGallery() {
  39. this.$emit('close')
  40. },
  41. interpretKeypress(e) {
  42. switch (e.key) {
  43. case 'ArrowRight':
  44. this.next()
  45. break
  46. case 'ArrowLeft':
  47. this.prev()
  48. break
  49. case 'Escape':
  50. this.hideGallery()
  51. break
  52. }
  53. },
  54. },
  55. watch: {
  56. activeImageIndex(newVal, oldVal) {
  57. this.selected = newVal
  58. },
  59. },
  60. async mounted() {
  61. // Set the first selection
  62. this.selected = this.activeImageIndex
  63. window.addEventListener('keydown', this.interpretKeypress)
  64. },
  65. unmounted() {
  66. window.removeEventListener('keydown', this.interpretKeypress)
  67. },
  68. }
  69. </script>
  70. <style lang="postcss">
  71. // prettier-ignore
  72. @import '../sss/variables.sss'
  73. @import '../sss/theme.sss'
  74. .gallery
  75. overflow: hidden
  76. .wrap
  77. /* width: 60vw */
  78. &.active
  79. position: fixed
  80. top: 0
  81. left: 0
  82. width: 100%
  83. height: 100%
  84. background-color: rgba(255, 0, 0, 0.6)
  85. z-index: 1001
  86. > * /* select for all direct children */
  87. opacity: 100%
  88. position: relative
  89. max-height: 95vh
  90. z-index: 1011
  91. button.hide
  92. position: fixed
  93. top: 0
  94. padding: 4px
  95. color: $cia_red
  96. z-index: 1100
  97. figure
  98. img
  99. background-size: auto
  100. max-width: 90vw
  101. max-height: 80vh
  102. .titledesc
  103. position: fixed
  104. max-width: 90vw
  105. bottom: 1vh
  106. background-color: rgba(255, 255, 255, 0.6)
  107. padding: 1.0em
  108. text-align: left
  109. h2, p
  110. color: $cia_black
  111. .controls
  112. position: absolute
  113. width: 100vw
  114. button
  115. background-color: rgba(255, 255, 255, 0.1)
  116. height: 100vh
  117. padding: 1.0em
  118. </style>