Skip to content

Commit

Permalink
loader added
Browse files Browse the repository at this point in the history
  • Loading branch information
terrerox committed Dec 24, 2022
1 parent 04802d6 commit 7db4a80
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 3 deletions.
File renamed without changes
1 change: 0 additions & 1 deletion public/vite.svg

This file was deleted.

Binary file added src/assets/loader.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/store/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const usePostStore = defineStore('posts', {
}),
actions: {
getAll() {
this.isLoading = true
return fetch(`https://graph.facebook.com/v14.0/17841413817530260?fields=media%7Btimestamp%2C%20caption%2C%20id%2C%20%20thumbnail_url%7D&access_token=${import.meta.env.VITE_INSTAGRAM_ACCESS_TOKEN}`)
.then(res => {
return res.json();
Expand All @@ -35,6 +36,7 @@ export const usePostStore = defineStore('posts', {
})
},
getOne(id) {
this.isLoading = true
return fetch(`https://graph.facebook.com/v14.0/${id}?fields=caption%2Cthumbnail_url%2Ctimestamp&access_token=${import.meta.env.VITE_INSTAGRAM_ACCESS_TOKEN}`)
.then(res => {
return res.json();
Expand Down
6 changes: 6 additions & 0 deletions src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,12 @@ a:focus {
margin-bottom: var(--spacing-8);
}

.loader {
display: flex;
justify-content: center;
align-items: center;
}

/* Media queries */

@media (max-width: 42rem) {
Expand Down
5 changes: 4 additions & 1 deletion src/views/BlogPost.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ watchEffect(
</script>
<template>
<Layout :title="siteTitle" :location="location">
<div v-if="postStore.isLoading" class="loader">
<img src="../assets/loader.gif"/>
</div>
<article
class="blog-post"
itemScope
itemType="http://schema.org/Article"
v-if="!postStore.isLoading"
v-else
>
<header>
<h1 itemProp="headline">{{postStore.post.title}}</h1>
Expand Down
5 changes: 4 additions & 1 deletion src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ onMounted(() => {
<template>
<Layout :title="siteTitle" :location="location">
<Station />
<ol style="listStyle: none">
<div v-if="postStore.isLoading" class="loader" style="margin-top: 5%;">
<img src="../assets/loader.gif"/>
</div>
<ol style="listStyle: none" v-else>
<Post
v-for="post in postStore.posts"
:key="post.slug"
Expand Down

1 comment on commit 7db4a80

@vercel
Copy link

@vercel vercel bot commented on 7db4a80 Dec 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.