2021-04-19 18:13:54 +02:00
|
|
|
<template>
|
|
|
|
<div class="timer">
|
2021-04-19 22:46:31 +02:00
|
|
|
<p v-if="warning == false" class="timeleft reverse">{{ countDown.toString() }}</p>
|
2021-04-20 13:30:23 +02:00
|
|
|
<p v-if="(warning == true) || (typeof warning == 'undefined')" class="timeout reverse">
|
2021-04-19 22:46:31 +02:00
|
|
|
<img src="joker.png" alt="joker">
|
|
|
|
<img src="joker.png" alt="joker">
|
|
|
|
<img src="joker.png" alt="joker">
|
|
|
|
<img src="joker.png" alt="joker">
|
|
|
|
<img src="joker.png" alt="joker">
|
|
|
|
</p>
|
2021-04-20 13:30:23 +02:00
|
|
|
<button v-on:click="restartTimer" class="timerBtn"><span class="timerBtn-inner"></span></button>
|
2021-04-19 22:46:31 +02:00
|
|
|
<p v-if="warning == false" class="timeleft">{{ countDown.toString() }}</p>
|
2021-04-20 13:30:23 +02:00
|
|
|
<p v-if="warning == true || (typeof warning == 'undefined')" class="timeout">
|
2021-04-19 22:46:31 +02:00
|
|
|
<img src="joker.png" alt="joker">
|
|
|
|
<img src="joker.png" alt="joker">
|
|
|
|
<img src="joker.png" alt="joker">
|
|
|
|
<img src="joker.png" alt="joker">
|
|
|
|
<img src="joker.png" alt="joker">
|
|
|
|
</p>
|
2021-04-19 18:13:54 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-04-19 22:46:31 +02:00
|
|
|
var Interval;
|
2021-04-19 18:13:54 +02:00
|
|
|
export default {
|
|
|
|
name: "Timer",
|
|
|
|
props: {
|
|
|
|
time: Number,
|
2021-04-20 13:30:23 +02:00
|
|
|
},
|
|
|
|
data: function() {
|
|
|
|
return {
|
|
|
|
countDown: -2,
|
|
|
|
warning: true,
|
|
|
|
}
|
2021-04-19 18:13:54 +02:00
|
|
|
},
|
|
|
|
mounted: function() {
|
2021-04-20 13:30:23 +02:00
|
|
|
},
|
2021-04-19 18:13:54 +02:00
|
|
|
methods: {
|
|
|
|
timeleft: function(){
|
|
|
|
this.countDown--;
|
2021-04-19 22:46:31 +02:00
|
|
|
if(this.countDown == 0) {
|
|
|
|
this.warning = true
|
|
|
|
clearInterval(Interval);
|
|
|
|
}
|
|
|
|
|
2021-04-19 18:13:54 +02:00
|
|
|
},
|
|
|
|
restartTimer: function() {
|
|
|
|
this.countDown = this.time;
|
2021-04-19 22:46:31 +02:00
|
|
|
this.warning = false;
|
|
|
|
clearInterval(Interval);
|
|
|
|
Interval = setInterval(() => {
|
|
|
|
this.timeleft()
|
|
|
|
}, 1000);
|
2021-04-19 18:13:54 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2021-04-22 13:39:38 +02:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
@import 'src/scss/fonts.scss';
|
2021-04-19 22:46:31 +02:00
|
|
|
|
|
|
|
.timer {
|
|
|
|
height: 100%;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: space-between;
|
|
|
|
font-family: "HelveticaNeue", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
|
|
|
|
|
|
|
.timeleft {
|
2021-04-19 18:13:54 +02:00
|
|
|
font-size: 5rem;
|
2021-04-19 22:46:31 +02:00
|
|
|
margin: 40px;
|
|
|
|
font-family: "HelveticaNeue", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
|
|
|
}
|
|
|
|
|
|
|
|
.timeout {
|
|
|
|
margin: 40px;
|
|
|
|
font-family: "HelveticaNeue", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
|
|
|
|
2021-04-22 13:39:38 +02:00
|
|
|
img {
|
|
|
|
height: 3rem;
|
|
|
|
}
|
2021-04-19 22:46:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.timerBtn {
|
|
|
|
appearance: none;
|
|
|
|
border: 1px solid #2c3e50;
|
|
|
|
border-radius: 3px;
|
|
|
|
font-size: 3rem;
|
|
|
|
background: none;
|
|
|
|
padding: 2rem;
|
|
|
|
font-family: "HelveticaNeue", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
|
|
|
|
2021-04-22 13:39:38 +02:00
|
|
|
.timerBtn-inner {
|
|
|
|
display: inline-block;
|
|
|
|
height: 2rem;
|
|
|
|
width: 2rem;
|
|
|
|
background-color: #2c3e50;
|
|
|
|
}
|
2021-04-20 13:30:23 +02:00
|
|
|
}
|
|
|
|
|
2021-04-19 22:46:31 +02:00
|
|
|
.reverse {
|
|
|
|
transform: scale(-1, -1);
|
2021-04-19 18:13:54 +02:00
|
|
|
}
|
2021-04-22 13:39:38 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-04-19 18:13:54 +02:00
|
|
|
</style>
|