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

Commit 81c4ef3

Browse files
committed
Add reusable empty state for the right panel
Signed-off-by: Michael Telatynski <[email protected]>
1 parent 39d453a commit 81c4ef3

File tree

11 files changed

+140
-222
lines changed

11 files changed

+140
-222
lines changed

res/css/_components.pcss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
@import "./structures/_MatrixChat.pcss";
7474
@import "./structures/_MessagePanel.pcss";
7575
@import "./structures/_NonUrgentToastContainer.pcss";
76-
@import "./structures/_NotificationPanel.pcss";
7776
@import "./structures/_QuickSettingsButton.pcss";
7877
@import "./structures/_RightPanel.pcss";
7978
@import "./structures/_RoomSearch.pcss";
@@ -259,6 +258,7 @@
259258
@import "./views/polls/pollHistory/_PollHistory.pcss";
260259
@import "./views/polls/pollHistory/_PollHistoryList.pcss";
261260
@import "./views/right_panel/_BaseCard.pcss";
261+
@import "./views/right_panel/_EmptyState.pcss";
262262
@import "./views/right_panel/_EncryptionInfo.pcss";
263263
@import "./views/right_panel/_PinnedMessagesCard.pcss";
264264
@import "./views/right_panel/_RightPanelTabs.pcss";

res/css/structures/_FilePanel.pcss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,3 @@ limitations under the License.
102102
padding-inline-start: 0;
103103
}
104104
}
105-
106-
.mx_FilePanel_empty::before {
107-
--maskImage: url("$(res)/img/element-icons/room/files.svg"); /* See: _RightPanel.pcss */
108-
}

res/css/structures/_NotificationPanel.pcss

Lines changed: 0 additions & 19 deletions
This file was deleted.

res/css/structures/_RightPanel.pcss

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -72,30 +72,3 @@ limitations under the License.
7272
order: 2;
7373
margin: auto;
7474
}
75-
76-
.mx_RightPanel_empty {
77-
margin-right: -28px;
78-
79-
h2 {
80-
font-weight: 700;
81-
margin: 16px 0;
82-
}
83-
84-
h2,
85-
p {
86-
font: var(--cpd-font-body-md-regular);
87-
}
88-
89-
&::before {
90-
content: "";
91-
display: block;
92-
margin: 11px auto 29px auto;
93-
height: 42px;
94-
width: 42px;
95-
background-color: $header-panel-text-primary-color;
96-
mask-image: var(--maskImage);
97-
mask-repeat: no-repeat;
98-
mask-size: contain;
99-
mask-position: center;
100-
}
101-
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
Copyright 2024 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+
.mx_EmptyState {
18+
height: 100%;
19+
box-sizing: border-box;
20+
padding: var(--cpd-space-4x);
21+
text-align: center;
22+
23+
svg {
24+
width: 56px;
25+
height: 56px;
26+
box-sizing: border-box;
27+
border-radius: 8px;
28+
padding: var(--cpd-space-3x);
29+
background-color: $panel-actions;
30+
}
31+
32+
&::before {
33+
/* Bloom using magic numbers directly out of Figma */
34+
content: "";
35+
position: absolute;
36+
z-index: -1;
37+
width: 642px;
38+
height: 775px;
39+
right: -253.77px;
40+
top: 0;
41+
background: radial-gradient(49.95% 49.95% at 50% 50%, rgba(13, 189, 139, 0.12) 0%, rgba(18, 115, 235, 0) 100%);
42+
transform: rotate(-89.69deg);
43+
overflow: hidden;
44+
}
45+
}

res/css/views/right_panel/_ThreadPanel.pcss

Lines changed: 8 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,17 @@ limitations under the License.
106106
}
107107

108108
.mx_RoomView_messagePanel {
109-
/* To avoid the rule from being applied to .mx_ThreadPanel_empty */
109+
&.mx_RoomView_messageListWrapper {
110+
position: initial;
111+
}
112+
110113
.mx_RoomView_messageListWrapper {
111114
width: calc(100% + 6px); /* 8px - 2px */
112115
}
116+
117+
.mx_RoomView_empty {
118+
display: contents;
119+
}
113120
}
114121

115122
.mx_RoomView_MessageList {
@@ -168,72 +175,6 @@ limitations under the License.
168175
mask-image: url("$(res)/img/element-icons/link.svg");
169176
}
170177

