Skip to content

Commit 7c907da

Browse files
committed
Loading animation whilest fetching
1 parent 95c5f86 commit 7c907da

5 files changed

Lines changed: 29 additions & 2 deletions

File tree

app/lib/footer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export function Footer() {
88
{
99
name: "Twitter",
1010
href: "#",
11-
icon: (props) => (
11+
icon: (props: any) => (
1212
<svg fill="currentColor" viewBox="0 0 24 24" {...props}>
1313
<path d="M8.29 20.251c7.547 0 11.675-6.253 11.675-11.675 0-.178 0-.355-.012-.53A8.348 8.348 0 0022 5.92a8.19 8.19 0 01-2.357.646 4.118 4.118 0 001.804-2.27 8.224 8.224 0 01-2.605.996 4.107 4.107 0 00-6.993 3.743 11.65 11.65 0 01-8.457-4.287 4.106 4.106 0 001.27 5.477A4.072 4.072 0 012.8 9.713v.052a4.105 4.105 0 003.292 4.022 4.095 4.095 0 01-1.853.07 4.108 4.108 0 003.834 2.85A8.233 8.233 0 012 18.407a11.616 11.616 0 006.29 1.84" />
1414
</svg>
@@ -17,7 +17,7 @@ export function Footer() {
1717
{
1818
name: "GitHub",
1919
href: "#",
20-
icon: (props) => (
20+
icon: (props: any) => (
2121
<svg fill="currentColor" viewBox="0 0 24 24" {...props}>
2222
<path
2323
fillRule="evenodd"

app/lib/loading.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from "react";
2+
3+
export function Loading() {
4+
return (
5+
<div className="grid place-items-center h-80">
6+
<svg
7+
className="animate-bounce w-12 h-12 text-green-400"
8+
viewBox="0 0 20 20"
9+
xmlns="http://www.w3.org/2000/svg"
10+
>
11+
<path
12+
fill="currentColor"
13+
fillRule="evenodd"
14+
d="M11.3 1.046A1 1 0 0112 2v5h4a1 1 0 01.82 1.573l-7 10A1 1 0 018 18v-5H4a1 1 0 01-.82-1.573l7-10a1 1 0 011.12-.38z"
15+
clipRule="evenodd"
16+
></path>
17+
</svg>{" "}
18+
</div>
19+
);
20+
}

app/pages/comments.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { useQuery } from "urql";
66
import { gql } from "../gql";
77
import { CommentItem } from "../lib/comment-item";
88
import { Container } from "../lib/container";
9+
import { Loading } from "../lib/loading";
910
import { MainSection } from "../lib/main-section";
1011

1112
const CommentsRouteQuery = gql(/* GraphQL */ `
@@ -43,6 +44,8 @@ const Comments: NextPage = () => {
4344
<section className="text-gray-600 body-font overflow-hidden">
4445
<div className="container px-5 py-24 mx-auto">
4546
<div className="-my-8 divide-y-2 divide-gray-100">
47+
{commentsQuery.fetching && <Loading />}
48+
4649
{commentsQuery?.data?.comments?.edges.map((edge) => (
4750
<CommentItem comment={edge.node!} key={edge.cursor} />
4851
))}

app/pages/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useQuery } from "urql";
55
import { gql } from "../gql";
66
import { Container } from "../lib/container";
77
import { FeedItem } from "../lib/feed-item";
8+
import { Loading } from "../lib/loading";
89
import { MainSection } from "../lib/main-section";
910
import { noopUUID } from "../lib/noop-uuid";
1011

@@ -53,6 +54,7 @@ const Home: NextPage = () => {
5354
<section className="text-gray-600 body-font overflow-hidden w-full">
5455
<div className="container px-3 py-24 mx-auto">
5556
<div className="-my-8">
57+
{indexQuery.fetching && <Loading />}
5658
{indexQuery?.data?.feed?.edges.map((edge) => (
5759
<FeedItem post={edge.node!} key={edge.cursor} />
5860
))}

app/pages/newest.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useQuery } from "urql";
55
import { gql } from "../gql";
66
import { Container } from "../lib/container";
77
import { FeedItem } from "../lib/feed-item";
8+
import { Loading } from "../lib/loading";
89
import { MainSection } from "../lib/main-section";
910
import { noopUUID } from "../lib/noop-uuid";
1011

@@ -46,6 +47,7 @@ const Newest: NextPage = () => {
4647
<section className="text-gray-600 body-font overflow-hidden w-full">
4748
<div className="container px-5 py-24 mx-auto">
4849
<div className="-my-8">
50+
{newestQuery.fetching && <Loading />}
4951
{newestQuery?.data?.feed?.edges.map((edge) => (
5052
<FeedItem post={edge.node!} key={edge.cursor} />
5153
))}

0 commit comments

Comments
 (0)