1
1
<template >
2
- <table >
3
- <tr >
4
- <td >
5
- <div class =" msg text-center" >
6
- <div class =" row" >
7
- <p class =" name" ><a :href =" `/election/${election.id}`" class =" name" >{{ election.goal }}</a ></p >
8
- </div >
9
- <div class =" row" >
10
- <p class =" links-container" >
11
- <a :href =" `/elections/${election.id}`" class =" useful-link" >Details</a >
12
- <a :href =" `/vote/${election.id}`" class =" useful-link" v-if =" isOpen(election)" >Vote</a >
13
- </p >
14
- </div >
15
- </div >
16
- </td >
17
- <td >
18
- <div class =" date" aria-label =" start date" >
19
- <span class =" first" ><svg xmlns =" http://www.w3.org/2000/svg" width =" 28" height =" 28" fill =" currentColor" class =" bi bi-hourglass-top" viewBox =" 0 0 16 16" >
20
- <path d =" M2 14.5a.5.5 0 0 0 .5.5h11a.5.5 0 1 0 0-1h-1v-1a4.5 4.5 0 0 0-2.557-4.06c-.29-.139-.443-.377-.443-.59v-.7c0-.213.154-.451.443-.59A4.5 4.5 0 0 0 12.5 3V2h1a.5.5 0 0 0 0-1h-11a.5.5 0 0 0 0 1h1v1a4.5 4.5 0 0 0 2.557 4.06c.29.139.443.377.443.59v.7c0 .213-.154.451-.443.59A4.5 4.5 0 0 0 3.5 13v1h-1a.5.5 0 0 0-.5.5m2.5-.5v-1a3.5 3.5 0 0 1 1.989-3.158c.533-.256 1.011-.79 1.011-1.491v-.702s.18.101.5.101.5-.1.5-.1v.7c0 .701.478 1.236 1.011 1.492A3.5 3.5 0 0 1 11.5 13v1z" />
21
- </svg > {{ ("0" + election.start.getUTCDate()).slice(-2) }}
22
- </span ><br />
23
- <span >{{ election.start.toLocaleString('default', { month: 'short' }) }} {{election.start.getFullYear() }}</span ><br />
24
- <span >{{ ("0" + election.start.getHours()).slice(-2) }}:{{ ("0" + election.start.getMinutes()).slice(-2) }}</span >
25
- </div >
26
- </td >
27
- <td >
28
- <div class =" date" aria-label =" end date" >
29
- <span class =" first date" ><svg xmlns =" http://www.w3.org/2000/svg" width =" 28" height =" 28" fill =" currentColor" class =" bi bi-hourglass-bottom" viewBox =" 0 0 16 16" >
30
- <path d =" M2 1.5a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-1v1a4.5 4.5 0 0 1-2.557 4.06c-.29.139-.443.377-.443.59v.7c0 .213.154.451.443.59A4.5 4.5 0 0 1 12.5 13v1h1a.5.5 0 0 1 0 1h-11a.5.5 0 1 1 0-1h1v-1a4.5 4.5 0 0 1 2.557-4.06c.29-.139.443-.377.443-.59v-.7c0-.213-.154-.451-.443-.59A4.5 4.5 0 0 1 3.5 3V2h-1a.5.5 0 0 1-.5-.5m2.5.5v1a3.5 3.5 0 0 0 1.989 3.158c.533.256 1.011.791 1.011 1.491v.702s.18.149.5.149.5-.15.5-.15v-.7c0-.701.478-1.236 1.011-1.492A3.5 3.5 0 0 0 11.5 3V2z" />
31
- </svg > {{ ("0" + election.end.getUTCDate()).slice(-2) }}
32
- </span ><br />
33
- <span >{{ election.end.toLocaleString('default', { month: 'short' }) }} {{election.end.getFullYear() }}</span ><br />
34
- <span >{{ ("0" + election.end.getHours()).slice(-2) }}:{{ ("0" + election.end.getMinutes()).slice(-2) }}</span >
35
- </div >
36
- </td >
37
- </tr >
38
- </table >
2
+ <div class =" row" >
3
+ <div class =" col msg text-center" >
4
+ <div class =" row" >
5
+ <p class =" name" ><a :href =" `/elections/${election.id}`" class =" name" >{{ election.goal }}</a ></p >
6
+ </div >
7
+ <div class =" d-flex justify-content-center flex-wrap" >
8
+ <a :href =" `/elections/${election.id}`" class =" useful-link" >Details</a >
9
+ <a :href =" `/vote/${election.id}`" class =" useful-link" v-if =" isOpen(election)" >Vote</a >
10
+ </div >
11
+ </div >
12
+ <div class =" col date my-auto" aria-label =" start date" >
13
+ <span class =" first" >
14
+ <svg xmlns =" http://www.w3.org/2000/svg" width =" 28" height =" 28" fill =" currentColor" class =" bi bi-hourglass-top" viewBox =" 0 0 16 16" >
15
+ <path d =" M2 14.5a.5.5 0 0 0 .5.5h11a.5.5 0 1 0 0-1h-1v-1a4.5 4.5 0 0 0-2.557-4.06c-.29-.139-.443-.377-.443-.59v-.7c0-.213.154-.451.443-.59A4.5 4.5 0 0 0 12.5 3V2h1a.5.5 0 0 0 0-1h-11a.5.5 0 0 0 0 1h1v1a4.5 4.5 0 0 0 2.557 4.06c.29.139.443.377.443.59v.7c0 .213-.154.451-.443.59A4.5 4.5 0 0 0 3.5 13v1h-1a.5.5 0 0 0-.5.5m2.5-.5v-1a3.5 3.5 0 0 1 1.989-3.158c.533-.256 1.011-.79 1.011-1.491v-.702s.18.101.5.101.5-.1.5-.1v.7c0 .701.478 1.236 1.011 1.492A3.5 3.5 0 0 1 11.5 13v1z" />
16
+ </svg >
17
+ {{formatDate(election.start).substring(0, 2)}}
18
+ </span >
19
+ <br />
20
+ <span >{{capitalizeFirstLetter(formatDate(election.start, 'numeric').substring(3, 11))}}</span >
21
+ <br />
22
+ <span >{{formatTime(election.start)}}</span >
23
+ </div >
24
+ <div class =" col date my-auto" aria-label =" end date" >
25
+ <span class =" first date" >
26
+ <svg xmlns =" http://www.w3.org/2000/svg" width =" 28" height =" 28" fill =" currentColor" class =" bi bi-hourglass-bottom" viewBox =" 0 0 16 16" >
27
+ <path d =" M2 1.5a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-1v1a4.5 4.5 0 0 1-2.557 4.06c-.29.139-.443.377-.443.59v.7c0 .213.154.451.443.59A4.5 4.5 0 0 1 12.5 13v1h1a.5.5 0 0 1 0 1h-11a.5.5 0 1 1 0-1h1v-1a4.5 4.5 0 0 1 2.557-4.06c.29-.139.443-.377.443-.59v-.7c0-.213-.154-.451-.443-.59A4.5 4.5 0 0 1 3.5 3V2h-1a.5.5 0 0 1-.5-.5m2.5.5v1a3.5 3.5 0 0 0 1.989 3.158c.533.256 1.011.791 1.011 1.491v.702s.18.149.5.149.5-.15.5-.15v-.7c0-.701.478-1.236 1.011-1.492A3.5 3.5 0 0 0 11.5 3V2z" />
28
+ </svg > {{ ("0" + election.end.getUTCDate()).slice(-2) }}
29
+ </span >
30
+ <br />
31
+ <span >{{capitalizeFirstLetter(formatDate(election.end, 'numeric').substring(3, 11))}}</span >
32
+ <br />
33
+ <span >{{formatTime(election.end)}}</span >
34
+ </div >
35
+ </div >
39
36
</template >
40
37
41
38
<script setup lang="ts">
42
- import type {VotingWithStatus } from " @/stores/voting" ;
39
+ import type {Voting } from " @/stores/voting" ;
40
+ import {capitalizeFirstLetter , formatDate , formatTime , getStatus } from " @/commons/utils" ;
41
+ import {ref } from " vue" ;
43
42
44
- function isOpen(election : VotingWithStatus ): boolean {
45
- return election . status === ' open' ;
43
+ function isOpen(election : Voting ): boolean {
44
+ return getStatus ( election , now . value ) === ' open' ;
46
45
}
47
- defineProps <{
48
- election: VotingWithStatus
46
+ const props = defineProps <{
47
+ election: Voting ,
48
+ time: number ,
49
49
}>()
50
+
51
+ const now = ref (props .time );
50
52
</script >
51
53
52
54
<style scoped>
53
-
54
- table td + td {
55
- border-left : 2px solid red ;
56
- }
57
-
58
55
div .date {
59
56
color : #0d6efd ;
57
+ border-left : 2px solid #e6308a ;
60
58
span .first {
61
59
font-weight : bold ;
62
60
font-size : 2em ;
@@ -69,28 +67,31 @@ div.date {
69
67
70
68
p .name {
71
69
font-weight : bold ;
72
- font-size : 1.1em ;
73
- color : #e6308a ;
70
+ font-size : 1.2em ;
74
71
margin : 4% 0 ;
75
- }
76
-
77
- p .links-container {
78
- display : flex ;
79
- justify-content : space-between ;
80
- padding : 0 15% ;
72
+ text-transform : uppercase ;
81
73
}
82
74
83
75
a {
84
76
color : #e6308a ;
85
77
text-decoration : none ;
86
78
}
87
79
88
- a .useful-link {
89
- margin : 0 10px ;
90
- }
91
-
92
80
a :hover {
93
81
text-decoration : underline ;
94
82
}
95
83
96
- </style >
84
+ a .useful-link {
85
+ padding : 6px 10px ;
86
+ margin : 6px ;
87
+ border-radius : 15px ;
88
+ border : 1px solid #0d6efd ;
89
+ text-decoration : none ;
90
+ color : #0d6efd ;
91
+ }
92
+
93
+ a .useful-link :hover {
94
+ font-weight : bold ;
95
+ box-shadow : 1px 2px 5px rgba (200 , 200 , 200 , 0.82 );
96
+ }
97
+ </style >
0 commit comments