-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a7a7cab
commit 92dea34
Showing
8 changed files
with
179 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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 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,15 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
.mx_RoomList { | ||
height: 100%; | ||
|
||
.mx_RoomList_List { | ||
/* Avoid when on hover, the background color to be on top of the right border */ | ||
padding-right: 1px; | ||
} | ||
} |
This file contains 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,44 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* The RoomCell has the following structure: | ||
* button----------------------------------------| | ||
* | <-12px-> container--------------------------| | ||
* | | room avatar <-12px-> content-----| | ||
* | | | room_name | | ||
* | | | ----------| <-- border | ||
* |---------------------------------------------| | ||
*/ | ||
.mx_RoomListCell { | ||
all: unset; | ||
|
||
&:hover { | ||
background-color: var(--cpd-color-bg-action-secondary-hovered); | ||
} | ||
|
||
.mx_RoomListCell_container { | ||
padding-left: var(--cpd-space-3x); | ||
font: var(--cpd-font-body-md-regular); | ||
height: 100%; | ||
|
||
.mx_RoomListCell_content { | ||
height: 100%; | ||
flex: 1; | ||
/* The border is only under the room name and the future hover menu */ | ||
border-bottom: var(--cpd-border-width-0-5) solid var(--cpd-color-bg-subtle-secondary); | ||
box-sizing: border-box; | ||
min-width: 0; | ||
|
||
span { | ||
white-space: nowrap; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
} | ||
} | ||
} | ||
} |
This file contains 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,51 @@ | ||
/* | ||
* 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, { useCallback, type JSX } from "react"; | ||
import { AutoSizer, List, type ListRowProps } from "react-virtualized"; | ||
|
||
import { type RoomListViewState } from "../../../viewmodels/roomlist/RoomListViewModel"; | ||
import { _t } from "../../../../languageHandler"; | ||
import { RoomListCell } from "./RoomListCell"; | ||
|
||
interface RoomListProps { | ||
vm: RoomListViewState; | ||
} | ||
|
||
export function RoomList({ vm: { rooms } }: RoomListProps): JSX.Element { | ||
const roomRendererMemoized = useCallback( | ||
({ key, index, style }: ListRowProps) => ( | ||
<RoomListCell | ||
room={rooms[index]} | ||
key={key} | ||
style={style} | ||
onClick={() => { | ||
// TODO call view model to select room | ||
}} | ||
/> | ||
), | ||
[rooms], | ||
); | ||
|
||
return ( | ||
<div className="mx_RoomList"> | ||
<AutoSizer> | ||
{({ height, width }) => ( | ||
<List | ||
aria-label={_t("room_list|list_title")} | ||
className="mx_RoomList_List" | ||
rowRenderer={roomRendererMemoized} | ||
rowCount={rooms.length} | ||
rowHeight={48} | ||
height={height} | ||
width={width} | ||
/> | ||
)} | ||
</AutoSizer> | ||
</div> | ||
); | ||
} |
This file contains 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,44 @@ | ||
/* | ||
* 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, { type JSX } from "react"; | ||
import { type Room } from "matrix-js-sdk/src/matrix"; | ||
|
||
import { _t } from "../../../../languageHandler"; | ||
import { Flex } from "../../../utils/Flex"; | ||
import DecoratedRoomAvatar from "../../avatars/DecoratedRoomAvatar"; | ||
|
||
interface RoomListCellProps extends React.HTMLAttributes<HTMLButtonElement> { | ||
/** | ||
* The room to display | ||
*/ | ||
room: Room; | ||
} | ||
|
||
/** | ||
* A cell in the room list | ||
*/ | ||
export function RoomListCell({ room, ...props }: RoomListCellProps): JSX.Element { | ||
return ( | ||
<button | ||
className="mx_RoomListCell" | ||
type="button" | ||
aria-label={_t("room_list|room|open_room", { roomName: room.name })} | ||
{...props} | ||
> | ||
{/* We need this extra div between the button and the content in order to add a padding which is not messing with the virtualized list */} | ||
<Flex className="mx_RoomListCell_container" gap="var(--cpd-space-3x)" align="center"> | ||
<DecoratedRoomAvatar room={room} size="32px" /> | ||
<Flex className="mx_RoomListCell_content" align="center"> | ||
{/* We truncate the room name when too long. Title here is to show the full name on hover */} | ||
<span title={room.name}>{room.name}</span> | ||
{/* Future hover menu et notification badges */} | ||
</Flex> | ||
</Flex> | ||
</button> | ||
); | ||
} |
This file contains 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 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,17 @@ | ||
/* | ||
* 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, { type JSX } from "react"; | ||
|
||
import { useRoomListViewModel } from "../../../viewmodels/roomlist/RoomListViewModel"; | ||
import { RoomList } from "./RoomList"; | ||
|
||
export function RoomListView(): JSX.Element { | ||
const vm = useRoomListViewModel(); | ||
// Room filters will be added soon | ||
return <RoomList vm={vm} />; | ||
} |
This file contains 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