WhatIsNew.vue 2.6 KB

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