News.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <div class='app'>
  3. <main-header></main-header>
  4. <div class='container'>
  5. <div class='card is-fullwidth' v-for='item in news'>
  6. <header class='card-header'>
  7. <p class='card-header-title'>
  8. {{ item.title }} - {{ formatDate(item.createdAt) }}
  9. </p>
  10. </header>
  11. <div class='card-content'>
  12. <div class='content'>
  13. <p>{{ item.description }}</p>
  14. </div>
  15. <div class='sect' v-show='item.features.length > 0'>
  16. <div class='sect-head-features'>The features are so great</div>
  17. <ul class='sect-body'>
  18. <li v-for='li in item.features'>{{ li }}</li>
  19. </ul>
  20. </div>
  21. <div class='sect' v-show='item.improvements.length > 0'>
  22. <div class='sect-head-improvements'>Improvements</div>
  23. <ul class='sect-body'>
  24. <li v-for='li in item.improvements'>{{ li }}</li>
  25. </ul>
  26. </div>
  27. <div class='sect' v-show='item.bugs.length > 0'>
  28. <div class='sect-head-bugs'>Bugs Smashed</div>
  29. <ul class='sect-body'>
  30. <li v-for='li in item.bugs'>{{ li }}</li>
  31. </ul>
  32. </div>
  33. <div class='sect' v-show='item.upcoming.length > 0'>
  34. <div class='sect-head-upcoming'>Coming Soon to a Musare near you</div>
  35. <ul class='sect-body'>
  36. <li v-for='li in item.upcoming'>{{ li }}</li>
  37. </ul>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. <main-footer></main-footer>
  43. </div>
  44. </template>
  45. <script>
  46. import MainHeader from '../MainHeader.vue';
  47. import MainFooter from '../MainFooter.vue';
  48. import io from '../../io';
  49. export default {
  50. components: { MainHeader, MainFooter },
  51. methods: {
  52. formatDate: unix => {
  53. return moment(unix).format('DD-MM-YYYY');
  54. }
  55. },
  56. data() {
  57. return {
  58. news: []
  59. }
  60. },
  61. ready: function () {
  62. let _this = this;
  63. io.getSocket((socket) => {
  64. _this.socket = socket;
  65. _this.socket.emit('news.index', res => {
  66. _this.news = res.data;
  67. });
  68. _this.socket.on('event:admin.news.created', news => {
  69. _this.news.unshift(news);
  70. });
  71. _this.socket.on('event:admin.news.updated', news => {
  72. for (let n = 0; n < _this.news.length; n++) {
  73. if (_this.news[n]._id === news._id) {
  74. _this.news.$set(n, news);
  75. }
  76. }
  77. });
  78. _this.socket.on('event:admin.news.removed', news => {
  79. _this.news = _this.news.filter(item => item._id !== news._id);
  80. });
  81. });
  82. }
  83. }
  84. </script>
  85. <style lang='scss' scoped>
  86. .card { margin-top: 50px; }
  87. .sect {
  88. div[class^='sect-head'], div[class*=' sect-head']{
  89. padding: 12px;
  90. text-transform: uppercase;
  91. font-weight: bold;
  92. color: #fff;
  93. }
  94. .sect-head-features { background-color: dodgerblue; }
  95. .sect-head-improvements { background-color: seagreen; }
  96. .sect-head-bugs { background-color: brown; }
  97. .sect-head-upcoming { background-color: mediumpurple; }
  98. .sect-body {
  99. padding: 15px 25px;
  100. li { list-style-type: disc; }
  101. }
  102. }
  103. </style>