1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
<template>
<client-only>
<div class="countdown">
{{ text }} <span>{{ days }} dni</span>
</div>
</client-only>
</template>
<script>
export default {
name: 'DayCountdown',
props: {
text: {
type: String,
required: true,
},
endDate: {
type: Date,
required: true,
},
startDate: {
type: Date,
default: () => new Date(Date.now()),
},
},
computed: {
days() {
return Math.round(
(this.endDate.getTime() - this.startDate.getTime()) / 86400000
)
},
},
}
</script>
<style>
.countdown {
background: #ffffff;
box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.2);
padding: 20px;
margin: 50px 10px;
}
.countdown span {
font-weight: 600;
}
</style>
|