diff --git a/res/css/structures/_ThreadsActivityCentre.pcss b/res/css/structures/_ThreadsActivityCentre.pcss index d1ac04162f..7c597d95ea 100644 --- a/res/css/structures/_ThreadsActivityCentre.pcss +++ b/res/css/structures/_ThreadsActivityCentre.pcss @@ -17,22 +17,31 @@ */ .mx_ThreadsActivityCentreButton { - color: $secondary-content; - height: 32px; - min-width: 32px; - display: flex; - align-items: center; - justify-content: center; border-radius: 8px; margin: 18px auto auto auto; &.expanded { /* align with settings icon */ - margin-left: 25px; + margin-left: 21px; - & > .mx_ThreadsActivityCentreButton_IndicatorIcon { + /** + * modify internal css of the compound component + * dirty but we need to add the `Threads` label into the indicator icon button + **/ + & > div { + display: flex; + align-items: center; + } + + & .mx_ThreadsActivityCentreButton_Icon { /* align with settings label */ margin-right: 14px; + /* required to set the icon width when into a flex container */ + min-width: 24px; + } + + & .mx_ThreadsActivityCentreButton_Text { + color: $secondary-content; } } diff --git a/src/components/views/spaces/threads-activity-centre/ThreadsActivityCentreButton.tsx b/src/components/views/spaces/threads-activity-centre/ThreadsActivityCentreButton.tsx index 13478c8c5b..3f85de38fa 100644 --- a/src/components/views/spaces/threads-activity-centre/ThreadsActivityCentreButton.tsx +++ b/src/components/views/spaces/threads-activity-centre/ThreadsActivityCentreButton.tsx @@ -16,17 +16,16 @@ * / */ -import React, { forwardRef, HTMLProps } from "react"; +import React, { ComponentProps, forwardRef } from "react"; import { Icon } from "@vector-im/compound-design-tokens/icons/threads-solid.svg"; import classNames from "classnames"; -import { IndicatorIcon } from "@vector-im/compound-web"; +import { IconButton, Text, Tooltip } from "@vector-im/compound-web"; import { _t } from "../../../../languageHandler"; -import AccessibleTooltipButton from "../../elements/AccessibleTooltipButton"; import { NotificationLevel } from "../../../../stores/notifications/NotificationLevel"; import { notificationLevelToIndicator } from "../../../../utils/notifications"; -interface ThreadsActivityCentreButtonProps extends HTMLProps { +interface ThreadsActivityCentreButtonProps extends ComponentProps { /** * Display the `Treads` label next to the icon. */ @@ -40,28 +39,36 @@ interface ThreadsActivityCentreButtonProps extends HTMLProps { /** * A button to open the thread activity centre. */ -export const ThreadsActivityCentreButton = forwardRef( +export const ThreadsActivityCentreButton = forwardRef( function ThreadsActivityCentreButton({ displayLabel, notificationLevel, ...props }, ref): React.JSX.Element { + // Disable tooltip when the label is displayed + const openTooltip = displayLabel ? false : undefined; + return ( - - + - - - {displayLabel && _t("common|threads")} - + <> + + {/* This is dirty, but we need to add the label to the indicator icon */} + {displayLabel && ( + + {_t("common|threads")} + + )} + + + ); }, ); diff --git a/test/components/views/spaces/ThreadsActivityCentre-test.tsx b/test/components/views/spaces/ThreadsActivityCentre-test.tsx index 8155773e6d..d0a14bd805 100644 --- a/test/components/views/spaces/ThreadsActivityCentre-test.tsx +++ b/test/components/views/spaces/ThreadsActivityCentre-test.tsx @@ -16,10 +16,11 @@ * / */ -import React from "react"; +import React, { ComponentProps } from "react"; import { getByText, render, screen } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import { NotificationCountType, PendingEventOrdering, Room } from "matrix-js-sdk/src/matrix"; +import { TooltipProvider } from "@vector-im/compound-web"; import { ThreadsActivityCentre } from "../../../../src/components/views/spaces/threads-activity-centre"; import { MatrixClientPeg } from "../../../../src/MatrixClientPeg"; @@ -37,12 +38,16 @@ describe("ThreadsActivityCentre", () => { return screen.getByRole("menu"); }; - const renderTAC = () => { + const getTACDescription = () => { + return screen.getByText("Threads"); + }; + + const renderTAC = (props?: ComponentProps) => { render( - - ); + , + { wrapper: TooltipProvider }, ); }; @@ -105,6 +110,12 @@ describe("ThreadsActivityCentre", () => { expect(getTACButton()).toBeInTheDocument(); }); + it("should render the threads activity centre button and the display label", async () => { + renderTAC({ displayButtonLabel: true }); + expect(getTACButton()).toBeInTheDocument(); + expect(getTACDescription()).toBeInTheDocument(); + }); + it("should render the threads activity centre menu when the button is clicked", async () => { renderTAC(); await userEvent.click(getTACButton()); diff --git a/test/components/views/spaces/__snapshots__/ThreadsActivityCentre-test.tsx.snap b/test/components/views/spaces/__snapshots__/ThreadsActivityCentre-test.tsx.snap index d82c7df6d0..a04f80973a 100644 --- a/test/components/views/spaces/__snapshots__/ThreadsActivityCentre-test.tsx.snap +++ b/test/components/views/spaces/__snapshots__/ThreadsActivityCentre-test.tsx.snap @@ -2,7 +2,7 @@ exports[`ThreadsActivityCentre renders notifications matching the snapshot 1`] = `