mirror of
https://github.com/Kugelschieber/breach.git
synced 2026-01-18 20:10:25 +00:00
Added basic components for UI.
This commit is contained in:
37
src/components/Timer.vue
Normal file
37
src/components/Timer.vue
Normal file
@@ -0,0 +1,37 @@
|
||||
<template>
|
||||
<div class="timer">
|
||||
<div class="timer-countdown">{{countdown}}</div>
|
||||
<div class="timer-progress" :style="{width: `${progress}%`}"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import {defineComponent, ref} from "vue";
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
time: {type: Object, required: true}
|
||||
},
|
||||
setup(props) {
|
||||
const countdown = ref("60.00");
|
||||
const progress = ref(100);
|
||||
|
||||
setInterval(() => {
|
||||
const remaining = (props.time.getTime()-new Date().getTime())/1000;
|
||||
|
||||
if(remaining > 0) {
|
||||
countdown.value = remaining.toFixed(2);
|
||||
progress.value = remaining/60*100;
|
||||
} else {
|
||||
countdown.value = "0.00";
|
||||
progress.value = 0;
|
||||
}
|
||||
}, 100);
|
||||
|
||||
return {
|
||||
countdown,
|
||||
progress
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user