WhatIsNew.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <div
  3. v-if="news !== null"
  4. class="modal"
  5. :class="{ 'is-active': isModalActive }"
  6. >
  7. <div class="modal-background" />
  8. <div class="modal-card">
  9. <header class="modal-card-head">
  10. <p class="modal-card-title">
  11. <strong>{{ news.title }}</strong>
  12. ({{ formatDate(news.createdAt) }})
  13. </p>
  14. <button class="delete" v-on:click="toggleModal()" />
  15. </header>
  16. <section class="modal-card-body">
  17. <div class="content">
  18. <p>{{ news.description }}</p>
  19. </div>
  20. <div v-show="news.features.length > 0" class="sect">
  21. <div class="sect-head-features">
  22. The features are so great
  23. </div>
  24. <ul class="sect-body">
  25. <li
  26. v-for="(feature, index) in news.features"
  27. :key="index"
  28. >
  29. {{ feature }}
  30. </li>
  31. </ul>
  32. </div>
  33. <div v-show="news.improvements.length > 0" class="sect">
  34. <div class="sect-head-improvements">Improvements</div>
  35. <ul class="sect-body">
  36. <li
  37. v-for="(improvement, index) in news.improvements"
  38. :key="index"
  39. >
  40. {{ improvement }}
  41. </li>
  42. </ul>
  43. </div>
  44. <div v-show="news.bugs.length > 0" class="sect">
  45. <div class="sect-head-bugs">Bugs Smashed</div>
  46. <ul class="sect-body">
  47. <li v-for="(bug, index) in news.bugs" :key="index">
  48. {{ bug }}
  49. </li>
  50. </ul>
  51. </div>
  52. <div v-show="news.upcoming.length > 0" class="sect">
  53. <div class="sect-head-upcoming">
  54. Coming Soon to a Musare near you
  55. </div>
  56. <ul class="sect-body">
  57. <li
  58. v-for="(upcoming, index) in news.upcoming"
  59. :key="index"
  60. >
  61. {{ upcoming }}
  62. </li>
  63. </ul>
  64. </div>
  65. </section>
  66. </div>
  67. </div>
  68. </template>
  69. <script>
  70. import { format } from "date-fns";
  71. import io from "../../io";
  72. export default {
  73. data() {
  74. return {
  75. isModalActive: false,
  76. news: null
  77. };
  78. },
  79. mounted() {
  80. io.getSocket(true, socket => {
  81. this.socket = socket;
  82. this.socket.emit("news.newest", res => {
  83. this.news = res.data;
  84. if (this.news && localStorage.getItem("firstVisited")) {
  85. if (localStorage.getItem("whatIsNew")) {
  86. if (
  87. parseInt(localStorage.getItem("whatIsNew")) <
  88. res.data.createdAt
  89. ) {
  90. this.toggleModal();
  91. localStorage.setItem(
  92. "whatIsNew",
  93. res.data.createdAt
  94. );
  95. }
  96. } else {
  97. if (
  98. parseInt(localStorage.getItem("firstVisited")) <
  99. res.data.createdAt
  100. ) {
  101. this.toggleModal();
  102. }
  103. localStorage.setItem("whatIsNew", res.data.createdAt);
  104. }
  105. } else if (!localStorage.getItem("firstVisited"))
  106. localStorage.setItem("firstVisited", Date.now());
  107. });
  108. });
  109. },
  110. methods: {
  111. toggleModal() {
  112. this.isModalActive = !this.isModalActive;
  113. },
  114. formatDate: unix => {
  115. return format(unix, "dd-MM-yyyy");
  116. }
  117. },
  118. events: {
  119. closeModal() {
  120. this.isModalActive = false;
  121. }
  122. }
  123. };
  124. </script>
  125. <style lang="scss" scoped>
  126. @import "../../styles/global.scss";
  127. .night-mode {
  128. .modal-card,
  129. .modal-card-head,
  130. .modal-card-body {
  131. background-color: $night-mode-secondary;
  132. }
  133. strong,
  134. p {
  135. color: #ddd;
  136. }
  137. }
  138. .modal-card-head {
  139. border-bottom: none;
  140. background-color: ghostwhite;
  141. padding: 15px;
  142. }
  143. .modal-card-title {
  144. font-size: 14px;
  145. }
  146. .delete {
  147. background: transparent;
  148. &:hover {
  149. background: transparent;
  150. }
  151. &:before,
  152. &:after {
  153. background-color: #bbb;
  154. }
  155. }
  156. .sect {
  157. div[class^="sect-head"],
  158. div[class*=" sect-head"] {
  159. padding: 12px;
  160. text-transform: uppercase;
  161. font-weight: bold;
  162. color: $white;
  163. }
  164. .sect-head-features {
  165. background-color: dodgerblue;
  166. }
  167. .sect-head-improvements {
  168. background-color: seagreen;
  169. }
  170. .sect-head-bugs {
  171. background-color: brown;
  172. }
  173. .sect-head-upcoming {
  174. background-color: mediumpurple;
  175. }
  176. .sect-body {
  177. padding: 15px 25px;
  178. li {
  179. list-style-type: disc;
  180. }
  181. }
  182. }
  183. </style>