From 1f05a8182863c2bc39bc4e2e86b6c8496262f541 Mon Sep 17 00:00:00 2001
From: Pravasta Caraka <43958791+pravastacaraka@users.noreply.github.com>
Date: Mon, 15 Jul 2024 14:11:38 +0700
Subject: [PATCH] feat(projects): add skeleton loading (#221)
---
app/(core)/projects/layout.js | 4 +--
app/(core)/projects/loading.js | 31 ++++++++----------
app/(core)/projects/page.js | 60 +++++++++++++++++++---------------
components/Card.js | 2 +-
4 files changed, 49 insertions(+), 48 deletions(-)
diff --git a/app/(core)/projects/layout.js b/app/(core)/projects/layout.js
index af12fdc..e9bc5c7 100644
--- a/app/(core)/projects/layout.js
+++ b/app/(core)/projects/layout.js
@@ -1,6 +1,4 @@
import { Heading, Stack, Text } from "@app-providers/chakra-ui";
-import { Suspense } from "react";
-import Loading from "./loading";
/** @type {import("next").Metadata} */
export const metadata = {
@@ -15,7 +13,7 @@ function ProjectsLayout({ children }) {
Recent Projects
Here are some of my past works from personal projects and open source ones.
- }>{children}
+ {children}
);
}
diff --git a/app/(core)/projects/loading.js b/app/(core)/projects/loading.js
index 3234060..c8a0c89 100644
--- a/app/(core)/projects/loading.js
+++ b/app/(core)/projects/loading.js
@@ -1,20 +1,17 @@
-import { CustomReactMarkdown } from "@app-components/markdown";
-import { Spinner, Stack } from "@app-providers/chakra-ui";
+import { AspectRatio, SimpleGrid, Skeleton, Stack } from "@chakra-ui/react";
-const Loading = () => (
-
-
- Loading...
-
-);
+const Loading = () => {
+ return (
+
+
+ {Array.from({ length: 6 }).map((_, index) => (
+
+
+
+ ))}
+
+
+ );
+};
export default Loading;
diff --git a/app/(core)/projects/page.js b/app/(core)/projects/page.js
index deac73e..df7de1e 100644
--- a/app/(core)/projects/page.js
+++ b/app/(core)/projects/page.js
@@ -2,10 +2,12 @@ import { ProjectCard } from "@app-components/Card";
import { CustomReactMarkdown } from "@app-components/markdown";
import { Center, SimpleGrid, Stack } from "@app-providers/chakra-ui";
import { getPlaiceholder } from "plaiceholder";
+import { Suspense } from "react";
+import Loading from "./loading";
const BASE_URL = `https://api.airtable.com/v0/${process.env.AIRTABLE_BASE_ID}`;
-async function fetchProjectsData() {
+async function getData() {
const headers = {
Authorization: `Bearer ${process.env.AIRTABLE_API_KEY}`,
"Content-Type": "application/json",
@@ -57,38 +59,42 @@ async function fetchProjectsData() {
return records;
}
-function ProjectList({ projects }) {
- return (
-
-
- {projects.map((project) => (
-
- ))}
-
-
- );
-}
+const NotFound = () => (
+
+ Don't have any projects.
+
+);
+
+const ProjectList = ({ projects }) => (
+
+
+ {projects.map((project) => (
+
+ ))}
+
+
+);
async function Page() {
- const projects = await fetchProjectsData();
+ const projects = await getData();
if (!projects || projects.length === 0) {
- return (
-
- Don't have any projects.
-
- );
+ return ;
}
- return ;
+ return (
+ }>
+
+
+ );
}
export default Page;
diff --git a/components/Card.js b/components/Card.js
index 38901ff..bf905f8 100644
--- a/components/Card.js
+++ b/components/Card.js
@@ -54,7 +54,7 @@ function ProjectCard({ project }) {
transitionProperty="opacity"
transitionTimingFunction="cubic-bezier(.39,.575,.565,1)"
>
-
+
{project.name}