WhatIsNew.vue 2.5 KB

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