Use tooltip compound in ReadReceiptPerson
component
This commit is contained in:
parent
dbe00e5889
commit
25fa1238ec
1 changed files with 32 additions and 47 deletions
|
@ -23,12 +23,10 @@ import { IReadReceiptProps } from "./EventTile";
|
|||
import AccessibleButton from "../elements/AccessibleButton";
|
||||
import MemberAvatar from "../avatars/MemberAvatar";
|
||||
import AutoHideScrollbar from "../../structures/AutoHideScrollbar";
|
||||
import { Alignment } from "../elements/Tooltip";
|
||||
import { formatDate } from "../../../DateUtils";
|
||||
import { Action } from "../../../dispatcher/actions";
|
||||
import dis from "../../../dispatcher/dispatcher";
|
||||
import ContextMenu, { aboveLeftOf, MenuItem, useContextMenu } from "../../structures/ContextMenu";
|
||||
import { useTooltip } from "../../../utils/useTooltip";
|
||||
import { _t } from "../../../languageHandler";
|
||||
import { useRovingTabIndex } from "../../../accessibility/RovingTabIndex";
|
||||
import { formatList } from "../../../utils/FormattingUtils";
|
||||
|
@ -219,53 +217,40 @@ function ReadReceiptPerson({
|
|||
isTwelveHour,
|
||||
onAfterClick,
|
||||
}: ReadReceiptPersonProps): JSX.Element {
|
||||
const [{ showTooltip, hideTooltip }, tooltip] = useTooltip({
|
||||
alignment: Alignment.Top,
|
||||
tooltipClassName: "mx_ReadReceiptGroup_person--tooltip",
|
||||
label: (
|
||||
<>
|
||||
<div className="mx_Tooltip_title">{roomMember?.rawDisplayName ?? userId}</div>
|
||||
<div className="mx_Tooltip_sub">{userId}</div>
|
||||
</>
|
||||
),
|
||||
});
|
||||
|
||||
return (
|
||||
<MenuItem
|
||||
className="mx_ReadReceiptGroup_person"
|
||||
onClick={() => {
|
||||
dis.dispatch({
|
||||
action: Action.ViewUser,
|
||||
// XXX: We should be using a real member object and not assuming what the receiver wants.
|
||||
// The ViewUser action leads to the RightPanelStore, and RightPanelStoreIPanelState defines the
|
||||
// member property of IRightPanelCardState as `RoomMember | User`, so we’re fine for now, but we
|
||||
// should definitely clean this up later
|
||||
member: roomMember ?? ({ userId } as User),
|
||||
push: false,
|
||||
});
|
||||
onAfterClick?.();
|
||||
}}
|
||||
onMouseOver={showTooltip}
|
||||
onMouseLeave={hideTooltip}
|
||||
onFocus={showTooltip}
|
||||
onBlur={hideTooltip}
|
||||
onWheel={hideTooltip}
|
||||
>
|
||||
<MemberAvatar
|
||||
member={roomMember}
|
||||
fallbackUserId={userId}
|
||||
size="24px"
|
||||
aria-hidden="true"
|
||||
aria-live="off"
|
||||
resizeMethod="crop"
|
||||
hideTitle
|
||||
/>
|
||||
<div className="mx_ReadReceiptGroup_name">
|
||||
<p>{roomMember?.name ?? userId}</p>
|
||||
<p className="mx_ReadReceiptGroup_secondary">{formatDate(new Date(ts), isTwelveHour)}</p>
|
||||
<Tooltip label={roomMember?.rawDisplayName ?? userId} caption={userId} placement="top">
|
||||
<div>
|
||||
<MenuItem
|
||||
className="mx_ReadReceiptGroup_person"
|
||||
onClick={() => {
|
||||
dis.dispatch({
|
||||
action: Action.ViewUser,
|
||||
// XXX: We should be using a real member object and not assuming what the receiver wants.
|
||||
// The ViewUser action leads to the RightPanelStore, and RightPanelStoreIPanelState defines the
|
||||
// member property of IRightPanelCardState as `RoomMember | User`, so we’re fine for now, but we
|
||||
// should definitely clean this up later
|
||||
member: roomMember ?? ({ userId } as User),
|
||||
push: false,
|
||||
});
|
||||
onAfterClick?.();
|
||||
}}
|
||||
>
|
||||
<MemberAvatar
|
||||
member={roomMember}
|
||||
fallbackUserId={userId}
|
||||
size="24px"
|
||||
aria-hidden="true"
|
||||
aria-live="off"
|
||||
resizeMethod="crop"
|
||||
hideTitle
|
||||
/>
|
||||
<div className="mx_ReadReceiptGroup_name">
|
||||
<p>{roomMember?.name ?? userId}</p>
|
||||
<p className="mx_ReadReceiptGroup_secondary">{formatDate(new Date(ts), isTwelveHour)}</p>
|
||||
</div>
|
||||
</MenuItem>
|
||||
</div>
|
||||
{tooltip}
|
||||
</MenuItem>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue