2019-03-30 22:55:48 +00:00
|
|
|
<template>
|
2020-03-19 22:07:12 +00:00
|
|
|
<div v-if="overviewLoaded" key="overview" class="mt-3 relative flex items-start text-center">
|
|
|
|
|
<div ref="sidebar" :class="{'fixed fixed-sidebar': fixedSidebar}" class="sidebar">
|
2019-12-03 20:57:52 +00:00
|
|
|
<SummonerChampions />
|
|
|
|
|
<SummonerStats />
|
|
|
|
|
<SummonerMates />
|
|
|
|
|
</div>
|
2020-03-19 22:07:12 +00:00
|
|
|
<div :class="{'pushed-container': fixedSidebar}" class="w-9/12">
|
2020-02-13 19:16:13 +00:00
|
|
|
<div v-if="current && current.participants" class="mb-4">
|
2020-01-03 21:50:09 +00:00
|
|
|
<LiveMatch />
|
|
|
|
|
</div>
|
|
|
|
|
<div v-if="overview.matches.length">
|
|
|
|
|
<ul>
|
|
|
|
|
<Match
|
|
|
|
|
v-for="(match, index) in overview.matches"
|
|
|
|
|
:key="index"
|
|
|
|
|
:data="overview.matches[index]"
|
2020-02-01 16:14:03 +00:00
|
|
|
:index-match="index"
|
2020-01-03 21:50:09 +00:00
|
|
|
/>
|
|
|
|
|
</ul>
|
|
|
|
|
<LoadingButton
|
|
|
|
|
v-if="moreMatchesToFetch"
|
|
|
|
|
@clicked="moreMatches"
|
|
|
|
|
:loading="matchesLoading"
|
|
|
|
|
btn-class="mt-4 block mx-auto bg-blue-800 px-4 py-2 rounded-md font-semibold hover:bg-blue-1000 shadow-lg"
|
|
|
|
|
>More matches</LoadingButton>
|
|
|
|
|
</div>
|
2019-09-14 21:19:10 +00:00
|
|
|
</div>
|
2019-03-30 22:55:48 +00:00
|
|
|
</div>
|
2020-01-01 16:04:55 +00:00
|
|
|
<div v-else>
|
|
|
|
|
<OverviewLoader />
|
2019-12-27 21:09:24 +00:00
|
|
|
</div>
|
2019-03-30 22:55:48 +00:00
|
|
|
</template>
|
|
|
|
|
|
2019-12-03 20:57:52 +00:00
|
|
|
|
2019-03-30 22:55:48 +00:00
|
|
|
<script>
|
2019-09-11 20:02:05 +00:00
|
|
|
import { mapState, mapActions, mapGetters } from 'vuex'
|
2020-01-03 21:50:09 +00:00
|
|
|
import LiveMatch from '@/components/Match/LiveMatch.vue'
|
2020-02-13 19:16:13 +00:00
|
|
|
import LoadingButton from '@/components/Form/LoadingButton.vue'
|
2019-11-03 17:49:58 +00:00
|
|
|
import Match from '@/components/Match/Match.vue'
|
2020-01-01 16:04:55 +00:00
|
|
|
import OverviewLoader from '@/components/Summoner/Overview/OverviewLoader.vue'
|
2019-12-03 20:57:52 +00:00
|
|
|
import SummonerChampions from '@/components/Summoner/Overview/SummonerChampions.vue'
|
|
|
|
|
import SummonerMates from '@/components/Summoner/Overview/SummonerMates.vue'
|
|
|
|
|
import SummonerStats from '@/components/Summoner/Overview/SummonerStats.vue'
|
2019-03-30 22:55:48 +00:00
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
components: {
|
2020-01-03 21:50:09 +00:00
|
|
|
LiveMatch,
|
2019-10-06 13:08:24 +00:00
|
|
|
LoadingButton,
|
2019-04-08 20:06:22 +00:00
|
|
|
Match,
|
2020-01-01 16:04:55 +00:00
|
|
|
OverviewLoader,
|
2019-11-24 13:26:27 +00:00
|
|
|
SummonerChampions,
|
2019-10-25 21:09:33 +00:00
|
|
|
SummonerMates,
|
2019-11-08 14:39:56 +00:00
|
|
|
SummonerStats,
|
2019-03-30 22:55:48 +00:00
|
|
|
},
|
2019-08-23 14:48:16 +00:00
|
|
|
|
2020-03-19 22:07:12 +00:00
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
fixedSidebar: false,
|
|
|
|
|
sidebarRectangle: {
|
2020-04-01 10:55:55 +00:00
|
|
|
y: 323,
|
2020-03-19 22:07:12 +00:00
|
|
|
height: null,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2019-04-07 17:44:01 +00:00
|
|
|
computed: {
|
2019-09-08 20:08:49 +00:00
|
|
|
...mapState({
|
2020-01-19 15:18:35 +00:00
|
|
|
current: state => state.summoner.live.match,
|
2019-12-27 17:38:43 +00:00
|
|
|
overview: state => state.summoner.overview
|
2019-09-11 20:02:05 +00:00
|
|
|
}),
|
2019-12-27 21:09:24 +00:00
|
|
|
...mapGetters('summoner', ['matchesLoading', 'moreMatchesToFetch', 'overviewLoaded', 'summonerFound'])
|
2019-12-27 17:38:43 +00:00
|
|
|
},
|
|
|
|
|
|
2019-12-28 19:35:05 +00:00
|
|
|
watch: {
|
2020-02-01 19:17:14 +00:00
|
|
|
overviewLoaded() {
|
2020-03-30 20:09:23 +00:00
|
|
|
this.fetchData()
|
|
|
|
|
|
2020-03-19 22:07:12 +00:00
|
|
|
this.getSidebarHeight()
|
2020-02-01 19:17:14 +00:00
|
|
|
},
|
2019-12-28 19:35:05 +00:00
|
|
|
summonerFound() {
|
|
|
|
|
this.fetchData()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2019-12-27 17:38:43 +00:00
|
|
|
created() {
|
2019-12-28 19:35:05 +00:00
|
|
|
this.fetchData()
|
2020-03-30 20:09:23 +00:00
|
|
|
window.addEventListener('scroll', this.isSidebarFixed)
|
2020-03-19 22:07:12 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
|
this.getSidebarHeight()
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
destroyed() {
|
2020-03-30 20:09:23 +00:00
|
|
|
window.removeEventListener('scroll', this.isSidebarFixed)
|
2019-08-23 14:48:16 +00:00
|
|
|
},
|
|
|
|
|
|
2019-03-30 22:55:48 +00:00
|
|
|
methods: {
|
2019-12-28 19:35:05 +00:00
|
|
|
fetchData() {
|
2019-12-28 22:49:53 +00:00
|
|
|
if (!this.overviewLoaded && this.summonerFound) {
|
2019-12-28 19:35:05 +00:00
|
|
|
this.overviewRequest()
|
|
|
|
|
}
|
|
|
|
|
},
|
2020-03-19 22:07:12 +00:00
|
|
|
getSidebarHeight() {
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
this.sidebarRectangle.height = this.$refs.sidebar ? this.$refs.sidebar.getBoundingClientRect().height : null
|
2020-03-30 20:09:23 +00:00
|
|
|
this.isSidebarFixed()
|
2020-03-19 22:07:12 +00:00
|
|
|
})
|
|
|
|
|
},
|
2020-03-30 20:09:23 +00:00
|
|
|
isSidebarFixed() {
|
2020-03-19 22:07:12 +00:00
|
|
|
if (!this.sidebarRectangle.height) return
|
2020-03-31 12:03:43 +00:00
|
|
|
this.fixedSidebar = window.innerHeight + document.documentElement.scrollTop > this.sidebarRectangle.y + this.sidebarRectangle.height + 121
|
2020-03-19 22:07:12 +00:00
|
|
|
},
|
2019-12-27 17:38:43 +00:00
|
|
|
...mapActions('summoner', ['moreMatches', 'overviewRequest']),
|
2019-12-28 19:35:05 +00:00
|
|
|
},
|
2019-08-23 14:48:16 +00:00
|
|
|
}
|
2019-03-30 22:55:48 +00:00
|
|
|
</script>
|
2020-03-19 22:07:12 +00:00
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.sidebar {
|
|
|
|
|
width: 300px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.fixed-sidebar {
|
2020-03-31 12:03:43 +00:00
|
|
|
bottom: 121px;
|
2020-03-19 22:07:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.pushed-container {
|
|
|
|
|
margin-left: 300px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|