Skip to content
This repository was archived by the owner on May 7, 2021. It is now read-only.

Commit 513fb82

Browse files
committed
Merge branch 'master' into kp/header
2 parents fc9dd41 + 242ee08 commit 513fb82

File tree

5 files changed

+78
-1
lines changed

5 files changed

+78
-1
lines changed

src/App.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<router-link :to="{ name: 'home' }">
66
<img class="logo" src="@/assets/logo.svg" alt="ProLab">
77
</router-link>
8+
<loading-indicator/>
89
</header>
910
<router-view v-show="!isError"/>
1011
</div>
@@ -13,10 +14,12 @@
1314
<script>
1415
import { mapGetters } from 'vuex';
1516
import ErrorPage from './components/ErrorPage.vue';
17+
import LoadingIndicator from './components/LoadingIndicator.vue';
1618
1719
export default {
1820
components: {
1921
ErrorPage,
22+
LoadingIndicator,
2023
},
2124
computed: {
2225
...mapGetters('criticalError', ['isError']),
@@ -55,5 +58,4 @@ header img {
5558
margin-left: 30px;
5659
}
5760
}
58-
5961
</style>

src/components/LoadingIndicator.vue

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<template>
2+
<div class="loading-indicator-container">
3+
<div :class="[ isLoading ? 'loading-indicator-active' : 'loading-indicator-inactive' ]"></div>
4+
</div>
5+
</template>
6+
7+
<script>
8+
import { mapState } from 'vuex';
9+
10+
export default {
11+
computed: {
12+
...mapState('ui', ['isLoading']),
13+
},
14+
};
15+
</script>
16+
17+
<style scoped>
18+
.loading-indicator-container {
19+
height: 5px;
20+
width: 100%;
21+
}
22+
23+
.loading-indicator-inactive {
24+
height: 100%;
25+
width: 0;
26+
margin-left: 0;
27+
}
28+
29+
.loading-indicator-active {
30+
height: 100%;
31+
background-color: cornflowerblue;
32+
animation: loading 1.5s linear infinite;
33+
}
34+
35+
@keyframes loading {
36+
0% {
37+
width: 0;
38+
margin-left: 0;
39+
}
40+
41+
50% {
42+
margin-left: 0;
43+
width: 50%;
44+
}
45+
46+
100% {
47+
margin-left: 100%;
48+
width: 0%;
49+
}
50+
}
51+
</style>

src/router.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ const router = new Router({
9696
});
9797

9898
router.beforeEach(async (to, from, next) => {
99+
store.commit('ui/setLoading');
99100
store.commit('criticalError/clearError');
100101
if (to.matched.length === 0) {
101102
store.dispatch('criticalError/createError', {
@@ -134,4 +135,9 @@ router.beforeEach(async (to, from, next) => {
134135
next();
135136
});
136137

138+
// eslint-disable-next-line no-unused-vars
139+
router.afterEach(async (to, from) => {
140+
store.commit('ui/clearLoading');
141+
});
142+
137143
export default router;

src/store/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import emailConfirmations from './modules/emailConfirmations';
1111
import memberIntroduction from './modules/memberIntroduction';
1212
import editUser from './modules/editUser';
1313
import invitation from './modules/invitation';
14+
import ui from './modules/ui';
1415

1516
Vue.use(Vuex);
1617

@@ -27,6 +28,7 @@ export default new Vuex.Store({
2728
memberIntroduction,
2829
editUser,
2930
invitation,
31+
ui,
3032
},
3133
plugins: [
3234
createPersistedState({

src/store/modules/ui/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export default {
2+
namespaced: true,
3+
state: {
4+
isLoading: false,
5+
},
6+
/* eslint-disable no-param-reassign */
7+
mutations: {
8+
setLoading(state) {
9+
state.isLoading = true;
10+
},
11+
clearLoading(state) {
12+
state.isLoading = false;
13+
},
14+
},
15+
/* eslint-enable no-param-reassign */
16+
};

0 commit comments

Comments
 (0)