2019-08-19 22:08:13 +00:00
|
|
|
<template>
|
|
|
|
|
<div>
|
2019-11-16 17:26:37 +00:00
|
|
|
<div class="inline-block bg-blue-800 rounded-lg">
|
2020-06-11 18:55:39 +00:00
|
|
|
<div
|
|
|
|
|
class="relative flex items-center justify-center py-2 text-blue-200 rounded-t-lg heading"
|
|
|
|
|
>
|
2019-11-16 17:26:37 +00:00
|
|
|
<svg class="w-4 h-4">
|
|
|
|
|
<use xlink:href="#time" />
|
|
|
|
|
</svg>
|
|
|
|
|
<span class="mx-3 text-sm font-bold uppercase">Recent Activity</span>
|
|
|
|
|
<svg class="w-4 h-4">
|
|
|
|
|
<use xlink:href="#time" />
|
|
|
|
|
</svg>
|
2019-08-20 20:42:11 +00:00
|
|
|
</div>
|
2019-11-16 17:26:37 +00:00
|
|
|
<div class="p-3 pt-1">
|
|
|
|
|
<div class="flex">
|
2020-06-11 18:55:39 +00:00
|
|
|
<span class="ml-12 text-xs font-semibold text-blue-200">{{ gridDays[11].month }}</span>
|
|
|
|
|
<span class="ml-16 text-xs font-semibold text-blue-200">{{ gridDays[42].month }}</span>
|
|
|
|
|
<span class="ml-16 text-xs font-semibold text-blue-200">{{ gridDays[73].month }}</span>
|
|
|
|
|
<span class="ml-16 text-xs font-semibold text-blue-200">{{ gridDays[104].month }}</span>
|
2019-08-20 20:42:11 +00:00
|
|
|
</div>
|
2020-06-11 18:55:39 +00:00
|
|
|
<div class="flex mt-1">
|
2019-11-16 17:26:37 +00:00
|
|
|
<div class="flex flex-col">
|
2020-06-11 18:55:39 +00:00
|
|
|
<span class="text-xs font-semibold leading-snug text-blue-200">Mo</span>
|
|
|
|
|
<span class="mt-1 text-xs font-semibold leading-snug text-blue-200">Tu</span>
|
|
|
|
|
<span class="mt-1 text-xs font-semibold leading-snug text-blue-200">We</span>
|
|
|
|
|
<span class="mt-1 text-xs font-semibold leading-snug text-blue-200">Th</span>
|
|
|
|
|
<span class="mt-1 text-xs font-semibold leading-snug text-blue-200">Fr</span>
|
|
|
|
|
<span class="mt-1 text-xs font-semibold leading-snug text-blue-200">Sa</span>
|
|
|
|
|
<span class="mt-1 text-xs font-semibold leading-snug text-blue-200">Su</span>
|
2019-11-16 17:26:37 +00:00
|
|
|
</div>
|
|
|
|
|
<div
|
2020-06-11 18:55:39 +00:00
|
|
|
class="flex flex-col flex-wrap ml-1"
|
2019-11-16 17:26:37 +00:00
|
|
|
style="width: calc(20px * 15); height: calc(20px * 7)"
|
|
|
|
|
>
|
2020-02-13 19:16:13 +00:00
|
|
|
<Tooltip v-for="(day, index) in gridDays.slice(indexFirstMonday)" :key="day.timestamp">
|
2021-04-03 15:18:24 +00:00
|
|
|
<template #trigger>
|
2019-11-16 17:26:37 +00:00
|
|
|
<div
|
|
|
|
|
:class="[getCaseMargin(index), getCaseColor(day.matches)]"
|
2020-06-11 18:55:39 +00:00
|
|
|
class="w-4 h-4 ml-1 cursor-pointer"
|
2019-11-16 17:26:37 +00:00
|
|
|
/>
|
|
|
|
|
</template>
|
2021-04-03 15:18:24 +00:00
|
|
|
<template #default>
|
2020-06-11 18:55:39 +00:00
|
|
|
<div class="px-2 text-xs text-center text-white">
|
2019-11-16 17:26:37 +00:00
|
|
|
<div>{{ day.date }}</div>
|
|
|
|
|
<div>
|
|
|
|
|
<span class="font-bold text-teal-400">{{ day.matches }}</span> game(s)
|
|
|
|
|
</div>
|
2019-10-13 18:29:08 +00:00
|
|
|
</div>
|
2019-11-16 17:26:37 +00:00
|
|
|
</template>
|
2020-02-13 19:16:13 +00:00
|
|
|
</Tooltip>
|
2019-11-16 17:26:37 +00:00
|
|
|
</div>
|
2019-08-20 20:42:11 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2019-08-19 22:08:13 +00:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-09-15 19:17:52 +00:00
|
|
|
import { mapState } from 'vuex'
|
2020-02-13 19:16:13 +00:00
|
|
|
import Tooltip from '@/components/Common/Tooltip.vue'
|
2019-10-13 18:29:08 +00:00
|
|
|
|
2019-08-19 22:08:13 +00:00
|
|
|
export default {
|
2019-10-13 18:29:08 +00:00
|
|
|
components: {
|
2020-02-13 19:16:13 +00:00
|
|
|
Tooltip,
|
2019-10-13 18:29:08 +00:00
|
|
|
},
|
|
|
|
|
|
2019-08-20 20:42:11 +00:00
|
|
|
data() {
|
2019-08-19 22:08:13 +00:00
|
|
|
return {
|
2019-08-20 20:42:11 +00:00
|
|
|
gridDays: [],
|
2019-08-20 21:14:22 +00:00
|
|
|
indexFirstMonday: 0,
|
2019-09-08 20:08:49 +00:00
|
|
|
nbColumns: 15,
|
|
|
|
|
options: {
|
|
|
|
|
year: 'numeric',
|
|
|
|
|
month: '2-digit',
|
|
|
|
|
day: 'numeric'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2021-09-15 19:17:52 +00:00
|
|
|
computed: {
|
|
|
|
|
...mapState({
|
|
|
|
|
recentActivity: state => state.summoner.basic.recentActivity
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
|
2019-09-08 20:08:49 +00:00
|
|
|
watch: {
|
2021-09-15 19:17:52 +00:00
|
|
|
recentActivity() {
|
2019-09-08 20:08:49 +00:00
|
|
|
this.fillGrid()
|
2019-08-23 14:48:16 +00:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
created() {
|
|
|
|
|
this.createGrid()
|
2019-08-19 22:08:13 +00:00
|
|
|
},
|
|
|
|
|
|
2019-08-20 20:42:11 +00:00
|
|
|
methods: {
|
|
|
|
|
createGrid() {
|
2019-08-23 14:48:16 +00:00
|
|
|
const nbDaysInGrid = this.nbColumns * 7
|
2019-08-19 22:08:13 +00:00
|
|
|
|
2019-08-20 20:42:11 +00:00
|
|
|
// Create array with all the days of the Grid
|
|
|
|
|
for (let i = 1; i <= nbDaysInGrid; i++) {
|
2019-08-23 14:48:16 +00:00
|
|
|
const day = new Date()
|
|
|
|
|
day.setDate(day.getDate() - nbDaysInGrid + i)
|
2020-04-03 10:40:22 +00:00
|
|
|
const formattedDay = day.toLocaleString(undefined, this.options)
|
2019-08-20 21:14:22 +00:00
|
|
|
|
2019-08-20 20:42:11 +00:00
|
|
|
this.gridDays.push({
|
|
|
|
|
date: formattedDay,
|
2019-08-20 21:14:22 +00:00
|
|
|
matches: 0,
|
2019-08-23 14:48:16 +00:00
|
|
|
day: day.toLocaleString('en', { weekday: 'long' }).substring(0, 2),
|
|
|
|
|
month: day.toLocaleString('en', { month: 'long' }).substring(0, 3)
|
|
|
|
|
})
|
2019-08-20 20:42:11 +00:00
|
|
|
}
|
|
|
|
|
|
2019-09-08 20:08:49 +00:00
|
|
|
this.fillGrid()
|
|
|
|
|
},
|
|
|
|
|
fillGrid() {
|
2019-08-20 20:42:11 +00:00
|
|
|
// Add all the matches made by the summoner
|
2021-09-15 19:17:52 +00:00
|
|
|
for (const match of this.recentActivity) {
|
|
|
|
|
const matchTime = new Date(match.day)
|
2020-04-03 10:40:22 +00:00
|
|
|
const formattedTime = matchTime.toLocaleString(undefined, this.options)
|
2019-08-20 20:42:11 +00:00
|
|
|
|
|
|
|
|
const dayOfTheMatch = this.gridDays.filter(
|
|
|
|
|
e => e.date === formattedTime
|
2019-08-23 14:48:16 +00:00
|
|
|
)
|
2019-08-20 20:42:11 +00:00
|
|
|
if (dayOfTheMatch.length > 0) {
|
2021-09-15 19:17:52 +00:00
|
|
|
dayOfTheMatch[0].matches = match.count
|
2019-08-20 20:42:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-20 21:14:22 +00:00
|
|
|
// Get the index of the first Monday
|
2019-08-23 14:48:16 +00:00
|
|
|
this.indexFirstMonday = this.gridDays.findIndex(d => d.day === 'Mo')
|
2019-08-20 20:42:11 +00:00
|
|
|
},
|
|
|
|
|
getCaseColor(nbMatches) {
|
|
|
|
|
/* TODO: change this */
|
2019-08-21 23:09:17 +00:00
|
|
|
if (nbMatches >= 6) {
|
2019-08-23 14:48:16 +00:00
|
|
|
return 'bg-teal-200'
|
2019-08-21 23:09:17 +00:00
|
|
|
} else if (nbMatches >= 4) {
|
2019-08-23 14:48:16 +00:00
|
|
|
return 'bg-teal-300'
|
2019-08-21 23:09:17 +00:00
|
|
|
} else if (nbMatches >= 2) {
|
2019-08-23 14:48:16 +00:00
|
|
|
return 'bg-teal-400'
|
2019-08-21 23:09:17 +00:00
|
|
|
} else if (nbMatches >= 1) {
|
2019-08-23 14:48:16 +00:00
|
|
|
return 'bg-teal-500'
|
2019-08-20 20:42:11 +00:00
|
|
|
}
|
2019-08-23 14:48:16 +00:00
|
|
|
return 'bg-teal-700'
|
2019-08-20 20:42:11 +00:00
|
|
|
},
|
|
|
|
|
getCaseMargin(index) {
|
|
|
|
|
if (index % 7 !== 0) {
|
2019-08-23 14:48:16 +00:00
|
|
|
return 'mt-1'
|
2019-08-19 22:08:13 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-08-20 20:42:11 +00:00
|
|
|
}
|
2019-08-23 14:48:16 +00:00
|
|
|
}
|
2019-09-08 20:08:49 +00:00
|
|
|
</script>
|