logo

pleroma-fe

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

link-preview.vue (1790B)


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