mirror of
https://github.com/romancm/gamebrary
synced 2024-11-24 04:03:06 +00:00
game backrop placeholder and scroll to top on route change
This commit is contained in:
parent
a86eaeb813
commit
2e9ebd2020
1 changed files with 32 additions and 1 deletions
|
@ -1,13 +1,16 @@
|
||||||
<template lang="html">
|
<template lang="html">
|
||||||
<div class="mt-3">
|
<div class="pt-3 game-page" ref="gamePage">
|
||||||
<!-- TODO: add -->
|
<!-- TODO: add -->
|
||||||
<!-- <b-button>Back to board</b-button> -->
|
<!-- <b-button>Back to board</b-button> -->
|
||||||
<game :game="game" :loading="loading" />
|
<game :game="game" :loading="loading" />
|
||||||
|
|
||||||
|
<div class="game-backdrop" :style="`background-image: url(${backdropUrl})`" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Game from '@/components/Game';
|
import Game from '@/components/Game';
|
||||||
|
import { mapState } from 'vuex';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
@ -22,13 +25,25 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
|
...mapState(['board']),
|
||||||
|
|
||||||
gameId() {
|
gameId() {
|
||||||
return this.$route.params.gameId;
|
return this.$route.params.gameId;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
backdropUrl() {
|
||||||
|
const screenshots = this.game && this.game.screenshots;
|
||||||
|
|
||||||
|
return screenshots && screenshots.length
|
||||||
|
? `https://images.igdb.com/igdb/image/upload/t_screenshot_huge_2x/${screenshots[0].image_id}.jpg`
|
||||||
|
: '';
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
gameId(gameId) {
|
gameId(gameId) {
|
||||||
|
document.getElementsByTagName('main')[0].scrollTop = 0;
|
||||||
|
|
||||||
if (gameId) this.loadGame();
|
if (gameId) this.loadGame();
|
||||||
// TODO: handle missing id, redirect? 404? search?
|
// TODO: handle missing id, redirect? 404? search?
|
||||||
},
|
},
|
||||||
|
@ -57,4 +72,20 @@ export default {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" rel="stylesheet/scss" scoped>
|
<style lang="scss" rel="stylesheet/scss" scoped>
|
||||||
|
.game-page {
|
||||||
|
z-index: 1;
|
||||||
|
// position: fixed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.game-backdrop {
|
||||||
|
width: 100%;
|
||||||
|
height: 100vw;
|
||||||
|
// position: fixed;
|
||||||
|
// top: 0;
|
||||||
|
backdrop-filter: grayscale(0.5) opacity(0.8) /* ...and on and on... */;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: contain;
|
||||||
|
// opacity: 0.1;
|
||||||
|
z-index: 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in a new issue