WhatIsNew.vue 2.5 KB

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