News.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <div class="app">
  3. <metadata title="News" />
  4. <main-header />
  5. <div class="container">
  6. <div
  7. v-for="(item, index) in news"
  8. :key="index"
  9. class="card is-fullwidth"
  10. >
  11. <header class="card-header">
  12. <p class="card-header-title">
  13. {{ item.title }} - {{ formatDate(item.createdAt) }}
  14. </p>
  15. </header>
  16. <div class="card-content">
  17. <div class="content">
  18. <p>{{ item.description }}</p>
  19. </div>
  20. <div v-show="item.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 item.features"
  27. :key="index"
  28. >
  29. {{ feature }}
  30. </li>
  31. </ul>
  32. </div>
  33. <div v-show="item.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,
  40. index) in item.improvements"
  41. :key="index"
  42. >
  43. {{ improvement }}
  44. </li>
  45. </ul>
  46. </div>
  47. <div v-show="item.bugs.length > 0" class="sect">
  48. <div class="sect-head-bugs">
  49. Bugs Smashed
  50. </div>
  51. <ul class="sect-body">
  52. <li v-for="(bug, index) in item.bugs" :key="index">
  53. {{ bug }}
  54. </li>
  55. </ul>
  56. </div>
  57. <div v-show="item.upcoming.length > 0" class="sect">
  58. <div class="sect-head-upcoming">
  59. Coming Soon to a Musare near you
  60. </div>
  61. <ul class="sect-body">
  62. <li
  63. v-for="(upcoming, index) in item.upcoming"
  64. :key="index"
  65. >
  66. {{ upcoming }}
  67. </li>
  68. </ul>
  69. </div>
  70. </div>
  71. </div>
  72. <h3 v-if="noFound" class="center">
  73. No news items were found.
  74. </h3>
  75. </div>
  76. <main-footer />
  77. </div>
  78. </template>
  79. <script>
  80. import MainHeader from "../MainHeader.vue";
  81. import MainFooter from "../MainFooter.vue";
  82. import io from "../../io";
  83. export default {
  84. components: { MainHeader, MainFooter },
  85. data() {
  86. return {
  87. news: [],
  88. noFound: false
  89. };
  90. },
  91. mounted() {
  92. io.getSocket(socket => {
  93. this.socket = socket;
  94. this.socket.emit("news.index", res => {
  95. this.news = res.data;
  96. if (this.news.length === 0) this.noFound = true;
  97. });
  98. this.socket.on("event:admin.news.created", news => {
  99. this.news.unshift(news);
  100. this.noFound = false;
  101. });
  102. this.socket.on("event:admin.news.updated", news => {
  103. for (let n = 0; n < this.news.length; n += 1) {
  104. if (this.news[n]._id === news._id) {
  105. this.news.$set(n, news);
  106. }
  107. }
  108. });
  109. this.socket.on("event:admin.news.removed", news => {
  110. this.news = this.news.filter(item => item._id !== news._id);
  111. if (this.news.length === 0) this.noFound = true;
  112. });
  113. });
  114. },
  115. methods: {
  116. formatDate: unix => {
  117. return moment(unix).format("DD-MM-YYYY");
  118. }
  119. }
  120. };
  121. </script>
  122. <style lang="scss" scoped>
  123. @import "styles/global.scss";
  124. .card {
  125. margin-top: 50px;
  126. }
  127. .sect {
  128. div[class^="sect-head"],
  129. div[class*=" sect-head"] {
  130. padding: 12px;
  131. text-transform: uppercase;
  132. font-weight: bold;
  133. color: $white;
  134. }
  135. .sect-head-features {
  136. background-color: dodgerblue;
  137. }
  138. .sect-head-improvements {
  139. background-color: seagreen;
  140. }
  141. .sect-head-bugs {
  142. background-color: brown;
  143. }
  144. .sect-head-upcoming {
  145. background-color: mediumpurple;
  146. }
  147. .sect-body {
  148. padding: 15px 25px;
  149. li {
  150. list-style-type: disc;
  151. }
  152. }
  153. }
  154. </style>