From bbcd7e18e54398c3c496ff087d0ff9a4da19bc97 Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Thu, 12 Sep 2024 15:28:28 +0100 Subject: [PATCH] Update stack message --- .../Dashboard/DashboardBookmarkCard.tsx | 4 +- .../Dashboard/EmptyStackMessage.tsx | 32 +++ src/components/Dashboard/ProgressStack.tsx | 218 +++++++++++------- 3 files changed, 164 insertions(+), 90 deletions(-) create mode 100644 src/components/Dashboard/EmptyStackMessage.tsx diff --git a/src/components/Dashboard/DashboardBookmarkCard.tsx b/src/components/Dashboard/DashboardBookmarkCard.tsx index 3a7bafbb9..10bd984b6 100644 --- a/src/components/Dashboard/DashboardBookmarkCard.tsx +++ b/src/components/Dashboard/DashboardBookmarkCard.tsx @@ -27,9 +27,9 @@ export function DashboardBookmarkCard(props: DashboardBookmarkCardProps) { - +

{resourceTitle}

); diff --git a/src/components/Dashboard/EmptyStackMessage.tsx b/src/components/Dashboard/EmptyStackMessage.tsx new file mode 100644 index 000000000..c0fc65567 --- /dev/null +++ b/src/components/Dashboard/EmptyStackMessage.tsx @@ -0,0 +1,32 @@ +type EmptyStackMessageProps = { + number: number; + title: string; + description: string; + buttonText: string; + buttonLink: string; +}; + +export function EmptyStackMessage(props: EmptyStackMessageProps) { + const { number, title, description, buttonText, buttonLink } = props; + + return ( +
+
+ + {number} + +
+

{title}

+

{description}

+
+ + + {buttonText} + +
+
+ ); +} diff --git a/src/components/Dashboard/ProgressStack.tsx b/src/components/Dashboard/ProgressStack.tsx index 4c0d9faef..29a16137a 100644 --- a/src/components/Dashboard/ProgressStack.tsx +++ b/src/components/Dashboard/ProgressStack.tsx @@ -14,6 +14,7 @@ import { cn } from '../../lib/classname'; import { DashboardProgressCard } from './DashboardProgressCard'; import { useStore } from '@nanostores/react'; import { $accountStreak, type StreakResponse } from '../../stores/streak'; +import { EmptyStackMessage } from './EmptyStackMessage.tsx'; type ProgressStackProps = { progresses: UserProgress[]; @@ -26,8 +27,8 @@ type ProgressStackProps = { }; const MAX_PROGRESS_TO_SHOW = 5; +const MAX_BOOKMARKS_TO_SHOW = 5; const MAX_PROJECTS_TO_SHOW = 8; -const MAX_BOOKMARKS_TO_SHOW = 8; type ProgressLaneProps = { title: string; @@ -74,7 +75,7 @@ function ProgressLane(props: ProgressLaneProps) { {linkText && linkHref && ( {linkText} @@ -83,7 +84,7 @@ function ProgressLane(props: ProgressLaneProps) { )} -
+
{isLoading && ( <> {Array.from({ length: loadingSkeletonCount }).map((_, index) => ( @@ -166,98 +167,139 @@ export function ProgressStack(props: ProgressStackProps) {
- - {userProgressesToShow.length > 0 && ( - <> - {userProgressesToShow.map((progress) => { - return ( - - ); - })} - - )} - - {userProgresses.length > MAX_PROGRESS_TO_SHOW && ( - + {!isLoading && bookmarksToShow.length === 0 && ( + )} - - - {projectsToShow.map((project) => { - return ( - - ); - })} - - {projects.length > MAX_PROJECTS_TO_SHOW && ( - + {bookmarksToShow.map((progress) => { + return ( + + ); + })} + {bookmarkedProgresses.length > MAX_BOOKMARKS_TO_SHOW && ( + + )} + +
+ +
+ {!isLoading && userProgressesToShow.length === 0 && ( + )} - + + {userProgressesToShow.length > 0 && ( + <> + {userProgressesToShow.map((progress) => { + return ( + + ); + })} + + )} - - {bookmarksToShow.map((progress) => { - return ( - MAX_PROGRESS_TO_SHOW && ( + - ); - })} - {bookmarkedProgresses.length > MAX_BOOKMARKS_TO_SHOW && ( - - )} - + )} + +
+ +
+ + {!isLoading && projectsToShow.length === 0 && ( + + )} + + {projectsToShow.map((project) => { + return ( + + ); + })} + + {projects.length > MAX_PROJECTS_TO_SHOW && ( + + )} + +
);