Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Improved delivered status indicator WPB-9170 #17553

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

svitovyda
Copy link
Contributor

@svitovyda svitovyda commented Jun 10, 2024

StoryWPB-9170 Improve hover states and paddings for delivered status

Description

Now the conversation should have additional empty space at the right, and the last delivered message should contain a translated "Delivered" indicator, visible always (instead of on mouse over).
This feature design was made considering that most of the webapp/desktop users use it on res 800px+, design improvements for smaller screens will be defined later.
After this version is deployed, we might implement another design with checkboxes (under a separate ticket) that can be toggled using debug

Note 1: for the first implementation, where each message had an additional div to the right: I assumed that any message header would be short enough to not wrap it into the container that takes 100% - ${deliveredIndicatorWidth}px. It might be the improvement for the next design iteration to address the small screen look

Note 2: for the second implementation, where the entire MessageList has a margin: Now the MessageList has to add and immediately remove the "Delivered" indicator to identify its width. Another option could be to add a static margin (of ~100px) and listen to the message components when one of them will have to add this indicator, then adjust the margin width. Another option could be that each message component could have a margin, but I'm not sure what we will win here

Screenshots/Screencast (for UI changes)

Screenshot 2024-06-10 at 21 32 32

Screenshot 2024-06-10 at 21 32 59

Screenshot 2024-06-10 at 21 33 36

Screenshot 2024-06-10 at 21 34 06

Screenshot 2024-06-10 at 21 35 36

Screenshot 2024-06-12 at 11 50 17

Checklist

  • PR has been self reviewed by the author;
  • Hard-to-understand areas of the code have been commented;
  • If it is a core feature, unit tests have been added;

fontSize: 'var(--font-size-small)',
fontWeight: 'var(--font-weight-regular)',
wordWrap: 'normal',
width: 'min-content',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One translation of "Delivered" is two words, here I make sure they will be wrapped

boxSizing: 'border-box',
justifyContent: 'center',
alignItems: 'center',
position: 'absolute',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's another self-positioned component

isLastDeliveredMessage,
onClickDetails,
}: ReadReceiptStatusProps) => {
export const ReadReceiptStatus = ({message, is1to1Conversation, onClickDetails}: ReadReceiptStatusProps) => {
Copy link
Contributor Author

@svitovyda svitovyda Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one can be moved to the ReadIndicator folder, which will make it easier to not forget about one of them when the other should be changed

@@ -22,7 +22,7 @@
width: 100%;
flex-wrap: wrap;
align-self: center;
padding: 12px;
padding: 12px 0 12px 12px;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the general designer's idea was to introduce additional whitespace at the right of the conversation, I guess we don't need the right padding of the message bodies

})}
{...(ephemeralCaption && {title: ephemeralCaption})}
aria-label={messageAriaLabel}
className="content-message-wrapper"
Copy link
Contributor Author

@svitovyda svitovyda Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding here className={cx('content-message-wrapper', { 'width': `calc(100% - ${deliveryIndicatorRef?.offsetWidth || 0}px)` })} doesn't work

aria-label={messageAriaLabel}
className="content-message-wrapper"
css={{
width: `calc(100% - ${deliveryIndicatorRef?.offsetWidth || 0}px)`,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried playing with display: flex and overflow etc. and with some of the message content (images, pre) the message was stretching outside of the screen

/>
)}
</div>
<DeliveredIndicator
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option was to add it on the level of the MessageWrapper, but I'm not sure it won't break again the stretching of the message for content like pre, and maybe we will need completely different behaviour for different kinds of messages. Also, it avoids additional div containers

fontWeight: 'var(--font-weight-regular)',
wordWrap: 'normal',
width: 'min-content',
visibility: isLastDeliveredMessage ? 'unset' : 'hidden',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how else to add the empty space of the dynamic width (the width of the translated longest word of "Delivered" plus padding). I guess it is possible to set the width once for all somewhere globally, even set the global right margin for the messages container, and only add one span for the last delivered message.

