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

Commit ed18524

Browse files
authored
Move new search experience to a Beta (#7718)
1 parent 5201c9b commit ed18524

File tree

16 files changed

+330
-117
lines changed

16 files changed

+330
-117
lines changed

res/css/structures/_RoomSearch.scss

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ limitations under the License.
3535
mask-repeat: no-repeat;
3636
background-color: $secondary-content;
3737
margin-left: 7px;
38+
margin-bottom: 2px;
3839
}
3940

4041
.mx_RoomSearch_input {
@@ -44,14 +45,18 @@ limitations under the License.
4445
padding: 0;
4546
height: 100%;
4647
width: 100%;
47-
font-size: $font-12px;
48-
line-height: $font-16px;
4948

5049
&:not(.mx_RoomSearch_inputExpanded)::placeholder {
5150
color: $tertiary-content !important; // !important to override default app-wide styles
5251
}
5352
}
5453

54+
.mx_RoomSearch_input,
55+
.mx_RoomSearch_spotlightTriggerText {
56+
font-size: $font-12px;
57+
line-height: $font-16px;
58+
}
59+
5560
&.mx_RoomSearch_hasQuery {
5661
border-color: $secondary-content;
5762
}
@@ -108,4 +113,36 @@ limitations under the License.
108113
}
109114
}
110115
}
116+
117+
&.mx_RoomSearch_spotlightTrigger {
118+
cursor: pointer;
119+
min-width: 0;
120+
121+
.mx_RoomSearch_spotlightTriggerText {
122+
color: $tertiary-content;
123+
flex: 1;
124+
min-width: 0;
125+
// the following rules are to match that of a real input field
126+
overflow: hidden;
127+
margin: 9px;
128+
font-weight: $font-semi-bold;
129+
}
130+
131+
&:hover {
132+
background-color: $tertiary-content;
133+
134+
.mx_RoomSearch_spotlightTriggerText {
135+
color: $background;
136+
}
137+
138+
.mx_RoomSearch_shortcutPrompt {
139+
background-color: $background;
140+
color: $secondary-content;
141+
}
142+
143+
.mx_RoomSearch_icon {
144+
background-color: $background;
145+
}
146+
}
147+
}
111148
}

res/css/views/beta/_BetaCard.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ limitations under the License.
5656
line-height: $font-15px;
5757
color: $secondary-content;
5858
margin-top: 20px;
59+
60+
> h4 {
61+
margin: 0;
62+
}
63+
64+
> p {
65+
margin-top: 0;
66+
}
5967
}
6068
}
6169

@@ -64,6 +72,7 @@ limitations under the License.
6472
width: 300px;
6573
object-fit: contain;
6674
height: 100%;
75+
border-radius: 4px;
6776
}
6877
}
6978

@@ -90,6 +99,7 @@ limitations under the License.
9099
border-radius: 8px;
91100
text-transform: uppercase;
92101
font-size: 12px;
102+
font-weight: $font-semi-bold;
93103
line-height: 15px;
94104
color: #FFFFFF;
95105
display: inline-block;

res/css/views/dialogs/_SpotlightDialog.scss

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -223,18 +223,13 @@ limitations under the License.
223223
text-overflow: ellipsis;
224224
}
225225

