0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Improved feed item layout and typography

ref https://linear.app/tryghost/issue/AP-282/render-notes-in-the-frontend
This commit is contained in:
Djordje Vlaisavljevic 2024-09-19 20:28:01 +01:00 committed by Fabien 'egg' O'Carroll
parent 6d873600f0
commit 9b2228708a

View file

@ -55,7 +55,7 @@ export function renderFeedAttachment(object: ObjectProperties, layout: string) {
} }
return ( return (
<div className={`attachment-gallery mt-2 grid ${gridClass} gap-2`}> <div className={`attachment-gallery mt-3 grid ${gridClass} gap-2`}>
{attachment.map((item, index) => ( {attachment.map((item, index) => (
<img key={item.url} alt={`attachment-${index}`} className={`h-full w-full rounded-md object-cover outline outline-1 -outline-offset-1 outline-black/10 ${attachmentCount === 3 && index === 0 ? 'row-span-2' : ''}`} src={item.url} /> <img key={item.url} alt={`attachment-${index}`} className={`h-full w-full rounded-md object-cover outline outline-1 -outline-offset-1 outline-black/10 ${attachmentCount === 3 && index === 0 ? 'row-span-2' : ''}`} src={item.url} />
))} ))}
@ -67,10 +67,10 @@ export function renderFeedAttachment(object: ObjectProperties, layout: string) {
case 'image/jpeg': case 'image/jpeg':
case 'image/png': case 'image/png':
case 'image/gif': case 'image/gif':
return <img alt='attachment' className='mt-2 rounded-md outline outline-1 -outline-offset-1 outline-black/10' src={attachment.url} />; return <img alt='attachment' className='mt-3 rounded-md outline outline-1 -outline-offset-1 outline-black/10' src={attachment.url} />;
case 'video/mp4': case 'video/mp4':
case 'video/webm': case 'video/webm':
return <div className='relative mb-4 mt-2'> return <div className='relative mb-4 mt-3'>
<video className='h-[300px] w-full rounded object-cover' src={attachment.url} controls/> <video className='h-[300px] w-full rounded object-cover' src={attachment.url} controls/>
</div>; </div>;
@ -164,9 +164,9 @@ const FeedItemStats: React.FC<{
}; };
return (<div className='flex gap-5'> return (<div className='flex gap-5'>
<div className='mt-3 flex gap-1'> <div className='flex gap-1'>
<Button <Button
className={`self-start text-grey-900 transition-all hover:opacity-70 ${isClicked ? 'bump' : ''} ${isLiked ? 'ap-red-heart text-red *:!fill-red hover:text-red' : ''}`} className={`self-start text-grey-900 transition-all hover:opacity-60 ${isClicked ? 'bump' : ''} ${isLiked ? 'ap-red-heart text-red *:!fill-red hover:text-red' : ''}`}
hideLabel={true} hideLabel={true}
icon='heart' icon='heart'
id='like' id='like'
@ -179,9 +179,9 @@ const FeedItemStats: React.FC<{
/> />
{isLiked && <span className={`text-grey-900`}>{likeCount}</span>} {isLiked && <span className={`text-grey-900`}>{likeCount}</span>}
</div> </div>
<div className='mt-3 flex gap-1'> <div className='flex gap-1'>
<Button <Button
className={`self-start text-grey-900`} className={`self-start text-grey-900 hover:opacity-60 ${isClicked ? 'bump' : ''}`}
hideLabel={true} hideLabel={true}
icon='comment' icon='comment'
id='comment' id='comment'
@ -192,7 +192,9 @@ const FeedItemStats: React.FC<{
onCommentClick(); onCommentClick();
}} }}
/> />
<span className={`text-grey-900`}>{commentCount}</span> {commentCount > 0 && (
<span className={`text-grey-900`}>{commentCount}</span>
)}
</div> </div>
</div>); </div>);
}; };
@ -261,7 +263,7 @@ const FeedItem: React.FC<FeedItemProps> = ({actor, object, layout, type, comment
const UserMenuTrigger = ( const UserMenuTrigger = (
<Button <Button
className={`relative z-10 ml-auto self-start ${isCopied ? 'bump' : ''}`} className={`relative z-10 ml-auto h-5 w-5 self-start ${isCopied ? 'bump' : ''}`}
hideLabel={true} hideLabel={true}
icon='dotdotdot' icon='dotdotdot'
iconColorClass='text-grey-600' iconColorClass='text-grey-600'
@ -284,29 +286,32 @@ const FeedItem: React.FC<FeedItemProps> = ({actor, object, layout, type, comment
<APAvatar author={author}/> <APAvatar author={author}/>
<div className='flex justify-between'> <div className='flex justify-between'>
<div className='relative z-10 flex w-full flex-col overflow-visible text-[1.5rem]'> <div className='relative z-10 flex w-full flex-col overflow-visible text-[1.5rem]'>
<div className='flex'> <div className='flex justify-between'>
<span className='truncate whitespace-nowrap font-bold' data-test-activity-heading>{author.name}</span> <div className='flex'>
<span className='whitespace-nowrap text-grey-700 before:mx-1 before:content-["·"]' title={`${timestamp}`}>{getRelativeTimestamp(date)}</span> <span className='truncate whitespace-nowrap font-bold' data-test-activity-heading>{author.name}</span>
</div> <span className='ml-1 truncate text-grey-700'>{getUsername(author)}</span>
<div className='flex'> </div>
<span className='truncate text-grey-700'>{getUsername(author)}</span> <span className='whitespace-nowrap text-grey-700' title={`${timestamp}`}>{getRelativeTimestamp(date)}</span>
</div> </div>
</div> </div>
<Menu items={menuItems} position='end' trigger={UserMenuTrigger}/>
</div> </div>
<div className={`relative z-10 col-start-2 col-end-3 w-full gap-4`}> <div className={`relative z-10 col-start-2 col-end-3 w-full gap-4`}>
<div className='flex flex-col'> <div className='flex flex-col'>
{object.name && <Heading className='mb-1 leading-tight' level={4} data-test-activity-heading>{object.name}</Heading>} <div className='mt-[-24px]'>
<div dangerouslySetInnerHTML={({__html: object.content})} className='ap-note-content text-pretty text-[1.5rem] text-grey-900'></div> {object.name && <Heading className='mb-1 leading-tight' level={4} data-test-activity-heading>{object.name}</Heading>}
{renderFeedAttachment(object, layout)} <div dangerouslySetInnerHTML={({__html: object.content})} className='ap-note-content text-pretty text-[1.5rem] text-grey-900'></div>
<FeedItemStats {renderFeedAttachment(object, layout)}
commentCount={comments.length} </div>
likeCount={1} <div className='space-between mt-5 flex'>
object={object} <FeedItemStats
onCommentClick={onCommentClick} commentCount={comments.length}
onLikeClick={onLikeClick} likeCount={1}
/> object={object}
onCommentClick={onCommentClick}
onLikeClick={onLikeClick}
/>
<Menu items={menuItems} position='end' trigger={UserMenuTrigger}/>
</div>
</div> </div>
</div> </div>
{/* </div> */} {/* </div> */}
@ -343,22 +348,25 @@ const FeedItem: React.FC<FeedItemProps> = ({actor, object, layout, type, comment
<div className={`relative z-10 col-start-1 col-end-3 w-full gap-4`}> <div className={`relative z-10 col-start-1 col-end-3 w-full gap-4`}>
<div className='flex flex-col'> <div className='flex flex-col'>
{object.name && <Heading className='mb-1 leading-tight' level={4} data-test-activity-heading>{object.name}</Heading>} {object.name && <Heading className='mb-1 leading-tight' level={4} data-test-activity-heading>{object.name}</Heading>}
<div dangerouslySetInnerHTML={({__html: object.content})} className='ap-note-content text-pretty text-[1.6rem] text-grey-900'></div> <div dangerouslySetInnerHTML={({__html: object.content})} className='ap-note-content text-pretty text-[1.7rem] text-grey-900'></div>
{renderFeedAttachment(object, layout)} {renderFeedAttachment(object, layout)}
<FeedItemStats <div className='space-between mt-5 flex'>
commentCount={comments.length} <FeedItemStats
likeCount={1} commentCount={comments.length}
object={object} likeCount={1}
onCommentClick={onCommentClick} object={object}
onLikeClick={onLikeClick} onCommentClick={onCommentClick}
/> onLikeClick={onLikeClick}
/>
<Menu items={menuItems} position='end' trigger={UserMenuTrigger}/>
</div>
</div> </div>
</div> </div>
{/* </div> */} {/* </div> */}
</div> </div>
<div className={`absolute -inset-x-3 -inset-y-0 z-0 rounded transition-colors`}></div> <div className={`absolute -inset-x-3 -inset-y-0 z-0 rounded transition-colors`}></div>
</div> </div>
<div className="mx-[-32px] mt-3 h-px w-[120%] bg-grey-200"></div> <div className="mt-3 h-px bg-grey-200"></div>
</div> </div>
)} )}
@ -392,13 +400,16 @@ const FeedItem: React.FC<FeedItemProps> = ({actor, object, layout, type, comment
{object.name && <Heading className='mb-1 leading-tight' level={4} data-test-activity-heading>{object.name}</Heading>} {object.name && <Heading className='mb-1 leading-tight' level={4} data-test-activity-heading>{object.name}</Heading>}
<div dangerouslySetInnerHTML={({__html: object.content})} className='ap-note-content text-pretty text-[1.5rem] text-grey-900'></div> <div dangerouslySetInnerHTML={({__html: object.content})} className='ap-note-content text-pretty text-[1.5rem] text-grey-900'></div>
{renderFeedAttachment(object, layout)} {renderFeedAttachment(object, layout)}
<FeedItemStats <div className='space-between mt-5 flex'>
commentCount={comments.length} <FeedItemStats
likeCount={1} commentCount={comments.length}
object={object} likeCount={1}
onCommentClick={onCommentClick} object={object}
onLikeClick={onLikeClick} onCommentClick={onCommentClick}
/> onLikeClick={onLikeClick}
/>
<Menu items={menuItems} position='end' trigger={UserMenuTrigger}/>
</div>
</div> </div>
</div> </div>
{/* </div> */} {/* </div> */}
@ -429,13 +440,16 @@ const FeedItem: React.FC<FeedItemProps> = ({actor, object, layout, type, comment
</div> </div>
{renderInboxAttachment(object)} {renderInboxAttachment(object)}
</div> </div>
<FeedItemStats <div className='space-between mt-5 flex'>
commentCount={comments.length} <FeedItemStats
likeCount={1} commentCount={comments.length}
object={object} likeCount={1}
onCommentClick={onCommentClick} object={object}
onLikeClick={onLikeClick} onCommentClick={onCommentClick}
/> onLikeClick={onLikeClick}
/>
<Menu items={menuItems} position='end' trigger={UserMenuTrigger}/>
</div>
</div> </div>
</div> </div>
</div> </div>