From af54b21bf30858fc787b2c3823908b956d7977e0 Mon Sep 17 00:00:00 2001 From: Djordje Vlaisavljevic Date: Thu, 14 Nov 2024 17:42:43 +0000 Subject: [PATCH] Fixed separator showing even after the last list item (#21620) close https://linear.app/ghost/issue/AP-528/remove-unnecessary-separator-after-last-list-items - Previously, in some components, we relied on CSS and all elements in the list being the same type of an HTML element to show the separator. Now, we've extracted the separator into its own component and place after all items during mapping except the last one. --- .../src/components/Activities.tsx | 39 +++++------ .../src/components/Inbox.tsx | 38 ++++++----- .../src/components/Profile.tsx | 65 ++++++++++--------- .../src/components/Search.tsx | 24 ++++--- .../components/activities/ActivityItem.tsx | 2 +- .../src/components/global/Separator.tsx | 7 ++ .../components/global/ViewProfileModal.tsx | 36 +++++----- .../components/navigation/MainNavigation.tsx | 2 +- 8 files changed, 118 insertions(+), 95 deletions(-) create mode 100644 apps/admin-x-activitypub/src/components/global/Separator.tsx diff --git a/apps/admin-x-activitypub/src/components/Activities.tsx b/apps/admin-x-activitypub/src/components/Activities.tsx index b32a5e7641..4eaa795f58 100644 --- a/apps/admin-x-activitypub/src/components/Activities.tsx +++ b/apps/admin-x-activitypub/src/components/Activities.tsx @@ -8,6 +8,7 @@ import APAvatar, {AvatarBadge} from './global/APAvatar'; import ActivityItem, {type Activity} from './activities/ActivityItem'; import ArticleModal from './feed/ArticleModal'; import MainNavigation from './navigation/MainNavigation'; +import Separator from './global/Separator'; import ViewProfileModal from './global/ViewProfileModal'; import getUsername from '../utils/get-username'; @@ -184,28 +185,24 @@ const Activities: React.FC = ({}) => { (isLoading === false && activities.length > 0) && ( <>
- {activities?.map(activity => ( - handleActivityClick(activity)} - > - -
-
- {activity.actor.name} - {getUsername(activity.actor)} + {activities?.map((activity, index) => ( + + handleActivityClick(activity)} + > + +
+
+ {activity.actor.name} + {getUsername(activity.actor)} +
+
{getActivityDescription(activity)}
+ {getExtendedDescription(activity)}
-
{getActivityDescription(activity)}
- {getExtendedDescription(activity)} -
- {/* */} - + + {index < activities.length - 1 && } + ))}
diff --git a/apps/admin-x-activitypub/src/components/Inbox.tsx b/apps/admin-x-activitypub/src/components/Inbox.tsx index 7baedec7e7..08295edd4e 100644 --- a/apps/admin-x-activitypub/src/components/Inbox.tsx +++ b/apps/admin-x-activitypub/src/components/Inbox.tsx @@ -5,6 +5,7 @@ import FeedItem from './feed/FeedItem'; import MainNavigation from './navigation/MainNavigation'; import NiceModal from '@ebay/nice-modal-react'; import React, {useEffect, useRef} from 'react'; +import Separator from './global/Separator'; import ViewProfileModal from './global/ViewProfileModal'; import getName from '../utils/get-name'; import getUsername from '../utils/get-username'; @@ -94,7 +95,7 @@ const Inbox: React.FC = ({}) => { onCommentClick={() => handleViewContent(activity, true, updateActivity)} /> {index < activities.length - 1 && ( -
+ )} ))} @@ -107,29 +108,28 @@ const Inbox: React.FC = ({}) => {
-

You might also like...

+

You might also like

{isLoadingSuggested ? ( ) : (
    - {suggested.map((profile) => { + {suggested.map((profile, index) => { const actor = profile.actor; // const isFollowing = profile.isFollowing; return ( -
  • - NiceModal.show(ViewProfileModal, { - profile: getUsername(actor), - onFollow: () => {}, - onUnfollow: () => {} - })}> - -
    -
    - {getName(actor)} -
    {getUsername(actor)}
    + +
  • + NiceModal.show(ViewProfileModal, { + profile: getUsername(actor), + onFollow: () => {}, + onUnfollow: () => {} + })}> + +
    + {getName(actor)} + {getUsername(actor)}
    -
- {/* = ({}) => { onFollow={() => updateSuggestedProfile(actor.id!, {isFollowing: true})} onUnfollow={() => updateSuggestedProfile(actor.id!, {isFollowing: false})} /> */} - - + + + {index < suggested.length - 1 && } + ); })} diff --git a/apps/admin-x-activitypub/src/components/Profile.tsx b/apps/admin-x-activitypub/src/components/Profile.tsx index e35ce8cfc0..e9b2987738 100644 --- a/apps/admin-x-activitypub/src/components/Profile.tsx +++ b/apps/admin-x-activitypub/src/components/Profile.tsx @@ -8,6 +8,7 @@ import getName from '../utils/get-name'; import getUsername from '../utils/get-username'; import {ActorProperties} from '@tryghost/admin-x-framework/api/activitypub'; +import Separator from './global/Separator'; import ViewProfileModal from './global/ViewProfileModal'; import {Button, Heading, List, NoValueLabel, Tab, TabView} from '@tryghost/admin-x-design-system'; import {handleViewContent} from '../utils/content-handlers'; @@ -102,7 +103,7 @@ const Profile: React.FC = ({}) => { onCommentClick={() => handleViewContent(activity, true)} /> {index < posts.length - 1 && ( -
+ )} ))} @@ -147,7 +148,7 @@ const Profile: React.FC = ({}) => { onCommentClick={() => handleViewContent(activity, true)} /> {index < liked.length - 1 && ( -
+ )} ))} @@ -178,25 +179,28 @@ const Profile: React.FC = ({}) => { ) : ( - {following.slice(0, visibleFollowing).map((item) => { + {following.slice(0, visibleFollowing).map((item, index) => { return ( - handleUserClick(item)} - > - -
-
- {getName(item)} -
{getUsername(item)}
+ + handleUserClick(item)} + > + +
+
+ {getName(item)} +
{getUsername(item)}
+
-
- {/*