From 233701a1cf036ecd52f5a6307110b5829063e47f Mon Sep 17 00:00:00 2001 From: zmeyer44 Date: Mon, 30 Oct 2023 09:55:09 -0400 Subject: [PATCH] better loading state --- .../explore/_components/CalendarCard.tsx | 43 +++++++++++++++++++ .../explore/_sections/ExploreCalendars.tsx | 22 ++++++++-- 2 files changed, 62 insertions(+), 3 deletions(-) diff --git a/app/(app)/explore/_components/CalendarCard.tsx b/app/(app)/explore/_components/CalendarCard.tsx index 4e8336c..3b76f6f 100644 --- a/app/(app)/explore/_components/CalendarCard.tsx +++ b/app/(app)/explore/_components/CalendarCard.tsx @@ -10,6 +10,7 @@ import { CardHeader, CardTitle, } from "@/components/ui/card"; +import { cn } from "@/lib/utils"; import { NDKEvent } from "@nostr-dev-kit/ndk"; import { BANNER } from "@/constants/app"; import { getNameToShow } from "@/lib/utils"; @@ -18,6 +19,8 @@ import useProfile from "@/lib/hooks/useProfile"; import useEvents from "@/lib/hooks/useEvents"; import { getTagAllValues, getTagValues } from "@/lib/nostr/utils"; import { useNDK } from "@/app/_providers/ndk"; +import { Skeleton } from "@/components/ui/skeleton"; +import { AspectRatio } from "@/components/ui/aspect-ratio"; type CalendarCardProps = { calendar: NDKEvent; @@ -144,3 +147,43 @@ export default function CalendarCard({ calendar }: CalendarCardProps) { ); } +export function LoadingCalendarCard() { + const textColor = "bg-zinc-200"; + return ( + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+
+ +
+ + + Upcoming Events: + + +
    +
  • + +
  • +
+
+
+
+
+
+ ); +} diff --git a/app/(app)/explore/_sections/ExploreCalendars.tsx b/app/(app)/explore/_sections/ExploreCalendars.tsx index a502d39..56e4d62 100644 --- a/app/(app)/explore/_sections/ExploreCalendars.tsx +++ b/app/(app)/explore/_sections/ExploreCalendars.tsx @@ -11,7 +11,7 @@ import { getTagValues } from "@/lib/nostr/utils"; import { NDKEvent, NDKKind, NDKUserProfile } from "@nostr-dev-kit/ndk"; import { useNDK } from "@nostr-dev-kit/ndk-react"; -import CalendarCard from "../_components/CalendarCard"; +import CalendarCard, { LoadingCalendarCard } from "../_components/CalendarCard"; export default function ExploreCalendars() { return (
@@ -35,14 +35,30 @@ function HorizontalCarousel() { limit: 5, }, }); + + if (events.length) { + return ( +
+ {events.map((calendar, index) => ( +
+ +
+ ))} +
+ ); + } + return (
- {events.map((calendar, index) => ( + {Array.from(Array(5)).map((_, index) => (
- +
))}