From adca6350ce1866681eeb11cec48e3d9048fc8f33 Mon Sep 17 00:00:00 2001 From: Arik Chakma Date: Wed, 8 May 2024 06:22:35 +0600 Subject: [PATCH] fix: update activity stream design --- src/components/Activity/ActivityStream.tsx | 35 +++++--- .../Activity/ActivityTopicTitles.tsx | 64 ++++++------- src/components/Activity/EmptyStream.tsx | 2 +- .../TeamActivity/TeamActivityItem.tsx | 89 ++++++++++++------- .../TeamActivity/TeamEmptyStream.tsx | 2 +- 5 files changed, 113 insertions(+), 79 deletions(-) diff --git a/src/components/Activity/ActivityStream.tsx b/src/components/Activity/ActivityStream.tsx index d4a4bdd5d..9cdae7ef4 100644 --- a/src/components/Activity/ActivityStream.tsx +++ b/src/components/Activity/ActivityStream.tsx @@ -111,28 +111,35 @@ export function ActivityStream(props: ActivityStreamProps) {
  • {actionType === 'in_progress' && ( <> - Started{' '} - setSelectedActivity(activity)} - />{' '} - in {resourceLinkComponent} {timeAgo} +

    + Started {topicCount} topic + {topicCount > 1 ? 's' : ''} in  + {resourceLinkComponent}  + {timeAgo} +

    + )} {actionType === 'done' && ( <> - Completed{' '} - setSelectedActivity(activity)} - />{' '} - in {resourceLinkComponent} {timeAgo} +

    + Completed {topicCount} topic + {topicCount > 1 ? 's' : ''} in  + {resourceLinkComponent}  + {timeAgo} +

    + )} {actionType === 'answered' && ( <> - Answered {topicCount} question{topicCount > 1 ? 's' : ''} in{' '} - {resourceLinkComponent} {timeAgo} +

    + Answered {topicCount} question + {topicCount > 1 ? 's' : ''} in  + {resourceLinkComponent}  + {timeAgo} +

    + )}
  • diff --git a/src/components/Activity/ActivityTopicTitles.tsx b/src/components/Activity/ActivityTopicTitles.tsx index 89337c7a7..a7afb11af 100644 --- a/src/components/Activity/ActivityTopicTitles.tsx +++ b/src/components/Activity/ActivityTopicTitles.tsx @@ -1,43 +1,43 @@ +import { useState } from 'react'; +import { cn } from '../../lib/classname'; + type ActivityTopicTitlesProps = { topicTitles: string[]; + className?: string; onSelectActivity?: () => void; }; export function ActivityTopicTitles(props: ActivityTopicTitlesProps) { - const { topicTitles, onSelectActivity } = props; - const firstThreeTopics = topicTitles?.slice(0, 3); - const remainingTopics = topicTitles?.slice(3); + const { topicTitles, onSelectActivity, className } = props; - return ( - <> - {firstThreeTopics.map((topicTitle, index) => { - return ( - - <> - {index > 0 && ', '} - {index === firstThreeTopics.length - 1 && - remainingTopics?.length === 0 && - firstThreeTopics.length > 1 - ? 'and ' - : ''} - {topicTitle} - - - ); - })} + const [showAll, setShowAll] = useState(false); + const filteredTopicTitles = topicTitles.slice( + 0, + showAll ? topicTitles.length : 3, + ); - {remainingTopics?.length > 0 && ( - <> - , and  - - + const shouldShowButton = topicTitles.length > 3; + + return ( +
    + {filteredTopicTitles.map((topicTitle, index) => ( + + {topicTitle} + + ))} + {shouldShowButton && ( + )} - +
    ); } diff --git a/src/components/Activity/EmptyStream.tsx b/src/components/Activity/EmptyStream.tsx index 847ab7d34..ca57f2c2c 100644 --- a/src/components/Activity/EmptyStream.tsx +++ b/src/components/Activity/EmptyStream.tsx @@ -4,7 +4,7 @@ export function EmptyStream() { return (
    - +

    No Activities

    diff --git a/src/components/TeamActivity/TeamActivityItem.tsx b/src/components/TeamActivity/TeamActivityItem.tsx index c89182d75..6e40e30ac 100644 --- a/src/components/TeamActivity/TeamActivityItem.tsx +++ b/src/components/TeamActivity/TeamActivityItem.tsx @@ -3,6 +3,7 @@ import { getRelativeTimeString } from '../../lib/date'; import type { TeamStreamActivity } from './TeamActivityPage'; import { ChevronsDown, ChevronsUp } from 'lucide-react'; import { ActivityTopicTitles } from '../Activity/ActivityTopicTitles'; +import { cn } from '../../lib/classname'; type TeamActivityItemProps = { onTopicClick?: (activity: TeamStreamActivity) => void; @@ -79,36 +80,49 @@ export function TeamActivityItem(props: TeamActivityItemProps) { return (

  • {actionType === 'in_progress' && ( <> - {username} started  +

    + {username} started  + {topicCount} topic{topicCount > 1 ? 's' : ''} in  + {resourceLink(activity)}  + {timeAgo(activity.updatedAt)} +

    onTopicClick?.(activity)} /> -  in {resourceLink(activity)}  - {timeAgo(activity.updatedAt)} )} - {actionType === 'done' && ( <> - {username} completed  +

    + {username} completed  + {topicCount} topic{topicCount > 1 ? 's' : ''} in  + {resourceLink(activity)}  + {timeAgo(activity.updatedAt)} +

    onTopicClick?.(activity)} /> -  in {resourceLink(activity)}  - {timeAgo(activity.updatedAt)} )} {actionType === 'answered' && ( <> - {username} answered {topicCount} question - {topicCount > 1 ? 's' : ''} in {resourceLink(activity)}  - {timeAgo(activity.updatedAt)} +

    + {username} answered  + {topicCount} question{topicCount > 1 ? 's' : ''} +  in  + {resourceLink(activity)}  + {timeAgo(activity.updatedAt)} +

    + )}
  • @@ -128,38 +142,51 @@ export function TeamActivityItem(props: TeamActivityItemProps) { resource(s)
    -
      - {activities.slice(0, activityLimit).map((activity) => { +
        + {activities.slice(0, activityLimit).map((activity, counter) => { const { actionType, topicTitles } = activity; const topicCount = topicTitles?.length || 0; return ( -
      • +
      • {actionType === 'in_progress' && ( <> - Started{' '} - onTopicClick?.(activity)} - />{' '} - in {resourceLink(activity)} {timeAgo(activity.updatedAt)} +

        + Started {topicCount} topic + {topicCount > 1 ? 's' : ''} in  + {resourceLink(activity)}  + {timeAgo(activity.updatedAt)} +

        + )} {actionType === 'done' && ( <> - Completed{' '} - onTopicClick?.(activity)} - />{' '} - in {resourceLink(activity)} {timeAgo(activity.updatedAt)} +

        + Completed {topicCount} topic + {topicCount > 1 ? 's' : ''} in  + {resourceLink(activity)}  + {timeAgo(activity.updatedAt)} +

        + )} {actionType === 'answered' && ( <> - Answered {topicCount} question - {topicCount > 1 ? 's' : ''} in {resourceLink(activity)}{' '} - {timeAgo(activity.updatedAt)} +

        + Answered {topicCount} question + {topicCount > 1 ? 's' : ''} in  + {resourceLink(activity)}  + {timeAgo(activity.updatedAt)} +

        + )}
      • diff --git a/src/components/TeamActivity/TeamEmptyStream.tsx b/src/components/TeamActivity/TeamEmptyStream.tsx index ee9aa34de..9fa63487b 100644 --- a/src/components/TeamActivity/TeamEmptyStream.tsx +++ b/src/components/TeamActivity/TeamEmptyStream.tsx @@ -1,4 +1,4 @@ -import { Activity, List, ListTodo } from 'lucide-react'; +import { ListTodo } from 'lucide-react'; type TeamActivityItemProps = { teamId: string;