link-preview.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <div>
  3. <a class="link-preview-card" :href="card.url" target="_blank" rel="noopener">
  4. <div class="card-image" :class="{ 'small-image': size === 'small' }" v-if="useImage">
  5. <img :src="card.image"></img>
  6. </div>
  7. <div class="card-content">
  8. <span class="card-host faint">{{ card.provider_name }}</span>
  9. <h4 class="card-title">{{ card.title }}</h4>
  10. <p class="card-description" v-if="useDescription">{{ card.description }}</p>
  11. </div>
  12. </a>
  13. </div>
  14. </template>
  15. <script src="./link-preview.js"></script>
  16. <style lang="scss">
  17. @import '../../_variables.scss';
  18. .link-preview-card {
  19. display: flex;
  20. flex-direction: row;
  21. cursor: pointer;
  22. overflow: hidden;
  23. margin-top: 0.5em;
  24. .card-image {
  25. flex-shrink: 0;
  26. width: 120px;
  27. max-width: 25%;
  28. img {
  29. width: 100%;
  30. height: 100%;
  31. object-fit: cover;
  32. border-radius: $fallback--attachmentRadius;
  33. border-radius: var(--attachmentRadius, $fallback--attachmentRadius);
  34. }
  35. }
  36. .small-image {
  37. width: 80px;
  38. }
  39. .card-content {
  40. max-height: 100%;
  41. margin: 0.5em;
  42. display: flex;
  43. flex-direction: column;
  44. }
  45. .card-host {
  46. font-size: 12px;
  47. }
  48. .card-description {
  49. margin: 0.5em 0 0 0;
  50. overflow: hidden;
  51. text-overflow: ellipsis;
  52. word-break: break-word;
  53. line-height: 1.2em;
  54. // cap description at 3 lines, the 1px is to clean up some stray pixels
  55. // TODO: fancier fade-out at the bottom to show off that it's too long?
  56. max-height: calc(1.2em * 3 - 1px);
  57. }
  58. color: $fallback--text;
  59. color: var(--text, $fallback--text);
  60. border-style: solid;
  61. border-width: 1px;
  62. border-radius: $fallback--attachmentRadius;
  63. border-radius: var(--attachmentRadius, $fallback--attachmentRadius);
  64. border-color: $fallback--border;
  65. border-color: var(--border, $fallback--border);
  66. }
  67. </style>