WhatIsNew.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <script setup lang="ts">
  2. import { defineAsyncComponent, onMounted } from "vue";
  3. import { formatDistance } from "date-fns";
  4. import { marked } from "marked";
  5. import dompurify from "dompurify";
  6. const Modal = defineAsyncComponent(() => import("@/components/Modal.vue"));
  7. const UserLink = defineAsyncComponent(
  8. () => import("@/components/UserLink.vue")
  9. );
  10. defineProps({
  11. modalUuid: { type: String, required: true },
  12. news: { type: Object, required: true }
  13. });
  14. onMounted(() => {
  15. marked.use({
  16. renderer: {
  17. table(header, body) {
  18. return `<table class="table">
  19. <thead>${header}</thead>
  20. <tbody>${body}</tbody>
  21. </table>`;
  22. }
  23. }
  24. });
  25. });
  26. const { sanitize } = dompurify;
  27. </script>
  28. <template>
  29. <modal title="News" class="what-is-news-modal">
  30. <template #body>
  31. <div
  32. class="section news-item"
  33. v-html="sanitize(marked(news.markdown))"
  34. ></div>
  35. </template>
  36. <template #footer>
  37. <span v-if="news.createdBy">
  38. By
  39. <user-link
  40. :user-id="news.createdBy"
  41. :alt="news.createdBy" /></span
  42. >&nbsp;<span :title="new Date(news.createdAt).toString()">
  43. {{
  44. formatDistance(news.createdAt, new Date(), {
  45. addSuffix: true
  46. })
  47. }}
  48. </span>
  49. </template>
  50. </modal>
  51. </template>
  52. <style lang="less">
  53. .what-is-news-modal .modal-card .modal-card-foot {
  54. column-gap: 0;
  55. }
  56. </style>
  57. <style lang="less" scoped>
  58. .night-mode {
  59. .modal-card,
  60. .modal-card-head,
  61. .modal-card-body {
  62. background-color: var(--dark-grey-3);
  63. }
  64. strong,
  65. p {
  66. color: var(--light-grey-2);
  67. }
  68. .section {
  69. background-color: transparent !important;
  70. }
  71. }
  72. .modal-card-head {
  73. border-bottom: none;
  74. background-color: ghostwhite;
  75. padding: 15px;
  76. }
  77. .modal-card-title {
  78. font-size: 14px;
  79. }
  80. .news-item {
  81. box-shadow: unset !important;
  82. }
  83. .delete {
  84. background: transparent;
  85. &:hover {
  86. background: transparent;
  87. }
  88. &:before,
  89. &:after {
  90. background-color: var(--light-grey-3);
  91. }
  92. }
  93. .sect {
  94. div[class^="sect-head"],
  95. div[class*=" sect-head"] {
  96. padding: 12px;
  97. text-transform: uppercase;
  98. font-weight: bold;
  99. color: var(--white);
  100. }
  101. .sect-head-features {
  102. background-color: dodgerblue;
  103. }
  104. .sect-head-improvements {
  105. background-color: seagreen;
  106. }
  107. .sect-head-bugs {
  108. background-color: brown;
  109. }
  110. .sect-head-upcoming {
  111. background-color: mediumpurple;
  112. }
  113. .sect-body {
  114. padding: 15px 25px;
  115. li {
  116. list-style-type: disc;
  117. }
  118. }
  119. }
  120. </style>