171-
.mx_ThreadPanel_empty {
172-
border-radius: 8px;
173-
background: $background;
174-
display: flex;
175-
flex-direction: column;
176-
align-items: center;
177-
justify-content: center;
178-
position: absolute;
179-
top: 0;
180-
bottom: 0;
181-
left: 0;
182-
padding: 20px;
183-
box-sizing: border-box; /* Include padding and border */
184-
width: 100%;
185-
186-
h2 {
187-
color: $primary-content;
188-
font-weight: var(--cpd-font-weight-semibold);
189-
font-size: $font-18px;
190-
margin-top: 24px;
191-
margin-bottom: 10px;
192-
}
193-
194-
p {
195-
font-size: $font-15px;
196-
color: $secondary-content;
197-
margin: 10px 0;
198-
}
199-
200-
button {
201-
border: none;
202-
background: none;
203-
color: $accent;
204-
font-size: $font-15px;
205-
206-
&:hover,
207-
&:active {
208-
text-decoration: underline;
209-
cursor: pointer;
210-
}
211-
}
212-
213-
.mx_ThreadPanel_empty_tip {
214-
font-size: $font-12px;
215-
line-height: $font-15px;
216-
217-
> b {
218-
font-weight: var(--cpd-font-weight-semibold);
219-
}
220-
}
221-
}
222-
223-
.mx_ThreadPanel_largeIcon {
224-
width: 28px;
225-
height: 28px;
226-
padding: 18px;
227-
background: $system;
228-
border-radius: 50%;
229-
230-
&::after {
231-
@mixin ThreadSummaryIcon;
232-
width: inherit;
233-
height: inherit;
234-
}
235-
}
236-
237178
.mx_ContextualMenu_wrapper {
238179
.mx_ThreadPanel_Header_FilterOptionItem {
239180
display: flex;

src/components/structures/FilePanel.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
TimelineWindow,
2929
} from "matrix-js-sdk/src/matrix";
3030
import { logger } from "matrix-js-sdk/src/logger";
31+
import { Icon as FilesIcon } from "@vector-im/compound-design-tokens/icons/files.svg";
3132

3233
import { MatrixClientPeg } from "../../MatrixClientPeg";
3334
import EventIndexPeg from "../../indexing/EventIndexPeg";
@@ -40,6 +41,7 @@ import Spinner from "../views/elements/Spinner";
4041
import { Layout } from "../../settings/enums/Layout";
4142
import RoomContext, { TimelineRenderingType } from "../../contexts/RoomContext";
4243
import Measured from "../views/elements/Measured";
44+
import EmptyState from "../views/right_panel/EmptyState";
4345

4446
interface IProps {
4547
roomId: string;
@@ -255,10 +257,11 @@ class FilePanel extends React.Component<IProps, IState> {
255257
// wrap a TimelinePanel with the jump-to-event bits turned off.
256258

257259
const emptyState = (
258-
<div className="mx_RightPanel_empty mx_FilePanel_empty">
259-
<h2>{_t("file_panel|empty_heading")}</h2>
260-
<p>{_t("file_panel|empty_description")}</p>
261-
</div>
260+
<EmptyState
261+
Icon={FilesIcon}
262+
title={_t("file_panel|empty_heading")}
263+
description={_t("file_panel|empty_description")}
264+
/>
262265
);
263266

264267
const isRoomEncrypted = this.noRoom ? false : MatrixClientPeg.safeGet().isRoomEncrypted(this.props.roomId);

src/components/structures/NotificationPanel.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ limitations under the License.
1616

1717
import React from "react";
1818
import { logger } from "matrix-js-sdk/src/logger";
19+
import { Icon as NotificationsIcon } from "@vector-im/compound-design-tokens/icons/notifications.svg";
1920

2021
import { _t } from "../../languageHandler";
2122
import { MatrixClientPeg } from "../../MatrixClientPeg";
@@ -26,6 +27,7 @@ import { Layout } from "../../settings/enums/Layout";
2627
import RoomContext, { TimelineRenderingType } from "../../contexts/RoomContext";
2728
import Measured from "../views/elements/Measured";
2829
import Heading from "../views/typography/Heading";
30+
import EmptyState from "../views/right_panel/EmptyState";
2931

3032
interface IProps {
3133
onClose(): void;
@@ -57,10 +59,11 @@ export default class NotificationPanel extends React.PureComponent<IProps, IStat
5759

5860
public render(): React.ReactNode {
5961
const emptyState = (
60-
<div className="mx_RightPanel_empty mx_NotificationPanel_empty">
61-
<h2>{_t("notif_panel|empty_heading")}</h2>
62-
<p>{_t("notif_panel|empty_description")}</p>
63-
</div>
62+
<EmptyState
63+
Icon={NotificationsIcon}
64+
title={_t("notif_panel|empty_heading")}
65+
description={_t("notif_panel|empty_description")}
66+
/>
6467
);
6568

6669
let content: JSX.Element;

0 commit comments

Comments
 (0)