226-
.mx_SpotlightDialog_recentSearches {
227-
overflow-y: hidden;
228-
height: calc(100% - 190px);
229-
230-
> h4 > .mx_AccessibleButton_kind_link {
231-
padding: 0;
232-
float: right;
233-
font-weight: normal;
234-
font-size: $font-12px;
235-
line-height: $font-15px;
236-
color: $secondary-content;
237-
}
226+
.mx_SpotlightDialog_recentSearches > h4 > .mx_AccessibleButton_kind_link {
227+
padding: 0;
228+
float: right;
229+
font-weight: normal;
230+
font-size: $font-12px;
231+
line-height: $font-15px;
232+
color: $secondary-content;
238233
}
239234

240235
.mx_SpotlightDialog_enterPrompt {
@@ -253,28 +248,21 @@ limitations under the License.
253248
font-size: $font-12px;
254249
line-height: $font-15px;
255250
color: $secondary-content;
256-
padding: 16px 16px 20px;
251+
padding: 12px 16px 16px;
257252
display: flex;
258253
border-top: 1px solid $quinary-content;
259254

255+
.mx_BetaCard_betaPill {
256+
margin-right: 12px;
257+
height: min-content;
258+
align-self: center;
259+
}
260+
260261
> span {
261-
position: relative;
262-
padding-left: 20px;
263262
align-self: center;
264263

265-
&::before {
266-
background-color: $secondary-content;
267-
content: "";
268-
mask-repeat: no-repeat;
269-
mask-position: center;
270-
mask-size: contain;
271-
mask-image: url('$(res)/img/element-icons/room/room-summary.svg');
272-
width: 16px;
273-
height: 16px;
274-
position: absolute;
275-
left: 0;
276-
top: 50%;
277-
transform: translateY(-50%);
264+
.mx_AccessibleButton_kind_link_inline {
265+
padding: 0;
278266
}
279267
}
280268

res/css/views/dialogs/_UserSettingsDialog.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ limitations under the License.
5454
}
5555

5656
.mx_UserSettingsDialog_labsIcon::before {
57-
mask-image: url('$(res)/img/element-icons/settings/lab-flags.svg');
57+
mask-image: url('$(res)/img/element-icons/settings/flask.svg');
5858
}
5959

6060
.mx_UserSettingsDialog_mjolnirIcon::before {
887 KB
Loading
Lines changed: 3 additions & 0 deletions
Loading

res/img/element-icons/settings/lab-flags.svg

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

src/Rooms.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,20 @@ function guessDMRoomTargetId(room: Room, myUserId: string): string {
158158
return oldestUser.userId;
159159
}
160160

161+
export function spaceContextDetailsText(space: Room): string {
162+
if (!space.isSpaceRoom()) return undefined;
163+
164+
const [parent, ...otherParents] = SpaceStore.instance.getKnownParents(space.roomId);
165+
if (parent) {
166+
return _t("%(spaceName)s and %(count)s others", {
167+
spaceName: space.client.getRoom(parent).name,
168+
count: otherParents.length,
169+
});
170+
}
171+
172+
return space.getCanonicalAlias();
173+
}
174+
161175
export function roomContextDetailsText(room: Room): string {
162176
if (room.isSpaceRoom()) return undefined;
163177

src/components/structures/MatrixChat.tsx

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ import { RoomUpdateCause } from "../../stores/room-list/models";
9191
import SecurityCustomisations from "../../customisations/Security";
9292
import Spinner from "../views/elements/Spinner";
9393
import QuestionDialog from "../views/dialogs/QuestionDialog";
94-
import UserSettingsDialog from '../views/dialogs/UserSettingsDialog';
94+
import UserSettingsDialog, { UserTab } from '../views/dialogs/UserSettingsDialog';
9595
import CreateGroupDialog from '../views/dialogs/CreateGroupDialog';
9696
import CreateRoomDialog from '../views/dialogs/CreateRoomDialog';
9797
import RoomDirectory from './RoomDirectory';
@@ -117,6 +117,7 @@ import { showSpaceInvite } from "../../utils/space";
117117
import AccessibleButton from "../views/elements/AccessibleButton";
118118
import { ActionPayload } from "../../dispatcher/payloads";
119119
import { SummarizedNotificationState } from "../../stores/notifications/SummarizedNotificationState";
120+
import GenericToast from '../views/toasts/GenericToast';
120121

121122
/** constants for MatrixChat.state.view */
122123
export enum Views {
@@ -1551,6 +1552,42 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
15511552
showNotificationsToast(false);
15521553
}
15531554

1555+
if (!localStorage.getItem("mx_seen_feature_spotlight_toast")) {
1556+
setTimeout(() => {
1557+
// Skip the toast if the beta is already enabled or the user has changed the setting from default
1558+
if (SettingsStore.getValue("feature_spotlight") ||
1559+
SettingsStore.getValue("feature_spotlight", null, true) !== null) {
1560+
return;
1561+
}
1562+
1563+
const key = "BETA_SPOTLIGHT_TOAST";
1564+
ToastStore.sharedInstance().addOrReplaceToast({
1565+
key,
1566+
title: _t("New search beta available"),
1567+
props: {
1568+
description: _t("We're testing a new search to make finding what you want quicker.\n"),
1569+
acceptLabel: _t("Learn more"),
1570+
onAccept: () => {
1571+
dis.dispatch({
1572+
action: Action.ViewUserSettings,
1573+
initialTabId: UserTab.Labs,
1574+
});
1575+
localStorage.setItem("mx_seen_feature_spotlight_toast", "true");
1576+
ToastStore.sharedInstance().dismissToast(key);
1577+
},
1578+
rejectLabel: _t("Dismiss"),
1579+
onReject: () => {
1580+
localStorage.setItem("mx_seen_feature_spotlight_toast", "true");
1581+
ToastStore.sharedInstance().dismissToast(key);
1582+
},
1583+
},
1584+
icon: "labs",
1585+
component: GenericToast,
1586+
priority: 9,
1587+
});
1588+
}, 5 * 60 * 1000); // show after 5 minutes to not overload user with toasts on launch
1589+
}
1590+
15541591
dis.fire(Action.FocusSendMessageComposer);
15551592
this.setState({
15561593
ready: true,

0 commit comments

Comments
 (0)