Skip to content

Commit

Permalink
[web] fix user profile long username bug
Browse files Browse the repository at this point in the history
Summary:
This diff fixes the bug where we had text overflow with longer usernames. To address this I introduced a version of `SingleLine` for `web`.

For context here is the `native` version of `SingleLine`
https://github.com/CommE2E/comm/blob/master/native/components/single-line.react.js

Linear task: https://linear.app/comm/issue/ENG-5372/fix-user-profiles-for-long-usernames

Test Plan:
Please see screenshots below

Before:
{F837885}

after:
{F837886}

Reviewers: atul, inka

Reviewed By: atul

Subscribers: ted, ashoat, tomek, wyilio

Differential Revision: https://phab.comm.dev/D9604
  • Loading branch information
ginsueddy committed Oct 26, 2023
1 parent 2957186 commit 10bd397
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
5 changes: 5 additions & 0 deletions web/components/single-line.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.singleLine {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
25 changes: 25 additions & 0 deletions web/components/single-line.react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// @flow

import classNames from 'classnames';
import * as React from 'react';

import { firstLine } from 'lib/utils/string-utils.js';

import css from './single-line.css';

type Props = {
+children: string,
+className?: string,
};

function SingleLine(props: Props): React.Node {
const { children, className } = props;

const text = firstLine(children);

const singleLineClassName = classNames([css.singleLine, className]);

return <div className={singleLineClassName}>{text}</div>;
}

export default SingleLine;
3 changes: 2 additions & 1 deletion web/modals/user-profile/user-profile.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
}

.usernameContainer {
padding-left: 16px;
margin-left: 16px;
overflow: hidden;
}

.usernameText {
Expand Down
3 changes: 2 additions & 1 deletion web/modals/user-profile/user-profile.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import UserProfileActionButtons from './user-profile-action-buttons.react.js';
import UserProfileAvatarModal from './user-profile-avatar-modal.react.js';
import css from './user-profile.css';
import UserAvatar from '../../avatars/user-avatar.react.js';
import SingleLine from '../../components/single-line.react.js';

type Props = {
+userInfo: ?UserInfo,
Expand Down Expand Up @@ -65,7 +66,7 @@ function UserProfile(props: Props): React.Node {
<UserAvatar userID={userInfo?.id} size="L" />
</div>
<div className={css.usernameContainer}>
<div className={css.usernameText}>{usernameText}</div>
<SingleLine className={css.usernameText}>{usernameText}</SingleLine>
<div
className={css.copyUsernameContainer}
onClick={onClickCopyUsername}
Expand Down

0 comments on commit 10bd397

Please sign in to comment.