From 9824882cc0a6ba2b2019e157345b5fc7923d79f4 Mon Sep 17 00:00:00 2001 From: Martin Domajnko <35891136+martines3000@users.noreply.github.com> Date: Thu, 6 Jun 2024 17:33:39 +0200 Subject: [PATCH] feat: profile loading skeleton (#4) --- packages/dapp/src/app/page.tsx | 27 +------- packages/dapp/src/app/profile/[slug]/Feed.tsx | 43 ++++++++++--- .../src/app/profile/[slug]/PageSkeleton.tsx | 29 +++++++++ .../src/app/profile/[slug]/ProfileAvatar.tsx | 62 +++++++++++++++---- .../dapp/src/app/profile/[slug]/loading.tsx | 5 +- .../dapp/src/components/Endorsee/index.tsx | 16 +++++ packages/dapp/src/lib/contracts/constants.ts | 2 +- 7 files changed, 137 insertions(+), 47 deletions(-) create mode 100644 packages/dapp/src/app/profile/[slug]/PageSkeleton.tsx diff --git a/packages/dapp/src/app/page.tsx b/packages/dapp/src/app/page.tsx index eef47dc..177742e 100644 --- a/packages/dapp/src/app/page.tsx +++ b/packages/dapp/src/app/page.tsx @@ -1,8 +1,7 @@ import { Container } from '@/components/Container'; import { EndorseForm } from '@/components/EndorseForm'; -import { Endorsee } from '@/components/Endorsee'; +import { Endorsee, EndorseeSkeleton } from '@/components/Endorsee'; import { Button } from '@/components/ui/button'; -import { Skeleton } from '@/components/ui/skeleton'; import { PlatformType, validateOrGetDefaultPlatform } from '@/utils'; import Link from 'next/link'; import { Suspense } from 'react'; @@ -33,17 +32,7 @@ export default async function Page({ endorsee={ -
- -
-
- - -
- - } + fallback={} > -
- -
-
- - -
- - } + fallback={} > { return (
-
+
{ @@ -56,7 +58,7 @@ export const Feed = ({ account, platform, tab, network }: FeedProps) => { @@ -64,11 +66,34 @@ export const Feed = ({ account, platform, tab, network }: FeedProps) => {
- {_tab === 'dashboard' && ( - - )} - {_tab === 'explorer' && } - {_tab === 'graph' && } + + +
+ } + > + {_tab === 'dashboard' && ( + + )} + {_tab === 'explorer' && } + {_tab === 'graph' && } + +
+
+ ); +}; + +export const FeedSkeleton = () => { + return ( +
+
+ + + +
+
+
); diff --git a/packages/dapp/src/app/profile/[slug]/PageSkeleton.tsx b/packages/dapp/src/app/profile/[slug]/PageSkeleton.tsx new file mode 100644 index 0000000..dcad698 --- /dev/null +++ b/packages/dapp/src/app/profile/[slug]/PageSkeleton.tsx @@ -0,0 +1,29 @@ +import { Container } from '@/components/Container'; +import { ProfileAvatarSkeleton } from './ProfileAvatar'; +import { Skeleton } from '@/components/ui/skeleton'; +import { FeedSkeleton } from './Feed'; + +export const PageSkeleton = () => { + return ( + +
+
+
+ +
+ +
+
+ + +
+ +
+
+
+ +
+
+
+ ); +}; diff --git a/packages/dapp/src/app/profile/[slug]/ProfileAvatar.tsx b/packages/dapp/src/app/profile/[slug]/ProfileAvatar.tsx index a656036..01aecba 100644 --- a/packages/dapp/src/app/profile/[slug]/ProfileAvatar.tsx +++ b/packages/dapp/src/app/profile/[slug]/ProfileAvatar.tsx @@ -5,19 +5,21 @@ import { useState } from 'react'; import { Skeleton } from '@/components/ui/skeleton'; import { MemoizedImage } from '@/components/MemoizedImage'; +type AvatarSize = + | 'xs' + | 'sm' + | 'md' + | 'lg' + | 'xl' + | '2xl' + | '3xl' + | '4xl' + | '5xl' + | '6xl'; + type ProfileAvatarProps = { avatar: string | null; - size?: - | 'xs' - | 'sm' - | 'md' - | 'lg' - | 'xl' - | '2xl' - | '3xl' - | '4xl' - | '5xl' - | '6xl'; + size?: AvatarSize; }; const AVATAR_SIZES = { @@ -101,3 +103,41 @@ export const ProfileAvatar = ({ avatar, size = 'md' }: ProfileAvatarProps) => { ); }; + +export const ProfileAvatarSkeleton = ({ + size = 'md', +}: { size?: AvatarSize }) => { + return ( +
+ +
+ ); +}; diff --git a/packages/dapp/src/app/profile/[slug]/loading.tsx b/packages/dapp/src/app/profile/[slug]/loading.tsx index 3bbc544..ec7dd83 100644 --- a/packages/dapp/src/app/profile/[slug]/loading.tsx +++ b/packages/dapp/src/app/profile/[slug]/loading.tsx @@ -1,4 +1,5 @@ +import { PageSkeleton } from './PageSkeleton'; + export default function Loading() { - // You can add any UI inside Loading, including a Skeleton. - return
Loading...
; + return ; } diff --git a/packages/dapp/src/components/Endorsee/index.tsx b/packages/dapp/src/components/Endorsee/index.tsx index 263aa36..0d01f21 100644 --- a/packages/dapp/src/components/Endorsee/index.tsx +++ b/packages/dapp/src/components/Endorsee/index.tsx @@ -3,6 +3,8 @@ import { EndorseeBadge } from './EndorseeBadge'; import type { PlatformType } from '@/utils/platform'; import { getMinimalProfileInfoByPlatform } from '@/lib/airstack/getMinimalProfileInfoByPlatform'; import { SearchParamsStateSync } from './SearchParamsStateSync'; +import { Skeleton } from '@/components/ui/skeleton'; +import { ProfileAvatarSkeleton } from '@/app/profile/[slug]/ProfileAvatar'; type EndorseeProps = { platform: PlatformType; @@ -63,3 +65,17 @@ export const Endorsee = async ({ ); }; + +export const EndorseeSkeleton = () => { + return ( + <> +
+ +
+
+ + +
+ + ); +}; diff --git a/packages/dapp/src/lib/contracts/constants.ts b/packages/dapp/src/lib/contracts/constants.ts index bb5784d..d109194 100644 --- a/packages/dapp/src/lib/contracts/constants.ts +++ b/packages/dapp/src/lib/contracts/constants.ts @@ -8,7 +8,7 @@ import { APP_ENV } from '@/utils/appEnv'; const getDefaultChainId = () => { if (APP_ENV === 'development') { - return 1337; + return 11155111; } if (APP_ENV === 'staging') {