puzzle/public/components/GameTeaser.vue.js

41 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-05-09 13:49:40 +02:00
"use strict"
2021-05-01 08:42:39 +02:00
import Time from './../../common/Time.js'
2021-05-13 22:45:55 +02:00
export default {
2021-05-01 08:42:39 +02:00
name: 'game-teaser',
props: {
game: Object,
},
template: `
<div class="game-teaser" :style="style">
2021-05-13 22:45:55 +02:00
<router-link class="game-info" :to="{ name: 'game', params: { id: game.id } }">
2021-05-01 08:42:39 +02:00
<span class="game-info-text">
🧩 {{game.tilesFinished}}/{{game.tilesTotal}}<br />
👥 {{game.players}}<br />
{{time(game.started, game.finished)}}<br />
</span>
2021-05-13 22:45:55 +02:00
</router-link>
<router-link v-if="false && game.hasReplay" class="game-replay" :to="{ name: 'replay', params: { id: game.id } }">
2021-05-01 08:42:39 +02:00
Watch replay
2021-05-13 22:45:55 +02:00
</router-link>
2021-05-01 08:42:39 +02:00
</div>`,
computed: {
style() {
const url = this.game.imageUrl.replace('uploads/', 'uploads/r/') + '-375x210.webp'
return {
'background-image': `url("${url}")`,
}
},
},
methods: {
time(start, end) {
const icon = end ? '🏁' : '⏳'
const from = start;
const to = end || Time.timestamp()
const timeDiffStr = Time.timeDiffStr(from, to)
return `${icon} ${timeDiffStr}`
},
},
}