Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 2f2295f

Browse files
committed
Use compound tooltip and icon button
1 parent 5a1e5d0 commit 2f2295f

File tree

3 files changed

+47
-32
lines changed

3 files changed

+47
-32
lines changed

res/css/structures/_ThreadsActivityCentre.pcss

+11-8
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,25 @@
1717
*/
1818

1919
.mx_ThreadsActivityCentreButton {
20-
color: $secondary-content;
21-
height: 32px;
22-
min-width: 32px;
23-
display: flex;
24-
align-items: center;
25-
justify-content: center;
2620
border-radius: 8px;
2721
margin: 18px auto auto auto;
2822

2923
&.expanded {
3024
/* align with settings icon */
31-
margin-left: 25px;
25+
margin-left: 22px;
3226

33-
& > .mx_ThreadsActivityCentreButton_IndicatorIcon {
27+
& > div {
28+
display: flex;
29+
}
30+
31+
& .mx_ThreadsActivityCentreButton_Icon {
3432
/* align with settings label */
3533
margin-right: 14px;
34+
min-width: 24px;
35+
}
36+
37+
& .mx_ThreadsActivityCentreButton_Text {
38+
color: $secondary-content;
3639
}
3740
}
3841

src/components/views/spaces/threads-activity-centre/ThreadsActivityCentre.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export function ThreadsActivityCentre({ displayButtonLabel }: ThreadsActivityCen
6464
<ThreadsActivityCentreButton
6565
displayLabel={displayButtonLabel}
6666
notificationLevel={roomsAndNotifications.greatestNotificationLevel}
67+
disableTooltip={open}
6768
/>
6869
}
6970
>

src/components/views/spaces/threads-activity-centre/ThreadsActivityCentreButton.tsx

+35-24
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@
1919
import React, { forwardRef, HTMLProps } from "react";
2020
import { Icon } from "@vector-im/compound-design-tokens/icons/threads-solid.svg";
2121
import classNames from "classnames";
22-
import { IndicatorIcon } from "@vector-im/compound-web";
22+
import { IconButton, Text, Tooltip } from "@vector-im/compound-web";
2323

2424
import { _t } from "../../../../languageHandler";
25-
import AccessibleTooltipButton from "../../elements/AccessibleTooltipButton";
2625
import { NotificationLevel } from "../../../../stores/notifications/NotificationLevel";
27-
import { notificationLevelToIndicator } from "../../../../utils/notifications";
2826

2927
interface ThreadsActivityCentreButtonProps extends HTMLProps<HTMLDivElement> {
3028
/**
@@ -35,35 +33,48 @@ interface ThreadsActivityCentreButtonProps extends HTMLProps<HTMLDivElement> {
3533
* The notification level of the threads.
3634
*/
3735
notificationLevel: NotificationLevel;
36+
/**
37+
* Whether to disable the tooltip.
38+
*/
39+
disableTooltip?: boolean;
3840
}
3941

4042
/**
4143
* A button to open the thread activity centre.
4244
*/
4345
export const ThreadsActivityCentreButton = forwardRef<HTMLDivElement, ThreadsActivityCentreButtonProps>(
44-
function ThreadsActivityCentreButton({ displayLabel, notificationLevel, ...props }, ref): React.JSX.Element {
46+
function ThreadsActivityCentreButton(
47+
{ displayLabel, notificationLevel, disableTooltip = false, ...props },
48+
ref,
49+
): React.JSX.Element {
50+
const openTooltip = displayLabel || disableTooltip ? false : undefined;
51+
4552
return (
46-
<AccessibleTooltipButton
47-
className={classNames("mx_ThreadsActivityCentreButton", { expanded: displayLabel })}
48-
title={_t("common|threads")}
49-
// @ts-ignore
50-
// ref nightmare...
51-
ref={ref}
52-
forceHide={displayLabel}
53-
aria-expanded={displayLabel}
54-
// The compound component Menu is already handling the keyboard events
55-
disableKeyboardOverrides={true}
56-
{...props}
57-
>
58-
<IndicatorIcon
59-
className="mx_ThreadsActivityCentreButton_IndicatorIcon"
60-
indicator={notificationLevelToIndicator(notificationLevel)}
61-
size="24px"
53+
<Tooltip label={_t("common|threads")} side="right" open={openTooltip}>
54+
<IconButton
55+
className={classNames("mx_ThreadsActivityCentreButton", { expanded: displayLabel })}
56+
// indicator={notificationLevelToIndicator(notificationLevel)}
57+
indicator="critical"
58+
// @ts-ignore
59+
// ref nightmare...
60+
ref={ref}
61+
{...props}
6262
>
63-
<Icon className="mx_ThreadsActivityCentreButton_Icon" />
64-
</IndicatorIcon>
65-
{displayLabel && _t("common|threads")}
66-
</AccessibleTooltipButton>
63+
<>
64+
<Icon className="mx_ThreadsActivityCentreButton_Icon" />
65+
{displayLabel && (
66+
<Text
67+
className="mx_ThreadsActivityCentreButton_Text"
68+
as="span"
69+
size="md"
70+
title={_t("common|threads")}
71+
>
72+
{_t("common|threads")}
73+
</Text>
74+
)}
75+
</>
76+
</IconButton>
77+
</Tooltip>
6778
);
6879
},
6980
);

0 commit comments

Comments
 (0)