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

Commit e20b375

Browse files
committed
Add filter results count and explore prompt
1 parent a4d11cc commit e20b375

File tree

6 files changed

+107
-1
lines changed

6 files changed

+107
-1
lines changed

res/css/structures/_LeftPanel.scss

+8
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ $tagPanelWidth: 56px; // only applies in this file, used for calculations
136136
}
137137
}
138138

139+
.mx_LeftPanel_roomListFilterCount {
140+
font-size: $font-13px;
141+
font-weight: 500;
142+
margin-left: 12px;
143+
margin-top: 16px;
144+
margin-bottom: -4px; // to counteract the normal roomListWrapper margin-top
145+
}
146+
139147
.mx_LeftPanel_roomListWrapper {
140148
overflow: hidden;
141149
margin-top: 10px; // so we're not up against the search/filter

res/css/views/rooms/_RoomList.scss

+34
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,37 @@ limitations under the License.
2424
.mx_RoomList_iconExplore::before {
2525
mask-image: url('$(res)/img/element-icons/roomlist/explore.svg');
2626
}
27+
28+
.mx_RoomList_explorePrompt {
29+
margin: 4px 12px 4px;
30+
padding-top: 12px;
31+
border-top: 1px solid #8D99A5;
32+
font-size: $font-13px;
33+
34+
div:first-child {
35+
font-weight: 500;
36+
margin-bottom: 8px;
37+
}
38+
39+
.mx_AccessibleButton {
40+
color: $secondary-fg-color;
41+
position: relative;
42+
margin-left: 24px;
43+
padding: 0;
44+
font-size: inherit;
45+
46+
&::before {
47+
content: '';
48+
width: 16px;
49+
height: 16px;
50+
position: absolute;
51+
top: 0;
52+
left: -24px;
53+
background: $secondary-fg-color;
54+
mask-position: center;
55+
mask-size: contain;
56+
mask-repeat: no-repeat;
57+
mask-image: url('$(res)/img/element-icons/roomlist/explore.svg');
58+
}
59+
}
60+
}

src/components/structures/LeftPanel.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import IndicatorScrollbar from "../structures/IndicatorScrollbar";
3737
import AccessibleTooltipButton from "../views/elements/AccessibleTooltipButton";
3838
import { OwnProfileStore } from "../../stores/OwnProfileStore";
3939
import { MatrixClientPeg } from "../../MatrixClientPeg";
40+
import RoomListNumResults from "../views/rooms/RoomListNumResults";
4041

4142
interface IProps {
4243
isMinimized: boolean;
@@ -409,6 +410,7 @@ export default class LeftPanel extends React.Component<IProps, IState> {
409410
{this.renderHeader()}
410411
{this.renderSearchExplore()}
411412
{this.renderBreadcrumbs()}
413+
<RoomListNumResults />
412414
<div className="mx_LeftPanel_roomListWrapper">
413415
<div
414416
className={roomListClasses}

src/components/views/rooms/RoomList.tsx

+19-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import CustomRoomTagStore from "../../../stores/CustomRoomTagStore";
4444
import { arrayFastClone, arrayHasDiff } from "../../../utils/arrays";
4545
import { objectShallowClone, objectWithOnly } from "../../../utils/objects";
4646
import { IconizedContextMenuOption, IconizedContextMenuOptionList } from "../context_menus/IconizedContextMenu";
47+
import AccessibleButton from "../elements/AccessibleButton";
4748

4849
interface IProps {
4950
onKeyDown: (ev: React.KeyboardEvent) => void;
@@ -278,6 +279,10 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
278279
}
279280
};
280281

282+
private onExplore = () => {
283+
dis.fire(Action.ViewRoomDirectory);
284+
};
285+
281286
private renderCommunityInvites(): TemporaryTile[] {
282287
// TODO: Put community invites in a more sensible place (not in the room list)
283288
// See https://github.com/vector-im/element-web/issues/14456
@@ -359,6 +364,16 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
359364
}
360365

361366
public render() {
367+
let explorePrompt: JSX.Element;
368+
if (RoomListStore.instance.getFirstNameFilterCondition()) {
369+
explorePrompt = <div className="mx_RoomList_explorePrompt">
370+
<div>{_t("Can't see what you’re looking for?")}</div>
371+
<AccessibleButton kind="link" onClick={this.onExplore}>
372+
{_t("Explore all public rooms")}
373+
</AccessibleButton>
374+
</div>;
375+
}
376+
362377
const sublists = this.renderSublists();
363378
return (
364379
<RovingTabIndexProvider handleHomeEnd={true} onKeyDown={this.props.onKeyDown}>
@@ -370,7 +385,10 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
370385
className="mx_RoomList"
371386
role="tree"
372387
aria-label={_t("Rooms")}
373-
>{sublists}</div>
388+
>
389+
{sublists}
390+
{explorePrompt}
391+
</div>
374392
)}
375393
</RovingTabIndexProvider>
376394
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
Copyright 2020 The Matrix.org Foundation C.I.C.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
import React, {useState} from "react";
18+
19+
import { _t } from "../../../languageHandler";
20+
import RoomListStore, { LISTS_UPDATE_EVENT } from "../../../stores/room-list/RoomListStore";
21+
import {useEventEmitter} from "../../../hooks/useEventEmitter";
22+
23+
const RoomListNumResults: React.FC = () => {
24+
const [count, setCount] = useState<number>(null);
25+
useEventEmitter(RoomListStore.instance, LISTS_UPDATE_EVENT, () => {
26+
if (RoomListStore.instance.getFirstNameFilterCondition()) {
27+
const numRooms = Object.values(RoomListStore.instance.orderedLists).flat(1).length;
28+
setCount(numRooms);
29+
} else {
30+
setCount(null);
31+
}
32+
});
33+
34+
if (typeof count !== "number") return null;
35+
36+
return <div className="mx_LeftPanel_roomListFilterCount">
37+
{_t("%(count)s results", { count })}
38+
</div>;
39+
};
40+
41+
export default RoomListNumResults;

src/i18n/strings/en_EN.json

+3
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,9 @@
11201120
"System Alerts": "System Alerts",
11211121
"Historical": "Historical",
11221122
"Custom Tag": "Custom Tag",
1123+
"Can't see what you’re looking for?": "Can't see what you’re looking for?",
1124+
"Explore all public rooms": "Explore all public rooms",
1125+
"%(count)s results|other": "%(count)s results",
11231126
"This room": "This room",
11241127
"Joining room …": "Joining room …",
11251128
"Loading …": "Loading …",

0 commit comments

Comments
 (0)