From 580e002900f9d62e4865881dcf8bcef7f0782bce Mon Sep 17 00:00:00 2001 From: Henry Date: Wed, 29 Oct 2025 21:24:55 +0000 Subject: [PATCH] feat: add skeleton loader --- apps/web/src/views/oss-friends/index.tsx | 81 +++++++++++++++--------- 1 file changed, 51 insertions(+), 30 deletions(-) diff --git a/apps/web/src/views/oss-friends/index.tsx b/apps/web/src/views/oss-friends/index.tsx index 9c95ffe9..e009cef2 100644 --- a/apps/web/src/views/oss-friends/index.tsx +++ b/apps/web/src/views/oss-friends/index.tsx @@ -18,6 +18,7 @@ interface OSSFriendsResponse { export default function OSSFriendsView() { const [ossFriends, setOSSFriends] = useState([]); + const [isLoading, setIsLoading] = useState(true); const fetchOSSFriends = async (): Promise => { try { const response = await fetch("/api/oss-friends"); @@ -36,8 +37,12 @@ export default function OSSFriendsView() { useEffect(() => { async function fetchData() { - const data = await fetchOSSFriends(); - setOSSFriends(data); + try { + const data = await fetchOSSFriends(); + setOSSFriends(data); + } finally { + setIsLoading(false); + } } void fetchData(); }, []); @@ -59,38 +64,54 @@ export default function OSSFriendsView() {
- {ossFriends.map((friend, idx) => { - return ( + {isLoading && + Array.from({ length: 12 }).map((_, idx) => (
-
- -

- {friend.name} -

- - -

- {friend.description} -

+
+
+
+
- +
- ); - })} + ))} + + {!isLoading && + ossFriends.map((friend, idx) => { + return ( +
+
+ +

+ {friend.name} +

+ + +

+ {friend.description} +

+
+ +
+ ); + })}