WhatIsNew.vue 3.1 KB

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