feat: replace cohort text with icon & overlay in posts (#69)
This implements the new UI design of showing an icon for posts that are specific to a cohort. The icon upon mouse-over shows the name of the cohort as an overlay. https://openedx.atlassian.net/browse/TNL-9483
This commit is contained in:
@@ -66,20 +66,31 @@ function PostFooter({
|
||||
<Badge variant="light">{intl.formatMessage(messages.newLabel, { count: post.unreadCommentCount })}</Badge>
|
||||
) : null}
|
||||
<div className="d-flex flex-fill justify-content-end align-items-center">
|
||||
{!preview
|
||||
&& (
|
||||
<span className="text-gray-500 mr-4 d-flex align-items-center">
|
||||
<Icon
|
||||
src={Person}
|
||||
className="mr-1"
|
||||
style={{
|
||||
width: '1em',
|
||||
height: '1em',
|
||||
}}
|
||||
/>
|
||||
{post.groupName || intl.formatMessage(messages.visibleToAll)}
|
||||
</span>
|
||||
)}
|
||||
{
|
||||
post.groupId
|
||||
? (
|
||||
<>
|
||||
<OverlayTrigger
|
||||
overlay={(
|
||||
<Tooltip>
|
||||
{post.groupName || intl.formatMessage(messages.visibleToAll)}
|
||||
</Tooltip>
|
||||
)}
|
||||
>
|
||||
<Icon
|
||||
data-testid="cohort-icon"
|
||||
src={Person}
|
||||
className="text-gray-500"
|
||||
style={{
|
||||
width: '1em',
|
||||
height: '1em',
|
||||
}}
|
||||
/>
|
||||
</OverlayTrigger>
|
||||
<span className="text-gray-500 mx-1">·</span>
|
||||
</>
|
||||
) : null
|
||||
}
|
||||
<span title={post.createdAt} className="text-gray-500">
|
||||
{timeago.format(post.createdAt, intl.locale)}
|
||||
</span>
|
||||
|
||||
@@ -73,4 +73,12 @@ describe('PostFooter', () => {
|
||||
renderComponent({ ...mockPost, unreadCommentCount: 1, commentCount: 1 });
|
||||
expect(screen.queryByText('1 new')).toBeFalsy();
|
||||
});
|
||||
|
||||
it('has the cohort icon only when group information is present', () => {
|
||||
renderComponent(mockPost);
|
||||
expect(screen.queryByTestId('cohort-icon')).toBeFalsy();
|
||||
|
||||
renderComponent({ ...mockPost, groupId: 5, groupName: 'Test Cohort' });
|
||||
expect(screen.getByTestId('cohort-icon')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user