123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- <template>
- <div
- v-if="news !== null"
- class="modal"
- :class="{ 'is-active': isModalActive }"
- >
- <div class="modal-background" />
- <div class="modal-card">
- <header class="modal-card-head">
- <p class="modal-card-title">
- <strong>{{ news.title }}</strong>
- ({{ formatDate(news.createdAt) }})
- </p>
- <button class="delete" v-on:click="toggleModal()" />
- </header>
- <section class="modal-card-body">
- <div class="content">
- <p>{{ news.description }}</p>
- </div>
- <div v-show="news.features.length > 0" class="sect">
- <div class="sect-head-features">
- The features are so great
- </div>
- <ul class="sect-body">
- <li
- v-for="(feature, index) in news.features"
- :key="index"
- >
- {{ feature }}
- </li>
- </ul>
- </div>
- <div v-show="news.improvements.length > 0" class="sect">
- <div class="sect-head-improvements">
- Improvements
- </div>
- <ul class="sect-body">
- <li
- v-for="(improvement, index) in news.improvements"
- :key="index"
- >
- {{ improvement }}
- </li>
- </ul>
- </div>
- <div v-show="news.bugs.length > 0" class="sect">
- <div class="sect-head-bugs">
- Bugs Smashed
- </div>
- <ul class="sect-body">
- <li v-for="(bug, index) in news.bugs" :key="index">
- {{ bug }}
- </li>
- </ul>
- </div>
- <div v-show="news.upcoming.length > 0" class="sect">
- <div class="sect-head-upcoming">
- Coming Soon to a Musare near you
- </div>
- <ul class="sect-body">
- <li
- v-for="(upcoming, index) in news.upcoming"
- :key="index"
- >
- {{ upcoming }}
- </li>
- </ul>
- </div>
- </section>
- </div>
- </div>
- </template>
- <script>
- import { format } from "date-fns";
- import io from "../../io";
- export default {
- data() {
- return {
- isModalActive: false,
- news: null
- };
- },
- mounted() {
- io.getSocket(true, socket => {
- this.socket = socket;
- this.socket.emit("news.newest", res => {
- this.news = res.data;
- if (this.news && localStorage.getItem("firstVisited")) {
- if (localStorage.getItem("whatIsNew")) {
- if (
- parseInt(localStorage.getItem("whatIsNew")) <
- res.data.createdAt
- ) {
- this.toggleModal();
- localStorage.setItem(
- "whatIsNew",
- res.data.createdAt
- );
- }
- } else {
- if (
- parseInt(localStorage.getItem("firstVisited")) <
- res.data.createdAt
- ) {
- this.toggleModal();
- }
- localStorage.setItem("whatIsNew", res.data.createdAt);
- }
- } else if (!localStorage.getItem("firstVisited"))
- localStorage.setItem("firstVisited", Date.now());
- });
- });
- },
- methods: {
- toggleModal() {
- this.isModalActive = !this.isModalActive;
- },
- formatDate: unix => {
- return format(unix, "dd-MM-yyyy");
- }
- },
- events: {
- closeModal() {
- this.isModalActive = false;
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- @import "styles/global.scss";
- .night-mode {
- .modal-card,
- .modal-card-head,
- .modal-card-body {
- background-color: $night-mode-secondary;
- }
- strong,
- p {
- color: #ddd;
- }
- }
- .modal-card-head {
- border-bottom: none;
- background-color: ghostwhite;
- padding: 15px;
- }
- .modal-card-title {
- font-size: 14px;
- }
- .delete {
- background: transparent;
- &:hover {
- background: transparent;
- }
- &:before,
- &:after {
- background-color: #bbb;
- }
- }
- .sect {
- div[class^="sect-head"],
- div[class*=" sect-head"] {
- padding: 12px;
- text-transform: uppercase;
- font-weight: bold;
- color: $white;
- }
- .sect-head-features {
- background-color: dodgerblue;
- }
- .sect-head-improvements {
- background-color: seagreen;
- }
- .sect-head-bugs {
- background-color: brown;
- }
- .sect-head-upcoming {
- background-color: mediumpurple;
- }
- .sect-body {
- padding: 15px 25px;
- li {
- list-style-type: disc;
- }
- }
- }
- </style>
|