WhatIsNew.vue 3.8 KB

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