NodeViewFigure.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <figure class="node-view-figure mt-2 mb-4">
  3. <div class="node-view-img-wrapper">
  4. <img :src="image.url" :alt="image.alt">
  5. <button-expand @click="onImageExpand" v-b-modal="'modal-image-' + node.id" />
  6. <b-button variant="creation" class="btn-shadow btn-artwork" @click="onCreationClick">
  7. {{ $t('text.read-artwork') }}
  8. </b-button>
  9. </div>
  10. <figcaption class="mt-3">
  11. <node-view-title :node="node" tag="p" class="m-0" />
  12. </figcaption>
  13. </figure>
  14. </template>
  15. <script>
  16. import { trim, toCommaList } from '@/helpers/common'
  17. import { NodeViewTitle } from '@/components/nodes'
  18. export default {
  19. name: 'NodeViewFigure',
  20. components: {
  21. NodeViewTitle
  22. },
  23. props: {
  24. node: { type: Object, required: true }
  25. },
  26. data () {
  27. return {
  28. image: undefined
  29. }
  30. },
  31. methods: {
  32. trim,
  33. toCommaList,
  34. onImageExpand () {
  35. this.$emit('expand-image', this.image)
  36. },
  37. onCreationClick () {
  38. this.$store.dispatch('OPEN_CREATION', this.node.id)
  39. }
  40. },
  41. created () {
  42. if (this.node.images && this.node.images.length) {
  43. const { url, alt, id } = this.node.images[0]
  44. this.image = { alt, id, url }
  45. }
  46. }
  47. }
  48. </script>
  49. <style lang="scss" scoped>
  50. .node-view-figure {
  51. .btn-artwork {
  52. position: absolute;
  53. right: $node-view-spacer-sm-x;
  54. bottom: $node-view-spacer-sm-y;
  55. }
  56. img {
  57. max-width: 100%;
  58. }
  59. }
  60. </style>