-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Add decline button to call notification toast (use new notification event) #30729
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
Merged
Merged
Changes from 19 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b0ee860
Add decline button to call notification toast (use new notification e…
toger5 98ed499
update styling for call toast
toger5 1f16f47
skip lobby on join button click / dont skip lobby on toast click
toger5 76e91c8
dismiss toast on remote decline
toger5 4989ba8
fixup docstring and event_id
toger5 cb52261
Add tests
toger5 06200ae
remove unused var
toger5 1ca4308
test that decline event gets sent
toger5 dd89107
make "go to lobby" accessible via keyboard (fix sonar cloud)
toger5 9f3aedd
remove keyboard input
toger5 544e28a
fix lint
toger5 4ab5fc1
use actual button
toger5 ee7209e
review style + toggle for join immediately
toger5 4d4ff24
fix `getNotificationEventSendTs`
toger5 62923a7
use story component
toger5 0241577
english text
toger5 cd0ba80
dont use legacy toggle
toger5 67bddb2
fix lint
toger5 b6fe854
review
toger5 09ca013
review (mostly docs)
toger5 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+9.51 KB
playwright/shared-component-snapshots/avatar-avatarwithdetails--default-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/shared-components/avatar/AvatarWithDetails/AvatarWithDetails.module.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* | ||
| * Copyright 2025 New Vector Ltd. | ||
| * | ||
| * SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial | ||
| * Please see LICENSE files in the repository root for full details. | ||
| */ | ||
|
|
||
| .avatarWithDetails { | ||
| display: flex; | ||
| align-items: center; | ||
|
|
||
| border-radius: 12px; | ||
| background-color: var(--cpd-color-gray-200); | ||
| padding: var(--cpd-space-2x); | ||
| gap: var(--cpd-space-2x); | ||
|
|
||
| .title { | ||
| display: inline-block; | ||
|
|
||
| font-weight: var(--cpd-font-weight-semibold); | ||
| font-size: var(--cpd-font-size-body-md); | ||
|
|
||
| overflow: hidden; | ||
| text-overflow: ellipsis; | ||
| white-space: nowrap; | ||
| } | ||
|
|
||
| .details { | ||
| font-size: var(--cpd-font-size-body-sm); | ||
| } | ||
| } |
26 changes: 26 additions & 0 deletions
26
src/shared-components/avatar/AvatarWithDetails/AvatarWithDetails.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /* | ||
| * Copyright 2025 New Vector Ltd. | ||
| * | ||
| * SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial | ||
| * Please see LICENSE files in the repository root for full details. | ||
| */ | ||
|
|
||
| import React from "react"; | ||
|
|
||
| import { AvatarWithDetails } from "./AvatarWithDetails"; | ||
| import type { Meta, StoryFn } from "@storybook/react-vite"; | ||
|
|
||
| export default { | ||
| title: "Avatar/AvatarWithDetails", | ||
| component: AvatarWithDetails, | ||
| tags: ["autodocs"], | ||
| args: { | ||
| avatar: <div style={{ width: 40, height: 40, backgroundColor: "#888", borderRadius: "50%" }} />, | ||
| details: "Details about the avatar go here", | ||
| title: "Room Name", | ||
| }, | ||
| } as Meta<typeof AvatarWithDetails>; | ||
|
|
||
| const Template: StoryFn<typeof AvatarWithDetails> = (args) => <AvatarWithDetails {...args} />; | ||
|
|
||
| export const Default = Template.bind({}); | ||
21 changes: 21 additions & 0 deletions
21
src/shared-components/avatar/AvatarWithDetails/AvatarWithDetails.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /* | ||
| Copyright 2025 New Vector Ltd. | ||
|
|
||
| SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial | ||
| Please see LICENSE files in the repository root for full details. | ||
| */ | ||
|
|
||
| import { composeStories } from "@storybook/react-vite"; | ||
| import { render } from "jest-matrix-react"; | ||
| import React from "react"; | ||
|
|
||
| import * as stories from "./AvatarWithDetails.stories.tsx"; | ||
|
|
||
| const { Default } = composeStories(stories); | ||
|
|
||
| describe("AvatarWithDetails", () => { | ||
| it("renders a textual event", () => { | ||
| const { container } = render(<Default />); | ||
| expect(container).toMatchSnapshot(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The snapshot looks very slightly odd with huge whitespace height, but maybe that's normal. Not a blocker, just wonder how that happened 😆 |
||
| }); | ||
| }); | ||
58 changes: 58 additions & 0 deletions
58
src/shared-components/avatar/AvatarWithDetails/AvatarWithDetails.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| /* | ||
| * Copyright 2025 New Vector Ltd. | ||
| * | ||
| * SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial | ||
| * Please see LICENSE files in the repository root for full details. | ||
| */ | ||
|
|
||
| import { type ComponentProps, type ElementType, type JSX, type PropsWithChildren } from "react"; | ||
| import React from "react"; | ||
| import classNames from "classnames"; | ||
|
|
||
| import styles from "./AvatarWithDetails.module.css"; | ||
| import { Flex } from "../../utils/Flex"; | ||
|
|
||
| export type AvatarWithDetailsProps<C extends ElementType> = { | ||
| /** | ||
| * The HTML tag. | ||
| * @default "div" | ||
| */ | ||
| as?: C; | ||
| /** | ||
| * The CSS class name. | ||
| */ | ||
| className?: string; | ||
| title: string; | ||
| avatar: React.ReactNode; | ||
| details: React.ReactNode; | ||
toger5 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } & ComponentProps<C>; | ||
|
|
||
| /** | ||
| * A component to display the body of a media message. | ||
toger5 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * | ||
| * @example | ||
| * ```tsx | ||
| * <AvatarWithDetails title="Room Name" details="10 participants" className="custom-class" /> | ||
| * ``` | ||
| */ | ||
| export function AvatarWithDetails<C extends React.ElementType = "div">({ | ||
| as, | ||
| className, | ||
| details, | ||
| avatar, | ||
| title, | ||
| ...props | ||
| }: PropsWithChildren<AvatarWithDetailsProps<C>>): JSX.Element { | ||
| const Component = as || "div"; | ||
|
|
||
| // Keep Mx_MediaBody to support the compatibility with existing timeline and the all the layout | ||
toger5 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return ( | ||
| <Component className={classNames(styles.avatarWithDetails, className)} {...props}> | ||
| {avatar} | ||
| <Flex direction="column"> | ||
| <span className={styles.title}>{title}</span> | ||
| <span className={styles.details}>{details}</span> | ||
| </Flex> | ||
| </Component> | ||
| ); | ||
| } | ||
28 changes: 28 additions & 0 deletions
28
src/shared-components/avatar/AvatarWithDetails/__snapshots__/AvatarWithDetails.test.tsx.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`AvatarWithDetails renders a textual event 1`] = ` | ||
| <div> | ||
| <div | ||
| class="avatarWithDetails" | ||
| > | ||
| <div | ||
| style="width: 40px; height: 40px; background-color: rgb(136, 136, 136); border-radius: 50%;" | ||
| /> | ||
| <div | ||
| class="flex" | ||
| style="--mx-flex-display: flex; --mx-flex-direction: column; --mx-flex-align: start; --mx-flex-justify: start; --mx-flex-gap: 0; --mx-flex-wrap: nowrap;" | ||
| > | ||
| <span | ||
| class="title" | ||
| > | ||
| Room Name | ||
| </span> | ||
| <span | ||
| class="details" | ||
| > | ||
| Details about the avatar go here | ||
| </span> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| /* | ||
| * Copyright 2025 New Vector Ltd. | ||
| * | ||
| * SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial | ||
| * Please see LICENSE files in the repository root for full details. | ||
| */ | ||
|
|
||
| export { AvatarWithDetails } from "./AvatarWithDetails"; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.