feat: add tooltip on match data to see full date

This commit is contained in:
vkaelin 2019-11-28 10:06:27 +01:00
parent 1313dce901
commit 8e61783c9a
3 changed files with 20 additions and 12 deletions

View file

@ -127,7 +127,20 @@
<div class="ml-auto flex flex-col items-center justify-center"> <div class="ml-auto flex flex-col items-center justify-center">
<img class="w-5 h-5" src="@/assets/img/icons/Stopwatch.svg" alt="Stopwatch" /> <img class="w-5 h-5" src="@/assets/img/icons/Stopwatch.svg" alt="Stopwatch" />
<div class="text-lg text-teal-400 font-medium">{{ data.time|secToTime }}</div> <div class="text-lg text-teal-400 font-medium">{{ data.time|secToTime }}</div>
<Dropdown>
<template v-slot:trigger>
<div class="text-xs text-white font-medium">{{ data.date }}</div> <div class="text-xs text-white font-medium">{{ data.date }}</div>
</template>
<template v-slot:default>
<div class="px-2 text-white text-center text-xs leading-tight select-none">
<svg class="w-4 h-4 mx-auto text-teal-400">
<use xlink:href="#time" />
</svg>
<div class="mt-1">{{ data.fullDate.date }}</div>
<div>{{ data.fullDate.time }}</div>
</div>
</template>
</Dropdown>
</div> </div>
</div> </div>
</div> </div>
@ -138,6 +151,7 @@
<script> <script>
import { mapActions, mapState, mapGetters } from 'vuex' import { mapActions, mapState, mapGetters } from 'vuex'
import Dropdown from '@/components/Dropdown'
import DetailedMatch from '@/components/Match/DetailedMatch' import DetailedMatch from '@/components/Match/DetailedMatch'
import MatchItems from '@/components/Match/MatchItems' import MatchItems from '@/components/Match/MatchItems'
import Ripple from '@/components/Ripple.vue' import Ripple from '@/components/Ripple.vue'
@ -145,6 +159,7 @@ import Ripple from '@/components/Ripple.vue'
export default { export default {
components: { components: {
DetailedMatch, DetailedMatch,
Dropdown,
MatchItems, MatchItems,
Ripple, Ripple,
}, },

View file

@ -25,14 +25,3 @@ export function timeDifference(previous) {
return day + '.' + month + '.' + oldDate.getFullYear().toString().substr(-2) return day + '.' + month + '.' + oldDate.getFullYear().toString().substr(-2)
} }
} }
/**
* Return time in a formatted way
* @param sec : time in seconds to convert
*/
export function secToTime(sec) {
const min = Math.floor(sec / 60)
const newSec = sec - min * 60
return min + 'm' + (newSec < 10 ? '0' + newSec : newSec) + 's'
}

View file

@ -32,6 +32,10 @@ export function createMatchData(matches) {
match.firstSum = getSummonerLink(match.firstSum) match.firstSum = getSummonerLink(match.firstSum)
match.secondSum = getSummonerLink(match.secondSum) match.secondSum = getSummonerLink(match.secondSum)
const date = new Date(match.date)
const dateOptions = { day: '2-digit', month: '2-digit', year: 'numeric' }
const timeOptions = { hour12: false, hour: '2-digit', minute:'2-digit' }
match.fullDate = { date: date.toLocaleString('fr', dateOptions), time: date.toLocaleString('fr', timeOptions) }
match.date = timeDifference(match.date) match.date = timeDifference(match.date)
match.map = maps[match.map] match.map = maps[match.map]