From a99b62a229926125ae85d091d159c3f5295ae733 Mon Sep 17 00:00:00 2001 From: monoid Date: Fri, 18 Oct 2024 03:23:36 +0900 Subject: [PATCH] Refactor GalleryCard to include a skeleton loading state --- .../src/components/gallery/GalleryCard.tsx | 24 ++++ packages/client/src/components/layout/nav.tsx | 2 +- packages/client/src/page/contentInfoPage.tsx | 42 +++++-- packages/client/src/page/galleryPage.tsx | 105 ++++++++++-------- packages/client/src/page/reader/comicPage.tsx | 2 +- 5 files changed, 114 insertions(+), 61 deletions(-) diff --git a/packages/client/src/components/gallery/GalleryCard.tsx b/packages/client/src/components/gallery/GalleryCard.tsx index ea49995..da3da6f 100644 --- a/packages/client/src/components/gallery/GalleryCard.tsx +++ b/packages/client/src/components/gallery/GalleryCard.tsx @@ -5,6 +5,7 @@ import { Fragment, useLayoutEffect, useRef, useState } from "react"; import { LazyImage } from "./LazyImage.tsx"; import StyledLink from "./StyledLink.tsx"; import React from "react"; +import { Skeleton } from "../ui/skeleton.tsx"; function clipTagsWhenOverflow(tags: string[], limit: number) { let l = 0; @@ -87,4 +88,27 @@ function GalleryCardImpl({ ; } +export function GalleryCardSkeleton({ + tagCount = 20 +}: { + tagCount?: number; +}) { + return + +
+ + + + + +
    + {Array.from({ length: tagCount }).map((_, i) => )} +
+
+
+
+} + export const GalleryCard = React.memo(GalleryCardImpl); \ No newline at end of file diff --git a/packages/client/src/components/layout/nav.tsx b/packages/client/src/components/layout/nav.tsx index bc7b750..5ea962f 100644 --- a/packages/client/src/components/layout/nav.tsx +++ b/packages/client/src/components/layout/nav.tsx @@ -63,7 +63,7 @@ export function NavList() { const loginInfo = useLogin(); const navItems = useNavItems(); - return