Skip to content

Commit

Permalink
Updated ActivityPub Feed and Replies design (#20992)
Browse files Browse the repository at this point in the history
- Added activity icon for Replies
- Updated Replies design
- Updated hard-coded Profile values to more realistic ones
- Renamed ActivityPub nav item and moved it to the top of the navbar
- Added a check for post attachments
  • Loading branch information
djordjevlais authored Sep 12, 2024
1 parent 625c89e commit a087e32
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 26 deletions.
16 changes: 10 additions & 6 deletions apps/admin-x-activitypub/src/components/Activities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import APAvatar, {AvatarBadge} from './global/APAvatar';
import ActivityItem from './activities/ActivityItem';
import MainNavigation from './navigation/MainNavigation';
import {Button} from '@tryghost/admin-x-design-system';
import {Button, NoValueLabel} from '@tryghost/admin-x-design-system';

import getUsername from '../utils/get-username';
import {useBrowseInboxForUser, useBrowseOutboxForUser, useFollowersForUser} from '../MainContent';
Expand Down Expand Up @@ -65,7 +65,7 @@ const getExtendedDescription = (activity: Activity): JSX.Element | null => {
return (
<div
dangerouslySetInnerHTML={{__html: activity.object?.content || ''}}
className='ml-2 mt-2 text-sm text-grey-600'
className='mt-2'
/>
);
}
Expand All @@ -92,7 +92,7 @@ const getActorUrl = (activity: Activity): string | null => {
const getActivityBadge = (activity: Activity): AvatarBadge => {
switch (activity.type) {
case ACTVITY_TYPE.CREATE:
return 'user-fill'; // TODO: Change this
return 'comment-fill';
case ACTVITY_TYPE.FOLLOW:
return 'user-fill';
case ACTVITY_TYPE.LIKE:
Expand Down Expand Up @@ -171,19 +171,23 @@ const Activities: React.FC<ActivitiesProps> = ({}) => {
<MainNavigation title='Activities' />
<div className='z-0 flex w-full flex-col items-center'>
{activities.length === 0 && (
<div className='mt-8 font-bold'>This is an empty state when there are no activities</div>
<div className='mt-8'>
<NoValueLabel icon='bell'>
When other Fediverse users interact with you, you&apos;ll see it here.
</NoValueLabel>
</div>
)}
{activities.length > 0 && (
<div className='mt-8 flex w-full max-w-[560px] flex-col'>
{activities?.map(activity => (
<ActivityItem key={activity.id} url={getActivityUrl(activity) || getActorUrl(activity)}>
<APAvatar author={activity.actor} badge={getActivityBadge(activity)} />
<div>
<div className='pt-[2px]'>
<div className='text-grey-600'>
<span className='mr-1 font-bold text-black'>{activity.actor.name}</span>
{getUsername(activity.actor)}
</div>
<div className='text-sm'>{getActivityDescription(activity, activityObjectsMap)}</div>
<div className=''>{getActivityDescription(activity, activityObjectsMap)}</div>
{getExtendedDescription(activity)}
</div>
{isFollower(activity.actor.id) === false && (
Expand Down
10 changes: 5 additions & 5 deletions apps/admin-x-activitypub/src/components/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const Profile: React.FC<ProfileProps> = ({}) => {
id: 'likes',
title: 'Likes',
contents: (
<div>
<div className='ap-likes'>
{liked.length === 0 ? (
<NoValueLabel icon='heart'>
You haven&apos;t liked anything yet.
Expand Down Expand Up @@ -141,10 +141,10 @@ const Profile: React.FC<ProfileProps> = ({}) => {
<div className='inline-flex rounded-lg border-4 border-white'>
<APAvatar size='lg' />
</div>
<Heading className='mt-4' level={3}>John Doe</Heading>
<span className='mt-1 text-[1.5rem] text-grey-800'>@index@site.com</span>
<p className='mt-3 text-[1.5rem]'>This is a summary/bio/etc which could be kinda long in certain cases but not always, so...</p>
<a className='mt-3 block text-[1.5rem] underline' href='#'>www.coolsite.com</a>
<Heading className='mt-4' level={3}>Building ActivityPub</Heading>
<span className='mt-1 text-[1.5rem] text-grey-800'>@index@activitypub.ghost.org</span>
<p className='mt-3 text-[1.5rem]'>Ghost is federating over ActivityPub to become part of the world&apos;s largest publishing network</p>
<a className='mt-3 block text-[1.5rem] underline' href='https://activitypub.ghost.org'>activitypub.ghost.org</a>
<TabView<'posts' | 'likes' | 'following' | 'followers'> containerClassName='mt-6' selectedTab={selectedTab} tabs={tabs} onTabChange={setSelectedTab} />
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const ActivityItem: React.FC<ActivityItemProps> = ({children, url = null}) => {

const Item = (
<div className='flex w-full max-w-[560px] flex-col hover:bg-grey-75'>
<div className='flex w-full items-center gap-4 border-b border-grey-100 px-2 py-4'>
<div className='flex w-full gap-4 border-b border-grey-100 px-2 py-4'>
{childrenArray[0]}
{childrenArray[1]}
{childrenArray[2]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ ${image &&
};

const FeedItemDivider: React.FC = () => (
<div className="mx-[-32px] my-4 h-px w-[120%] bg-grey-200"></div>
<div className="mx-[-32px] my-5 h-px w-[120%] bg-grey-200"></div>
);

const ArticleModal: React.FC<ArticleModalProps> = ({object, actor, comments, allComments}) => {
Expand Down
12 changes: 6 additions & 6 deletions apps/admin-x-activitypub/src/components/feed/FeedItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ function renderInboxAttachment(object: ObjectProperties) {
// }
return (
<div className='min-w-[160px]'>
<div className='relative'>
{attachment[0] && <div className='relative'>
<img className={`h-[100px] w-[160px] rounded-md object-cover`} src={attachment[0].url} />
<div className='absolute bottom-1 right-1 z-10 rounded-full border border-[rgba(255,255,255,0.25)] bg-black px-2 py-0.5 font-semibold text-white'>+ {attachmentCount - 1}</div>
</div>
</div>}
</div>
);
}
Expand All @@ -103,7 +103,7 @@ function renderInboxAttachment(object: ObjectProperties) {
case 'image/gif':
return (
<div className='min-w-[160px]'>
<img className={`h-[100px] w-[160px] rounded-md object-cover`} src={attachment.url} />
{attachment && <img className={`h-[100px] w-[160px] rounded-md object-cover`} src={attachment.url} />}
</div>
);
case 'video/mp4':
Expand Down Expand Up @@ -302,7 +302,7 @@ const FeedItem: React.FC<FeedItemProps> = ({actor, object, layout, type, comment
</div>
<div className={`absolute -inset-x-3 -inset-y-0 z-0 rounded transition-colors`}></div>
</div>
<div className="mx-[-32px] my-4 h-px w-[120%] bg-grey-200"></div>
<div className="mx-[-32px] my-3 h-px w-[120%] bg-grey-200"></div>
</div>

)}
Expand All @@ -312,12 +312,12 @@ const FeedItem: React.FC<FeedItemProps> = ({actor, object, layout, type, comment
return (
<>
{object && (
<div className={`group/article relative cursor-pointer pt-5`} onClick={onClick}>
<div className={`group/article relative cursor-pointer pt-2`} onClick={onClick}>
{(type === 'Announce' && object.type === 'Note') && <div className='z-10 mb-2 flex items-center gap-3 text-grey-700'>
<div className='z-10 flex w-10 justify-end'><Icon colorClass='text-grey-700' name='reload' size={'sm'}></Icon></div>
<span className='z-10'>{actor.name} reposted</span>
</div>}
<div className={`border-1 z-10 -my-1 grid grid-cols-[auto_1fr] grid-rows-[auto_1fr] gap-x-3 gap-y-2 border-b-grey-200 pb-4`} data-test-activity>
<div className={`border-1 z-10 -my-1 grid grid-cols-[auto_1fr] grid-rows-[auto_1fr] gap-x-3 gap-y-2 border-b-grey-200`} data-test-activity>
<div className='relative z-10 pt-[3px]'>
<APAvatar author={author}/>
</div>
Expand Down
7 changes: 5 additions & 2 deletions apps/admin-x-activitypub/src/components/global/APAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {ActorProperties} from '@tryghost/admin-x-framework/api/activitypub';
import {Icon} from '@tryghost/admin-x-design-system';

type AvatarSize = 'xs' | 'sm' | 'lg';
export type AvatarBadge = 'user-fill' | 'heart-fill' | undefined;
export type AvatarBadge = 'user-fill' | 'heart-fill' | 'comment-fill' | undefined;

interface APAvatarProps {
author?: ActorProperties;
Expand All @@ -25,6 +25,9 @@ const APAvatar: React.FC<APAvatarProps> = ({author, size, badge}) => {
case 'heart-fill':
badgeColor = ' bg-red-500';
break;
case 'comment-fill':
badgeColor = ' bg-purple-500';
break;
}

switch (size) {
Expand All @@ -47,7 +50,7 @@ const APAvatar: React.FC<APAvatarProps> = ({author, size, badge}) => {
return (
<>
{author && author.icon?.url ? (
<a className='relative z-10 pt-[3px] transition-opacity hover:opacity-80' href={author.url} rel='noopener noreferrer' target='_blank'>
<a className='relative z-10 h-10 w-10 pt-[3px] transition-opacity hover:opacity-80' href={author.url} rel='noopener noreferrer' target='_blank'>
<img
className={imageClass}
src={author.icon.url}
Expand Down
14 changes: 14 additions & 0 deletions apps/admin-x-activitypub/src/styles/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,17 @@ animation: bump 0.3s ease-in-out;
margin-top: 1.5rem !important;
}

.ap-likes .ellipsis::after {
content: "…";
}

.ap-likes .invisible {
display: inline-block;
font-size: 0;
height: 0;
line-height: 0;
position: absolute;
width: 0;
}


4 changes: 4 additions & 0 deletions apps/admin-x-design-system/src/assets/icons/comment-fill.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions ghost/admin/app/components/gh-nav-menu/main.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
{{#unless this.session.user.isContributor}}
<div class="gh-nav-top">
<ul class="gh-nav-list gh-nav-main">
{{#if (feature "ActivityPub")}}
<li>
<LinkTo @route="activitypub-x" @current-when="activitypub-x">{{svg-jar "star"}}ActivityPub</LinkTo>
</li>
{{/if}}
{{#if (gh-user-can-admin this.session.user)}}
<li class="relative gh-nav-list-home">
<LinkTo @route="dashboard" @alt="Dashboard" title="Dashboard" data-test-nav="dashboard">{{svg-jar "house"}} Dashboard</LinkTo>
Expand Down Expand Up @@ -128,11 +133,6 @@
<LinkTo @route="demo-x" @current-when="demo-x">{{svg-jar "star"}}AdminX Demo</LinkTo>
</li>
{{/if}}
{{#if (feature "ActivityPub")}}
<li>
<LinkTo @route="activitypub-x" @current-when="activitypub-x">{{svg-jar "star"}}ActivityPub Demo</LinkTo>
</li>
{{/if}}
</ul>

{{#if this.session.user.isOwnerOnly}}
Expand Down

0 comments on commit a087e32

Please sign in to comment.