-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Move EventTileBubble to shared components #31911
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
Open
rbondesson
wants to merge
12
commits into
element-hq:develop
Choose a base branch
from
ZacksBot:refactor/event-tile-bubble
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+410
−162
Open
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ce7796e
Move EventTileBubble to shared components as is
rbondesson 77cc843
Added documentation and updated stories and unit tests
rbondesson efed0ce
Merge branch 'develop' of https://github.com/ZacksBot/element-web int…
rbondesson 051bed0
Merge remote-tracking branch 'origin/develop' into refactor/event-til…
rbondesson bc839e5
Move 'global' element web css to _common.pcss
rbondesson 9651ce7
Adding playwright snapshots
rbondesson 5c1966a
Updated comments
rbondesson f135f23
Merge branch 'element-hq:develop' into refactor/event-tile-bubble
rbondesson 04dca2e
Added legacy mx_MessageTimestamp class and updated snapshots
rbondesson edc6f99
Regenerate snapshots with correct hash
rbondesson cf015c1
Merge remote-tracking branch 'origin/develop' into refactor/event-til…
rbondesson 90040dc
Changes to css and removed timestamp from properties after review.
rbondesson 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
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
Binary file added
BIN
+6.68 KB
...ines__/event-tiles/EventTileBubble/EventTileBubble.stories.tsx/default-auto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.41 KB
..._/event-tiles/EventTileBubble/EventTileBubble.stories.tsx/has-children-auto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.59 KB
...-tiles/EventTileBubble/EventTileBubble.stories.tsx/has-lock-solid-icon-auto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.34 KB
...EventTileBubble/EventTileBubble.stories.tsx/has-timestamp-and-children-auto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.62 KB
.../event-tiles/EventTileBubble/EventTileBubble.stories.tsx/has-timestamp-auto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.6 KB
...les/EventTileBubble/EventTileBubble.stories.tsx/is-crypto-event-bubble-auto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions
59
packages/shared-components/src/event-tiles/EventTileBubble/EventTileBubble.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,59 @@ | ||
| /* | ||
| * Copyright 2026 Element Creations 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. | ||
| */ | ||
|
|
||
| .container { | ||
| background-color: var(--cpd-color-bg-subtle-secondary); | ||
| padding: 10px; | ||
rbondesson marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| border-radius: 8px; | ||
| /* Reserve space for external timestamps, but also cap the width */ | ||
| /* Legacy variable: --MessageTimestamp-width: 46px; /* 8 + 30 (avatar) + 8 */ | ||
| /* max-width: min(calc(100% - 2 * var(--MessageTimestamp-width)), 600px); */ | ||
| max-width: min(calc(100% - 2 * 46px), 600px); | ||
| box-sizing: border-box; | ||
| display: grid; | ||
| grid-template-columns: 24px minmax(0, 1fr) min-content min-content; | ||
|
|
||
| svg { | ||
| position: relative; | ||
| grid-column: 1; | ||
| grid-row: 1 / 3; | ||
| width: 16px; | ||
| height: 16px; | ||
| content: ""; | ||
| inset: 0; | ||
| mask-repeat: no-repeat; | ||
| mask-position: center; | ||
| mask-size: contain; | ||
| margin-top: var(--cpd-space-1x); | ||
| } | ||
|
|
||
| .title, | ||
| .subtitle { | ||
| grid-column: 2; | ||
| overflow-wrap: break-word; | ||
| min-inline-size: 50px; | ||
| } | ||
|
|
||
| .title { | ||
| font-weight: var(--cpd-font-weight-semibold); | ||
| font-size: var(--cpd-font-size-body-md); | ||
| grid-row: 1; | ||
| } | ||
|
|
||
| .subtitle { | ||
| font-size: var(--cpd-font-size-body-sm); | ||
| grid-row: 2; | ||
| } | ||
|
|
||
| /* Keep mx_MessageTimestamp to preserve compatibility with the existing timeline layouts. */ | ||
| .mx_MessageTimestamp { | ||
| grid-column: 4; | ||
| grid-row: 1 / 3; | ||
| align-self: center; | ||
| margin-left: var(--cpd-space-4x); | ||
| } | ||
| } | ||
74 changes: 74 additions & 0 deletions
74
packages/shared-components/src/event-tiles/EventTileBubble/EventTileBubble.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,74 @@ | ||
| /* | ||
| * Copyright 2026 Element Creations 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 { LockSolidIcon, ErrorSolidIcon } from "@vector-im/compound-design-tokens/assets/web/icons"; | ||
| import { Tooltip } from "@vector-im/compound-web"; | ||
|
|
||
| import type { Meta, StoryFn } from "@storybook/react-vite"; | ||
| import { EventTileBubble } from "./EventTileBubble"; | ||
|
|
||
| export default { | ||
| title: "Event/EventTileBubble", | ||
| component: EventTileBubble, | ||
| tags: ["autodocs"], | ||
| args: { | ||
| icon: <ErrorSolidIcon />, | ||
| title: "Title goes here", | ||
| subtitle: "Subtitle goes here", | ||
| className: "custom-class", | ||
| }, | ||
| } as Meta<typeof EventTileBubble>; | ||
|
|
||
| const Template: StoryFn<typeof EventTileBubble> = (args) => <EventTileBubble {...args} />; | ||
|
|
||
| export const Default = Template.bind({}); | ||
|
|
||
| export const HasLockSolidIcon = Template.bind({}); | ||
| HasLockSolidIcon.args = { | ||
| className: undefined, | ||
| icon: <LockSolidIcon />, | ||
| timestamp: undefined, | ||
| children: undefined, | ||
| }; | ||
|
|
||
| export const HasChildren = Template.bind({}); | ||
| HasChildren.args = { | ||
| className: undefined, | ||
| timestamp: undefined, | ||
| children: <div>children</div>, | ||
| }; | ||
|
|
||
| export const HasTimestamp = Template.bind({}); | ||
| HasTimestamp.args = { | ||
| className: undefined, | ||
| timestamp: <div>timestamp</div>, | ||
| children: undefined, | ||
| }; | ||
|
|
||
| export const HasTimestampAndChildren = Template.bind({}); | ||
| HasTimestampAndChildren.args = { | ||
| className: undefined, | ||
| timestamp: <div>timestamp</div>, | ||
| children: <div>children</div>, | ||
| }; | ||
|
|
||
| export const IsCryptoEventBubble = Template.bind({}); | ||
| IsCryptoEventBubble.args = { | ||
| className: undefined, | ||
| icon: <LockSolidIcon />, | ||
| title: "Encryption enabled", | ||
| subtitle: "Messages here are end-to-end encrypted. Verify XYZ in their profile - tap on their profile picture.", | ||
| timestamp: undefined, | ||
| children: ( | ||
| <Tooltip description="Thu, 17 Nov 2022, 4:58:32 pm"> | ||
| <span aria-hidden={true} aria-live="off"> | ||
| 04:58 | ||
| </span> | ||
| </Tooltip> | ||
| ), | ||
| }; |
48 changes: 48 additions & 0 deletions
48
packages/shared-components/src/event-tiles/EventTileBubble/EventTileBubble.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,48 @@ | ||
| /* | ||
| * Copyright 2025 New Vector Ltd. | ||
rbondesson marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * | ||
| * 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 { render } from "@test-utils"; | ||
| import { composeStories } from "@storybook/react-vite"; | ||
| import { describe, it, expect } from "vitest"; | ||
| import React from "react"; | ||
|
|
||
| import * as stories from "./EventTileBubble.stories.tsx"; | ||
|
|
||
| const { Default, HasLockSolidIcon, HasChildren, HasTimestamp, HasTimestampAndChildren, IsCryptoEventBubble } = | ||
| composeStories(stories); | ||
|
|
||
| describe("EventTileBubble", () => { | ||
| it("renders the event tile bubble", () => { | ||
| const { container } = render(<Default />); | ||
| expect(container).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| it("renders the event tile bubble with icon", () => { | ||
| const { container } = render(<HasLockSolidIcon />); | ||
| expect(container).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| it("renders the event tile bubble with children", () => { | ||
| const { container } = render(<HasChildren />); | ||
| expect(container).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| it("renders the event tile bubble with timestamp", () => { | ||
| const { container } = render(<HasTimestamp />); | ||
| expect(container).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| it("renders the event tile bubble with timestamp and children", () => { | ||
| const { container } = render(<HasTimestampAndChildren />); | ||
| expect(container).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| it("renders the event tile bubble as crypto event bubble", () => { | ||
| const { container } = render(<IsCryptoEventBubble />); | ||
| expect(container).toMatchSnapshot(); | ||
| }); | ||
| }); | ||
71 changes: 71 additions & 0 deletions
71
packages/shared-components/src/event-tiles/EventTileBubble/EventTileBubble.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,71 @@ | ||
| /* | ||
| * Copyright 2026 Element Creations 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, { type JSX, type ReactNode } from "react"; | ||
| import classNames from "classnames"; | ||
|
|
||
| import styles from "./EventTileBubble.module.css"; | ||
|
|
||
| export interface EventTileBubbleProps { | ||
| /** | ||
| * Icon rendered at the start of the bubble. | ||
| */ | ||
| icon: JSX.Element; | ||
| /** | ||
| * Main title text for the bubble. | ||
| */ | ||
| title: string; | ||
| /** | ||
| * Optional subtitle rendered beneath the title. | ||
| */ | ||
| subtitle?: ReactNode; | ||
| /** | ||
| * Optional extra class name for the container. | ||
| */ | ||
| className?: string; | ||
| /** | ||
| * Optional timestamp element rendered at the end of the bubble. | ||
| */ | ||
| timestamp?: JSX.Element; | ||
| /** | ||
| * Optional children rendered between subtitle and timestamp. | ||
| */ | ||
| children?: JSX.Element; | ||
| /** | ||
| * Forwarded ref for the container element. | ||
| */ | ||
| ref?: React.RefObject<any>; | ||
rbondesson marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| /** | ||
| * EventTileBubble renders a compact event tile with an icon, title, and optional subtitle/content. | ||
| * | ||
| * @example | ||
| * ```tsx | ||
| * <EventTileBubble icon={<Icon />} title="Room created" /> | ||
| * ``` | ||
| */ | ||
| export function EventTileBubble({ | ||
| icon, | ||
| title, | ||
| subtitle, | ||
| className, | ||
| timestamp, | ||
| children, | ||
| ref, | ||
| }: EventTileBubbleProps): JSX.Element { | ||
| // Keep mx_EventTileBubble to preserve compatibility with the existing timeline layouts. | ||
| return ( | ||
| <div className={classNames("mx_EventTileBubble", styles.container, className)} ref={ref}> | ||
rbondesson marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| {icon} | ||
| <div className={styles.title}>{title}</div> | ||
| {subtitle && <div className={styles.subtitle}>{subtitle}</div>} | ||
| {children} | ||
| {timestamp} | ||
rbondesson marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </div> | ||
| ); | ||
| } | ||
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.