WhatIsNew.vue 3.8 KB

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