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:
Arunmozhi
2022-03-02 19:32:46 +05:30
committed by GitHub
parent 20cc3e9827
commit ac54d25be8
2 changed files with 33 additions and 14 deletions

View File

@@ -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>

View File

@@ -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();
});
});