Skip to content

Commit

Permalink
Add countdown timer and fix stream
Browse files Browse the repository at this point in the history
  • Loading branch information
weaversam8 committed Jan 9, 2021
1 parent 90a0e6a commit 2bdd93d
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 4 deletions.
11 changes: 8 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"@gridsome/source-contentful": "^0.5.2",
"buefy": "^0.8.8",
"gridsome": "^0.7.0",
"moment": "^2.29.1",
"node-sass": "^4.13.0",
"sass-loader": "^8.0.0"
"sass-loader": "^8.0.0",
"vue-awesome-countdown": "^1.1.4"
}
}
4 changes: 4 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

// Import plugins and libraries
import Buefy from "buefy";
import VueAwesomeCountdown from "vue-awesome-countdown";

// Import components
import Navbar from "~/components/Navbar.vue";
Expand All @@ -28,6 +29,9 @@ export default function(Vue, { router, head, isClient }) {
defaultIconPack: "fas", // Font Awesome Solid
});

// Use the countdown library
Vue.use(VueAwesomeCountdown);

// Make the Navbar component available on all pages
Vue.component("Navbar", Navbar);

Expand Down
42 changes: 42 additions & 0 deletions src/pages/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@
<div id="twitch-embed"></div>
<!-- Load the Twitch embed script -->

<p class="notification is-primary has-text-centered is-size-2">
<i class="fa fa-chevron-up fa-lg"></i>&nbsp;
<span>
{{ streamTimerMessage }}
<countdown :end-time="streamTimerEnd">
<span slot="process" slot-scope="{ timeObj }">{{
`${timeObj.d == "0" ? "" : timeObj.d + ":"}${
timeObj.h
}:${timeObj.m}:${timeObj.s}`
}}</span>
<span slot="finish">{{
streamTimerMessage == ""
? "Stream is " + streamTimerTense
: "... now!"
}}</span>
</countdown> </span
>&nbsp;
<i class="fa fa-chevron-up fa-lg"></i>
</p>

<p class="notification is-primary has-text-centered">
<i class="fa fa-chevron-down fa-lg"></i>&nbsp;
<strong>Warning: Outdated content!</strong> Content beneath this box
Expand Down Expand Up @@ -133,6 +153,11 @@

<script>
import BlogPostList from "~/components/BlogPostList.vue";
import moment from "moment";
const streamStart = moment("2021-01-09 13:00:00-05:00");
const streamEnd = moment("2021-01-09 22:00:00-05:00");
const finalStretch = false;
const meta = {
url: "https://fullmoonrobotics.org/",
Expand Down Expand Up @@ -168,6 +193,23 @@ export default {
parent: ["fullmoonrobotics.org"],
});
},
computed: {
streamTimerMessage() {
if (moment().isBefore(streamStart)) return "Stream starts in ";
else if (finalStretch && moment().isBefore(streamEnd))
return "Stream ends in ";
else return "";
},
streamTimerTense() {
if (moment().isBefore(streamEnd)) return "live!";
else return "offline.";
},
streamTimerEnd() {
if (moment().isBefore(streamStart) || !finalStretch)
return streamStart.toDate();
else return streamEnd.toDate();
},
},
components: {
BlogPostList,
},
Expand Down

0 comments on commit 2bdd93d

Please sign in to comment.