You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

169 lines
5.5 KiB

  1. <template lang='pug'>
  2. v-card.editor-modal-media.animated.fadeInLeft(flat, tile)
  3. v-container.pa-3(grid-list-lg, fluid)
  4. v-layout(row, wrap)
  5. v-flex(xs9)
  6. v-card.radius-7.animated.fadeInLeft.wait-p1s(light)
  7. v-card-text
  8. .d-flex
  9. v-toolbar.radius-7(color='teal lighten-5', dense, flat, height='44')
  10. .body-2.teal--text Images
  11. v-btn.ml-3.my-0.radius-7(outline, large, color='teal', disabled)
  12. v-icon(left) keyboard_arrow_up
  13. span Parent Folder
  14. v-btn.my-0.radius-7(outline, large, color='teal')
  15. v-icon(left) add
  16. span New Folder
  17. v-list.mt-3(dense, two-line)
  18. template(v-for='(item, idx) of [1,2,3,4,5,6,7,8,9,10]')
  19. v-list-tile(@click='')
  20. v-list-tile-avatar
  21. v-avatar.radius-7(color='teal')
  22. v-icon(dark) image
  23. v-list-tile-content
  24. v-list-tile-title Image {{item}}
  25. v-list-tile-sub-title 1024x768, 10 KBs
  26. v-list-tile-action
  27. .caption.pr-3 2019-04-07
  28. v-list-tile-action
  29. v-chip.teal--text(label, small, color='teal lighten-5') JPG
  30. v-divider(v-if='idx < 10 - 1')
  31. .d-flex.mt-3
  32. v-toolbar.radius-7(flat, color='grey lighten-4', dense, height='44')
  33. .body-2 / universe
  34. v-spacer
  35. .body-1.grey--text.text--darken-1 10 files
  36. v-btn.ml-3.my-0.radius-7(color='teal', large, @click='insert', disabled)
  37. v-icon(left) save_alt
  38. span Insert
  39. v-flex(xs3)
  40. v-card.radius-7.animated.fadeInRight.wait-p3s(light)
  41. v-card-text
  42. v-toolbar.radius-7(color='teal lighten-5', dense, flat)
  43. v-icon.mr-3(color='teal') cloud_upload
  44. .body-2.teal--text Upload Images
  45. file-pond.mt-3(
  46. name='mediaUpload'
  47. ref='pond'
  48. label-idle='Browse or Drop files here...'
  49. allow-multiple='true'
  50. accepted-file-types='image/jpeg, image/png, image/gif, image/svg'
  51. :files='files'
  52. max-files='10'
  53. )
  54. v-divider
  55. v-card-actions.pa-3
  56. .caption.grey--text.text-darken-2 Max 10 files, 5 MB each
  57. v-spacer
  58. v-btn(color='teal', dark, @click='upload') Upload
  59. v-card.mt-3.radius-7.animated.fadeInRight.wait-p4s(light)
  60. v-card-text.pb-0
  61. v-toolbar.radius-7(color='teal lighten-5', dense, flat)
  62. v-icon.mr-3(color='teal') cloud_download
  63. .body-2.teal--text Fetch Remote Image
  64. v-text-field.mt-3(
  65. v-model='remoteImageUrl'
  66. outline
  67. single-line
  68. background-color='grey lighten-2'
  69. placeholder='https://example.com/image.jpg'
  70. )
  71. v-divider
  72. v-card-actions.pa-3
  73. .caption.grey--text.text-darken-2 Max 5 MB
  74. v-spacer
  75. v-btn(color='teal', dark) Fetch
  76. v-card.mt-3.radius-7.animated.fadeInRight.wait-p4s(light)
  77. v-card-text.pb-0
  78. v-toolbar.radius-7(color='teal lighten-5', dense, flat)
  79. v-icon.mr-3(color='teal') format_align_left
  80. .body-2.teal--text Alignment
  81. v-select.mt-3(
  82. v-model='imageAlignment'
  83. :items='imageAlignments'
  84. outline
  85. single-line
  86. background-color='grey lighten-2'
  87. placeholder='None'
  88. )
  89. </template>
  90. <script>
  91. // import _ from 'lodash'
  92. import { sync } from 'vuex-pathify'
  93. import vueFilePond from 'vue-filepond'
  94. import 'filepond/dist/filepond.min.css'
  95. import FilePondPluginFileValidateType from 'filepond-plugin-file-validate-type'
  96. import uploadFileMutation from 'gql/editor/upload.gql'
  97. const FilePond = vueFilePond(FilePondPluginFileValidateType)
  98. export default {
  99. components: {
  100. FilePond
  101. },
  102. props: {
  103. value: {
  104. type: Boolean,
  105. default: false
  106. }
  107. },
  108. data() {
  109. return {
  110. files: [],
  111. remoteImageUrl: '',
  112. imageAlignments: [
  113. { text: 'None', value: '' },
  114. { text: 'Centered', value: 'center' },
  115. { text: 'Right', value: 'right' },
  116. { text: 'Absolute Top Right', value: 'abstopright' }
  117. ],
  118. imageAlignment: ''
  119. }
  120. },
  121. computed: {
  122. isShown: {
  123. get() { return this.value },
  124. set(val) { this.$emit('input', val) }
  125. },
  126. activeModal: sync('editor/activeModal')
  127. },
  128. methods: {
  129. insert () {
  130. this.activeModal = ''
  131. },
  132. async upload () {
  133. const files = this.$refs.pond.getFiles()
  134. for (let fl of files) {
  135. const resp = await this.$apollo.mutate({
  136. mutation: uploadFileMutation,
  137. variables: {
  138. data: fl.file
  139. },
  140. context: {
  141. hasUpload: true
  142. }
  143. })
  144. console.info(resp)
  145. }
  146. }
  147. }
  148. }
  149. </script>
  150. <style lang='scss'>
  151. .editor-modal-media {
  152. position: fixed;
  153. top: 112px;
  154. left: 64px;
  155. z-index: 10;
  156. width: calc(100vw - 64px - 17px);
  157. height: calc(100vh - 112px - 24px);
  158. background-color: rgba(darken(mc('grey', '900'), 3%), .9) !important;
  159. }
  160. </style>