LeagueStats/client/src/views/Summoner.vue

133 lines
3.6 KiB
Vue
Raw Normal View History

2019-03-30 22:55:48 +00:00
<template>
2020-12-17 21:48:02 +00:00
<div>
<div
v-if="overviewLoaded"
key="overview"
class="relative flex items-start justify-between mt-3 text-center vue-sticky-container"
>
2020-12-17 21:48:02 +00:00
<VueStickySidebar
:top-spacing="48"
:bottom-spacing="123"
class="z-40 sidebar"
container-selector=".vue-sticky-container"
>
<SummonerChampions />
<SummonerStats />
<SummonerMates />
</VueStickySidebar>
<div class="w-9/12">
<div v-if="current && current.participants" class="mb-4">
<LiveMatch />
</div>
<div v-if="overview.matches.length">
<ul>
<Match
v-for="(match, index) in overview.matches"
:key="index"
:data="overview.matches[index]"
:index-match="index"
/>
</ul>
<LoadingButton
v-if="moreMatchesToFetch"
@clicked="moreMatches"
:loading="matchesLoading"
btn-class="block px-4 py-2 mx-auto mt-4 font-semibold bg-blue-800 rounded-md shadow-lg hover:bg-blue-1000"
>More matches</LoadingButton>
</div>
<div v-else>
<div class="flex justify-center">
<div class="px-4 py-3 text-lg font-bold text-center text-blue-100 rounded-lg bg-gradient">
<div>No matches found.</div>
<div>😕</div>
</div>
</div>
</div>
</div>
</div>
2020-12-17 21:48:02 +00:00
<div v-else>
<OverviewLoader />
</div>
<RunesContainer :open="runesOpen" :runes="selectedRunes" />
2019-12-27 21:09:24 +00:00
</div>
2019-03-30 22:55:48 +00:00
</template>
2019-03-30 22:55:48 +00:00
<script>
2019-09-11 20:02:05 +00:00
import { mapState, mapActions, mapGetters } from 'vuex'
import LiveMatch from '@/components/Match/LiveMatch.vue'
import LoadingButton from '@/components/Form/LoadingButton.vue'
import Match from '@/components/Match/Match.vue'
2020-01-01 16:04:55 +00:00
import OverviewLoader from '@/components/Summoner/Overview/OverviewLoader.vue'
2020-12-17 21:48:02 +00:00
import RunesContainer from '@/components/Match/Runes/RunesContainer.vue'
import SummonerChampions from '@/components/Summoner/Overview/SummonerChampions.vue'
import SummonerMates from '@/components/Summoner/Overview/SummonerMates.vue'
import SummonerStats from '@/components/Summoner/Overview/SummonerStats.vue'
import VueStickySidebar from 'vue-sticky-sidebar'
2019-03-30 22:55:48 +00:00
export default {
components: {
LiveMatch,
LoadingButton,
2019-04-08 20:06:22 +00:00
Match,
2020-01-01 16:04:55 +00:00
OverviewLoader,
2020-12-17 21:48:02 +00:00
RunesContainer,
SummonerChampions,
SummonerMates,
SummonerStats,
VueStickySidebar
},
2019-04-07 17:44:01 +00:00
computed: {
2019-09-08 20:08:49 +00:00
...mapState({
current: state => state.summoner.live.match,
2020-12-17 21:48:02 +00:00
overview: state => state.summoner.overview,
runesOpen: state => state.cdragon.runesOpen,
selectedRunes: state => state.cdragon.selectedRunes
2019-09-11 20:02:05 +00:00
}),
2019-12-27 21:09:24 +00:00
...mapGetters('summoner', ['matchesLoading', 'moreMatchesToFetch', 'overviewLoaded', 'summonerFound'])
},
watch: {
2020-02-01 19:17:14 +00:00
overviewLoaded() {
this.fetchData()
2020-02-01 19:17:14 +00:00
},
summonerFound() {
this.fetchData()
}
},
created() {
this.fetchData()
2020-12-17 21:48:02 +00:00
this.getRunes()
2019-08-23 14:48:16 +00:00
},
2019-03-30 22:55:48 +00:00
methods: {
fetchData() {
if (!this.overviewLoaded && this.summonerFound) {
this.overviewRequest()
}
// Keep only the 10 last matches when summoner enters overview page
else if (this.overviewLoaded && this.summonerFound && this.overview.matches.length !== 10) {
this.sliceOverviewMatches(10)
}
},
2020-12-17 21:48:02 +00:00
...mapActions('cdragon', ['getRunes']),
...mapActions('summoner', ['moreMatches', 'overviewRequest', 'sliceOverviewMatches']),
},
metaInfo() {
return {
title: 'Summoner Overview',
}
}
2019-08-23 14:48:16 +00:00
}
2019-03-30 22:55:48 +00:00
</script>
<style scoped>
.sidebar {
width: 300px;
}
</style>