From a7561a82b8219ebbce2d4e082c882d0fe9830fd7 Mon Sep 17 00:00:00 2001 From: Valentin Kaelin Date: Sun, 6 Oct 2019 15:08:24 +0200 Subject: [PATCH] feat: add loading animation on load more matches button --- client/src/components/LoadingButton.vue | 117 ++++++++++++++++++++++++ client/src/store/modules/summoner.js | 9 ++ client/src/views/Summoner.vue | 14 ++- client/tailwind.config.js | 1 + 4 files changed, 136 insertions(+), 5 deletions(-) create mode 100644 client/src/components/LoadingButton.vue diff --git a/client/src/components/LoadingButton.vue b/client/src/components/LoadingButton.vue new file mode 100644 index 0000000..85edee3 --- /dev/null +++ b/client/src/components/LoadingButton.vue @@ -0,0 +1,117 @@ + + + + + diff --git a/client/src/store/modules/summoner.js b/client/src/store/modules/summoner.js index 4acb42a..f440873 100644 --- a/client/src/store/modules/summoner.js +++ b/client/src/store/modules/summoner.js @@ -11,11 +11,17 @@ export const state = { matches: [], soloQ: {} }, + matchesLoading: false, status: '', } export const mutations = { + MATCHES_LOADING(state) { + state.matchesLoading = true + }, MATCHES_FOUND(state, newMatches) { + state.matchesLoading = false + state.infos.matches = [...state.infos.matches, ...newMatches] state.infos.matchIndex += newMatches.length @@ -38,6 +44,8 @@ export const mutations = { export const actions = { async moreMatches({ commit }) { + commit('MATCHES_LOADING') + const account = state.infos.account const gameIds = state.infos.matchList.slice(state.infos.matchIndex, state.infos.matchIndex + 10).map(({ gameId }) => gameId) @@ -69,6 +77,7 @@ export const actions = { } export const getters = { + matchesLoading: state => state.matchesLoading, moreMatchesToFetch: state => state.infos.matchIndex < state.infos.matchList.length, summonerFound: state => state.status === 'found', summonerNotFound: state => state.status === 'error', diff --git a/client/src/views/Summoner.vue b/client/src/views/Summoner.vue index f07a90b..fc27167 100644 --- a/client/src/views/Summoner.vue +++ b/client/src/views/Summoner.vue @@ -87,11 +87,13 @@ - + @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 + @@ -113,6 +115,7 @@