index.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <div
  3. class="o-media-card u-pointer"
  4. @click="onClick"
  5. @dblclick="onDblclick"
  6. >
  7. <auto-image
  8. class="o-media-card__image"
  9. :placeholder="source.icon"
  10. :src="source.thumb"
  11. />
  12. <auto-text
  13. class="o-media-card__name"
  14. :text="source.name"
  15. />
  16. <slot />
  17. </div>
  18. </template>
  19. <script>
  20. export default {
  21. name: 'MediaCard',
  22. props: {
  23. source: {
  24. type: Object,
  25. required: true
  26. }
  27. },
  28. methods: {
  29. onClick () {
  30. this.$emit('click', this.source)
  31. },
  32. onDblclick () {
  33. this.$emit('dblclick', this.source)
  34. }
  35. }
  36. }
  37. </script>
  38. <style lang="scss" scoped>
  39. .o-media-card {
  40. display: inline-block;
  41. position: relative;
  42. padding-top: 56.25%;
  43. color: $info;
  44. background-color: rgba(0, 0, 0, 0.8);
  45. &__name {
  46. position: absolute;
  47. left: 0;
  48. right: 0;
  49. bottom: 0;
  50. padding: 4px 6px;
  51. font-size: 14px;
  52. text-align: center;
  53. background-color: rgba(0, 0, 0, 0.6);
  54. }
  55. &__image {
  56. position: absolute;
  57. top: 0;
  58. left: 0;
  59. width: 100%;
  60. height: 100%;
  61. font-size: 20px;
  62. }
  63. }
  64. </style>