Skip to content

Commit 616e5f0

Browse files
committed
V2
1 parent c0c8c0a commit 616e5f0

File tree

10 files changed

+1975
-2262
lines changed

10 files changed

+1975
-2262
lines changed

components/Map/index.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,30 +205,40 @@ export default {
205205
206206
/deep/ .popup {
207207
margin: 0 16px 0 8px;
208+
208209
&_title {
209210
margin-top: 4px;
210211
margin-bottom: 8px;
211212
font-size: 16px;
212213
}
214+
213215
&_item {
216+
214217
span {
215218
font-weight: 700;
216219
font-size: 14px;
220+
217221
&:first-child {
218222
font-weight: 300;
219223
}
220224
}
225+
221226
&.item_confirmed {
227+
222228
.value {
223229
color: #ffa500;
224230
}
225231
}
232+
226233
&.item_recovered {
234+
227235
.value {
228236
color: #66a266;
229237
}
230238
}
239+
231240
&.item_dead {
241+
232242
.value {
233243
color: #b20000;
234244
}

components/Overview/index.vue

Lines changed: 140 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,107 @@
11
<template>
22
<div class="overview">
3+
<div class="title">
4+
{{ title }}
5+
<a class="close" href="#" @click.prevent="onClose">
6+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none">
7+
<g opacity="0.3">
8+
<path d="M1.5 1.5L15 15" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
9+
<path d="M15 1.5L1.5 15" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
10+
</g>
11+
</svg>
12+
</a>
13+
</div>
314
<div class="content">
4-
<div class="title">
5-
{{ title }}
6-
<div class="close" @click="onClose">
7-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none">
8-
<g opacity="0.3">
9-
<path d="M1.5 1.5L15 15" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
10-
<path d="M15 1.5L1.5 15" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
11-
</g>
12-
</svg>
13-
</div>
14-
</div>
15-
<div class="cases">
15+
<div class="section cases">
1616
<p>Known Cases</p>
1717
<Latest :data="latest" :invert="true" />
1818
</div>
19+
<div class="section chart">
20+
<p>Daily</p>
21+
<p class="sub">Click chart to view daily cases</p>
22+
<client-only>
23+
<apexchart height="350" type="line" :options="chartOptions" :series="series"></apexchart>
24+
</client-only>
25+
</div>
1926
</div>
2027
</div>
2128
</template>
2229

2330
<script>
31+
import { mapGetters } from 'vuex'
2432
import Latest from '~/components/Latest'
2533
2634
export default {
2735
name: 'Overview',
2836
components: {
2937
Latest
3038
},
31-
props: {
32-
data: Object
33-
},
3439
computed: {
40+
...mapGetters([
41+
'result'
42+
]),
3543
title() {
36-
const o = this.data
44+
const o = this.result
3745
return o.province ? `${o.province}, ${o.country}` : o.country
3846
},
3947
latest() {
40-
return this.data.latest
48+
return this.result.latest
49+
},
50+
chartOptions() {
51+
return {
52+
chart: {
53+
zoom: {
54+
enabled: false
55+
},
56+
toolbar: {
57+
show: false
58+
},
59+
stacked: false
60+
},
61+
dataLabels: {
62+
enabled: false
63+
},
64+
colors: ["#ffa500", "#b20000", "#66a266"],
65+
stroke: {
66+
width: [4, 4, 4]
67+
},
68+
xaxis: {
69+
type: "datetime",
70+
labels: {
71+
format: "dd MMM"
72+
}
73+
},
74+
yaxis: {
75+
opposite: true,
76+
labels: {
77+
align: 'right',
78+
offsetX: -20
79+
}
80+
},
81+
legend: {
82+
show: false,
83+
horizontalAlign: "left"
84+
}
85+
}
86+
},
87+
series() {
88+
const timelineConfirmed = Object.entries(this.result.timelines.confirmed.timeline).map(o => o)
89+
const timelineDeaths = Object.entries(this.result.timelines.deaths.timeline).map(o => o)
90+
const timelineRecovered = Object.entries(this.result.timelines.recovered.timeline).map(o => o)
91+
return [
92+
{
93+
name: "Confirmed",
94+
data: timelineConfirmed
95+
},
96+
{
97+
name: "Deaths",
98+
data: timelineDeaths
99+
},
100+
{
101+
name: "Recovered",
102+
data: timelineRecovered
103+
}
104+
]
41105
}
42106
},
43107
data() {
@@ -46,31 +110,56 @@ export default {
46110
methods: {
47111
onClose() {
48112
this.$emit('close')
113+
},
114+
formatDate(val) {
115+
const d = new Date(val)
116+
const dtf = new Intl.DateTimeFormat('en', {
117+
year: 'numeric',
118+
month: 'short',
119+
day: '2-digit'
120+
})
121+
const [{ value: mo }, , { value: da }, , { value: ye }] = dtf.formatToParts(d)
122+
return {
123+
month: mo,
124+
date: da,
125+
year: ye
126+
}
49127
}
50128
}
51129
}
52130
</script>
53131

54132
<style lang="scss" scoped>
55133
.overview {
56-
width: 100%;
134+
border-radius: 4px;
135+
padding: 24px;
136+
width: 624px;
137+
height: 100%;
57138
background-color: #ffffff;
58139
140+
@media only screen and (min-width: 768px) {
141+
height: auto;
142+
}
143+
59144
.close {
60145
position: absolute;
61146
top: 50%;
62147
right: 0;
63148
width: 16px;
64149
height: 16px;
150+
display: block;
65151
cursor: pointer;
66152
z-index: 1;
67153
transform: translateY(calc(-50% - 16px));
68154
transition: all .3s;
69155
fill: rgba(0,0,0,.5);
156+
157+
svg {
158+
cursor: pointer;
159+
}
70160
}
71161
72162
.content {
73-
padding: 0 24px;
74163
color: #000000;
75164
}
76165
@@ -80,16 +169,32 @@ export default {
80169
margin: 32px 0 12px;
81170
padding-bottom: 8px;
82171
font-size: 32px;
172+
173+
@media only screen and (min-width: 768px) {
174+
margin: 0 0 12px;
175+
}
83176
}
84177
85-
.cases {
86-
font-size: 24px;
87-
font-weight: 300;
178+
.section {
179+
margin-top: 24px;
180+
181+
&:first-of-type {
182+
margin-top: 0;
183+
}
88184
89-
p {
185+
& > p {
90186
margin-bottom: 8px;
187+
font-size: 24px;
188+
font-weight: 300;
189+
190+
&.sub {
191+
font-size: 14px;
192+
color: #666666;
193+
}
91194
}
195+
}
92196
197+
.cases {
93198
/deep/ .latest {
94199
position: relative;
95200
@@ -107,5 +212,17 @@ export default {
107212
}
108213
}
109214
}
215+
216+
.chart {
217+
max-width: 624px;
218+
219+
& > p {
220+
& + div {
221+
border: 1px solid #cccccc;
222+
border-radius: 4px;
223+
margin-top: 12px;
224+
}
225+
}
226+
}
110227
}
111228
</style>

0 commit comments

Comments
 (0)