@@ -274,7 +274,6 @@
// MESSAGE - BODY
.message-body {
position: relative;
padding-right: 40px;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here - we already have one big whitespace at the right, we don't need this one anymore

@tlebon
Copy link
Contributor

tlebon commented Jun 11, 2024

338319899-724d7b8e-951b-4630-8cfe-b66947348f2a
regarding this image you shared -> i think the delivered status should be aligned with the time stamp at the top of longer mesages. (also timestamp should not wrap)

@svitovyda svitovyda force-pushed the feat/delivered-status-WPB-9170 branch from 0e07132 to 37704a7 Compare June 11, 2024 13:06
@codecov-commenter
Copy link

codecov-commenter commented Jun 11, 2024

Codecov Report

Attention: Patch coverage is 76.47059% with 4 lines in your changes missing coverage. Please review.

Project coverage is 46.13%. Comparing base (c0c9c7f) to head (450d23b).
Report is 36 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev   #17553      +/-   ##
==========================================
+ Coverage   46.11%   46.13%   +0.01%     
==========================================
  Files         760      762       +2     
  Lines       25016    25025       +9     
  Branches     5721     5722       +1     
==========================================
+ Hits        11537    11546       +9     
+ Misses      12036    12035       -1     
- Partials     1443     1444       +1     

@svitovyda svitovyda force-pushed the feat/delivered-status-WPB-9170 branch from 09c9a8e to b29dcc4 Compare June 11, 2024 18:38
@svitovyda
Copy link
Contributor Author

338319899-724d7b8e-951b-4630-8cfe-b66947348f2a regarding this image you shared -> i think the delivered status should be aligned with the time stamp at the top of longer mesages. (also timestamp should not wrap)

I now aligned "Delivered" text to the top of the message, and also made the timestamp text nowrap (it was broken before my changes). And aligned the MessageActions to the most right - 16 px.

@svitovyda svitovyda force-pushed the feat/delivered-status-WPB-9170 branch from b29dcc4 to cd20f5a Compare June 11, 2024 18:54
display: 'inline-flex',
alignItems: 'center',
minHeight: '32px',
minWidth: '40px',
position: 'absolute',
right: '16px',
right: `${16 - rightMarginWidth}px`,
Copy link
Contributor Author

@svitovyda svitovyda Jun 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to position reactions menu to look in the old way - 16px from the right of the screen, not of the message container. I can't use position: fixed as I need it only horizontally, and vertically it should still be relative to the parent, to be scrolled. I also tried to play with left: (100vw - 100% - 16px), but 100% is a message container, already resized to the right margin of the MessageList container with margin, so it gives the same result as right: 16px.

@svitovyda svitovyda force-pushed the feat/delivered-status-WPB-9170 branch from cd20f5a to 5127b89 Compare June 12, 2024 09:19
message: ContentMessage;
onClickButton: (message: CompositeMessage, buttonId: string) => void;
onRetry: (message: ContentMessage) => void;
quotedMessage?: ContentMessage;
selfId: QualifiedId;
isMsgElementsFocusable: boolean;
onClickReaction: (emoji: string) => void;
rightMarginWidth: number;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this implementation, rightMarginWidth gets calculated in MessageList and must be used to correctly position MessageActionsMenu (in old way, aligned to the screen, ignoring the new margin). It can be made as a context to not do this long chain-propsing

return (
<>
{rightMarginWidth === 0 && <DeliveredIndicator ref={setDeliveredIndicatorWidth} isLastDeliveredMessage={false} />}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we agree on this approach, it can be modified to

if(rightMarginWidth === 0) return <DeliveredIndicator ref={setDeliveredIndicatorWidth} isLastDeliveredMessage={false} />

return ( ...

to avoid one extra render. Then the MessageList.test must be adjusted to ignore the first render

@@ -121,6 +122,8 @@ export const MessagesList: FC<MessagesListParams> = ({
const [highlightedMessage, setHighlightedMessage] = useState<string | undefined>(conversation.initialMessage()?.id);
const conversationLastReadTimestamp = useRef(conversation.last_read_timestamp());

const [rightMarginWidth, setRightMarginWidth] = useState<number>(0);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also can be ref, to avoid each time getting recalculated and re-rendered all the time, but should be recalculated on the language switch.

@svitovyda svitovyda force-pushed the feat/delivered-status-WPB-9170 branch from 5127b89 to 450d23b Compare June 12, 2024 09:58
@svitovyda svitovyda marked this pull request as ready for review June 12, 2024 09:58
@svitovyda svitovyda requested review from otto-the-bot and a team as code owners June 12, 2024 09:58
Copy link

sonarcloud bot commented Jun 12, 2024

Quality Gate Passed Quality Gate passed

Issues
3 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants