Skip to content

Commit bd0d7f0

Browse files
committed
Add refresh icon spinning
1 parent c4ee0a8 commit bd0d7f0

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

resources/js/components/TopMenu.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
</div>
3535
<div>
3636
<button class="p-2 rounded bg-indigo-500 text-indigo-100 hover:bg-indigo-700 hover:text-white" v-on:click="refetchData()" title="Refetch data">
37-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" class="fill-current w-4 h-4">
37+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" class="fill-current w-4 h-4" v-bind:class="{'spin' : isRefreshing}">
3838
<path d="M10 3v2a5 5 0 0 0-3.54 8.54l-1.41 1.41A7 7 0 0 1 10 3zm4.95 2.05A7 7 0 0 1 10 17v-2a5 5 0 0 0 3.54-8.54l1.41-1.41zM10 20l-4-4 4-4v8zm0-12V0l4 4-4 4z"></path>
3939
</svg>
4040
</button>
@@ -46,11 +46,22 @@
4646

4747
<script>
4848
export default {
49+
data() {
50+
return {
51+
isRefreshing: false,
52+
}
53+
},
54+
4955
methods: {
5056
async refetchData() {
57+
this.isRefreshing = true;
5158
await this.$store.dispatch('collectRequirements');
5259
await this.$store.dispatch('collectRepositories');
5360
await this.$store.dispatch('collectJobs');
61+
// Timeout needed to not interrupt animation too quick
62+
setTimeout(() => {
63+
this.isRefreshing = false;
64+
}, 1000);
5465
},
5566
5667
getJobsBadgeClass() {

resources/sass/base.scss

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,30 @@ body,
22
.font-mono {
33
font-family: 'IBM Plex Mono', monospace;
44
}
5+
6+
@-webkit-keyframes spin {
7+
0% {
8+
-webkit-transform: rotate(0deg);
9+
transform: rotate(0deg)
10+
}
11+
to {
12+
-webkit-transform: rotate(1turn);
13+
transform: rotate(1turn)
14+
}
15+
}
16+
17+
@keyframes spin {
18+
0% {
19+
-webkit-transform: rotate(0deg);
20+
transform: rotate(0deg)
21+
}
22+
to {
23+
-webkit-transform: rotate(1turn);
24+
transform: rotate(1turn)
25+
}
26+
}
27+
28+
.spin {
29+
-webkit-animation: spin 2s linear infinite;
30+
animation: spin 2s linear infinite;
31+
}

0 commit comments

Comments
 (0)