logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

gallery.vue (4439B)


  1. <template>
  2. <div
  3. ref="galleryContainer"
  4. class="Gallery"
  5. :class="{ '-long': tooManyAttachments && hidingLong }"
  6. >
  7. <div class="gallery-rows">
  8. <div
  9. v-for="(row, rowIndex) in rows"
  10. :key="rowIndex"
  11. class="gallery-row"
  12. :style="rowStyle(row)"
  13. :class="{ '-audio': row.audio, '-minimal': row.minimal, '-grid': grid }"
  14. >
  15. <div
  16. class="gallery-row-inner"
  17. :class="{ '-grid': grid }"
  18. >
  19. <Attachment
  20. v-for="(attachment, attachmentIndex) in row.items"
  21. :key="attachment.id"
  22. class="gallery-item"
  23. :compact="compact"
  24. :nsfw="nsfw"
  25. :attachment="attachment"
  26. :size="size"
  27. :editable="editable"
  28. :remove="removeAttachment"
  29. :shift-up="!(attachmentIndex === 0 && rowIndex === 0) && shiftUpAttachment"
  30. :shift-dn="!(attachmentIndex === row.items.length - 1 && rowIndex === rows.length - 1) && shiftDnAttachment"
  31. :edit="editAttachment"
  32. :description="descriptions && descriptions[attachment.id]"
  33. :hide-description="size === 'small' || tooManyAttachments && hidingLong"
  34. :style="itemStyle(attachment.id, row.items)"
  35. @setMedia="onMedia"
  36. @naturalSizeLoad="onNaturalSizeLoad"
  37. />
  38. </div>
  39. </div>
  40. </div>
  41. <div
  42. v-if="tooManyAttachments"
  43. class="many-attachments"
  44. >
  45. <div class="many-attachments-text">
  46. {{ $t("status.many_attachments", { number: attachments.length }) }}
  47. </div>
  48. <div class="many-attachments-buttons">
  49. <span
  50. v-if="!hidingLong"
  51. class="many-attachments-button"
  52. >
  53. <button
  54. class="button-unstyled -link"
  55. @click="toggleHidingLong(true)"
  56. >
  57. {{ $t("status.collapse_attachments") }}
  58. </button>
  59. </span>
  60. <span
  61. v-if="hidingLong"
  62. class="many-attachments-button"
  63. >
  64. <button
  65. class="button-unstyled -link"
  66. @click="toggleHidingLong(false)"
  67. >
  68. {{ $t("status.show_all_attachments") }}
  69. </button>
  70. </span>
  71. <span
  72. v-if="hidingLong"
  73. class="many-attachments-button"
  74. >
  75. <button
  76. class="button-unstyled -link"
  77. @click="openGallery"
  78. >
  79. {{ $t("status.open_gallery") }}
  80. </button>
  81. </span>
  82. </div>
  83. </div>
  84. </div>
  85. </template>
  86. <script src='./gallery.js'></script>
  87. <style lang="scss">
  88. .Gallery {
  89. .gallery-rows {
  90. display: flex;
  91. flex-direction: column;
  92. }
  93. .gallery-row {
  94. position: relative;
  95. height: 0;
  96. width: 100%;
  97. flex-grow: 1;
  98. .gallery-row-inner {
  99. position: absolute;
  100. top: 0;
  101. left: 0;
  102. right: 0;
  103. bottom: 0;
  104. display: flex;
  105. flex-flow: row wrap;
  106. align-content: stretch;
  107. .gallery-item {
  108. margin: 0 0.5em 0 0;
  109. flex-grow: 1;
  110. height: 100%;
  111. box-sizing: border-box;
  112. // to make failed images a bit more noticeable on chromium
  113. min-width: 2em;
  114. &:last-child {
  115. margin: 0;
  116. }
  117. }
  118. &.-grid {
  119. width: 100%;
  120. height: auto;
  121. position: relative;
  122. display: grid;
  123. grid-gap: 0.5em;
  124. grid-template-columns: repeat(auto-fill, minmax(15em, 1fr));
  125. .gallery-item {
  126. margin: 0;
  127. height: 200px;
  128. }
  129. }
  130. }
  131. &.-grid,
  132. &.-minimal {
  133. height: auto;
  134. .gallery-row-inner {
  135. position: relative;
  136. }
  137. }
  138. &:not(:first-child) {
  139. margin-top: 0.5em;
  140. }
  141. }
  142. &.-long {
  143. .gallery-rows {
  144. max-height: 25em;
  145. overflow: hidden;
  146. mask:
  147. linear-gradient(to top, white, transparent) bottom/100% 70px no-repeat,
  148. linear-gradient(to top, white, white);
  149. /* Autoprefixed seem to ignore this one, and also syntax is different */
  150. mask-composite: xor;
  151. mask-composite: exclude;
  152. }
  153. }
  154. .many-attachments-text {
  155. text-align: center;
  156. line-height: 2;
  157. }
  158. .many-attachments-buttons {
  159. display: flex;
  160. }
  161. .many-attachments-button {
  162. display: flex;
  163. flex: 1;
  164. justify-content: center;
  165. line-height: 2;
  166. button {
  167. padding: 0 2em;
  168. }
  169. }
  170. }
  171. </style>