bit improved index page
This commit is contained in:
parent
f5a93f1f57
commit
7a957ca09c
4 changed files with 58 additions and 20 deletions
|
|
@ -28,30 +28,50 @@ const Upload = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const GameTeaser = {
|
||||||
|
name: 'gameteaser',
|
||||||
|
props: {
|
||||||
|
game: Object,
|
||||||
|
},
|
||||||
|
template: `
|
||||||
|
<div class="game-teaser" :style="'background-image: url('+game.imageUrl+')'">
|
||||||
|
<a class="game-info" :href="'/g/' + game.id">
|
||||||
|
<span class="game-info-text">
|
||||||
|
🧩 {{game.tilesFinished}}/{{game.tilesTotal}}<br />
|
||||||
|
👥 {{game.players}}<br />
|
||||||
|
{{time(game.started, game.finished)}}<br />
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
<a v-if="game.hasReplay" class="game-replay" :href="'/replay/' + game.id">
|
||||||
|
↪️ Watch replay
|
||||||
|
</a>
|
||||||
|
</div>`,
|
||||||
|
methods: {
|
||||||
|
time(start, end) {
|
||||||
|
const icon = end ? '🏁' : '⏳'
|
||||||
|
const from = start;
|
||||||
|
const to = end || Time.timestamp()
|
||||||
|
const timeDiffStr = Time.timeDiffStr(from, to)
|
||||||
|
return `${icon} ${timeDiffStr}`
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
Upload,
|
Upload,
|
||||||
|
GameTeaser,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
games: Array,
|
gamesRunning: Array,
|
||||||
|
gamesFinished: Array,
|
||||||
images: Array,
|
images: Array,
|
||||||
},
|
},
|
||||||
template: `
|
template: `
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<h1>Running games</h1>
|
<h1>Running games</h1>
|
||||||
<div class="game-teaser-wrap" v-for="g in games">
|
<div class="game-teaser-wrap" v-for="g in gamesRunning">
|
||||||
<div class="game-teaser" :style="'background-image: url('+g.imageUrl+')'">
|
<game-teaser :game="g" />
|
||||||
<a class="game-info" :href="'/g/' + g.id">
|
|
||||||
<span class="game-info-text">
|
|
||||||
🧩 {{g.tilesFinished}}/{{g.tilesTotal}}<br />
|
|
||||||
👥 {{g.players}}<br />
|
|
||||||
{{time(g.started, g.finished)}}<br />
|
|
||||||
</span>
|
|
||||||
</a>
|
|
||||||
<a v-if="g.hasReplay" class="game-replay" :href="'/replay/' + g.id">
|
|
||||||
↪️ Watch replay
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h1>New game</h1>
|
<h1>New game</h1>
|
||||||
|
|
@ -75,12 +95,16 @@ export default {
|
||||||
|
|
||||||
<h1>Image lib</h1>
|
<h1>Image lib</h1>
|
||||||
<div>
|
<div>
|
||||||
<img
|
<div
|
||||||
v-for="i in images"
|
v-for="i in images"
|
||||||
:src="i.url"
|
|
||||||
@click="image = i"
|
@click="image = i"
|
||||||
style="width: 150px; display: inline-block; margin: 5px;"
|
class="imageteaser"
|
||||||
/>
|
:style="{'background-image': 'url(' + i.url + ')'}"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h1>Finished games</h1>
|
||||||
|
<div class="game-teaser-wrap" v-for="g in gamesFinished">
|
||||||
|
<game-teaser :game="g" />
|
||||||
</div>
|
</div>
|
||||||
</div>`,
|
</div>`,
|
||||||
data() {
|
data() {
|
||||||
|
|
|
||||||
|
|
@ -202,3 +202,15 @@ input:focus {
|
||||||
top: 0;
|
top: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.imageteaser {
|
||||||
|
width: 150px;
|
||||||
|
height: 100px;
|
||||||
|
display: inline-block;
|
||||||
|
margin: 5px;
|
||||||
|
background-size: contain;
|
||||||
|
background-position: center;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-color: #222;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,8 @@
|
||||||
el: '#app',
|
el: '#app',
|
||||||
render: (h) => h(Page, {
|
render: (h) => h(Page, {
|
||||||
props: {
|
props: {
|
||||||
games: {{ games|json_encode|raw }},
|
gamesRunning: {{ gamesRunning|json_encode|raw }},
|
||||||
|
gamesFinished: {{ gamesFinished|json_encode|raw }},
|
||||||
images: {{ images|json_encode|raw }},
|
images: {{ images|json_encode|raw }},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,8 @@ app.use('/', async (req, res, next) => {
|
||||||
]
|
]
|
||||||
|
|
||||||
res.send(await render('index.html.twig', {
|
res.send(await render('index.html.twig', {
|
||||||
games,
|
gamesRunning: games.filter(g => !g.finished),
|
||||||
|
gamesFinished: games.filter(g => !!g.finished),
|
||||||
images: allImages(),
|
images: allImages(),
|
||||||
}))
|
}))
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue