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

Spotlight search labs #7116

Merged
merged 24 commits into from
Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b661aa9
parent f40291d408ccfa33bdfc577e29a39ac7baa0f653
t3chguy Nov 10, 2021
bef1f81
Iterate Spotlight
t3chguy Dec 2, 2021
66e1319
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Dec 2, 2021
b58bcaf
delint
t3chguy Dec 2, 2021
255e53c
Tweak edge case styling
t3chguy Dec 2, 2021
2f38591
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Dec 6, 2021
61c7460
Fix dm edge case in roomContextDetailsText
t3chguy Dec 6, 2021
e0c6545
Iterate Recent Searches
t3chguy Dec 6, 2021
5df26b9
Include space-room results properly
t3chguy Dec 6, 2021
6c690b6
Iterate explore public rooms cta
t3chguy Dec 6, 2021
344912e
Iterate spotlight results interactions
t3chguy Dec 6, 2021
181b7f2
Add footer to Spotlight
t3chguy Dec 6, 2021
cceaf9c
Remove redundant bits
t3chguy Dec 6, 2021
602c4fd
Iterate PR
t3chguy Dec 6, 2021
67a732e
add comment
t3chguy Dec 6, 2021
58d320f
Iterate PR based on feedback
t3chguy Dec 7, 2021
f3c88bc
Add jump to start chat dialog cta for spotlight
t3chguy Dec 7, 2021
d2b51e4
Iterate PR based on feedback
t3chguy Dec 9, 2021
5ac7342
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Dec 9, 2021
3cd58b1
Merge branch 'develop' into t3chguy/fix/19530
t3chguy Dec 10, 2021
b903e5b
Merge branch 't3chguy/fix/19530' of github.com:matrix-org/matrix-reac…
t3chguy Dec 10, 2021
935511f
delint
t3chguy Dec 10, 2021
76f6a22
Fix roving tab index order
t3chguy Dec 10, 2021
df9fc89
Remove redundant test
t3chguy Dec 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions res/css/_components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
@import "./views/dialogs/_ShareDialog.scss";
@import "./views/dialogs/_SlashCommandHelpDialog.scss";
@import "./views/dialogs/_SpaceSettingsDialog.scss";
@import "./views/dialogs/_SpotlightDialog.scss";
@import "./views/dialogs/_TabbedIntegrationManagerDialog.scss";
@import "./views/dialogs/_TermsDialog.scss";
@import "./views/dialogs/_UntrustedDeviceDialog.scss";
Expand Down
1 change: 1 addition & 0 deletions res/css/views/avatars/_DecoratedRoomAvatar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ limitations under the License.
content: '';
width: 8px;
height: 8px;
right: 0;
position: absolute;
border-radius: 8px;
}
Expand Down
286 changes: 286 additions & 0 deletions res/css/views/dialogs/_SpotlightDialog.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,286 @@
/*
Copyright 2021 The Matrix.org Foundation C.I.C.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

.mx_SpotlightDialog_wrapper .mx_Dialog {
border-radius: 8px;
overflow-y: initial;
position: relative;
height: 60%;
padding: 0;
contain: unset; // needed for .mx_SpotlightDialog_keyboardPrompt to not be culled

.mx_SpotlightDialog_keyboardPrompt {
position: absolute;
padding: 8px;
border-radius: 8px;
background-color: $background;
top: -60px; // relative to the top of the modal
left: 50%;
transform: translateX(-50%);
font-size: $font-12px;
line-height: $font-15px;
color: $secondary-content;

> span > div {
display: inline-block;
padding: 2px 4px;
margin: 0 4px;
border-radius: 6px;
background-color: $quinary-content;
vertical-align: middle;
color: $tertiary-content;
}
}
}

.mx_SpotlightDialog {
height: 100%;
display: flex;
flex-direction: column;

.mx_Dialog_header {
margin-bottom: 0;
}

.mx_SpotlightDialog_searchBox {
margin: 0;
border: none;
padding: 12px 16px;
border-bottom: 1px solid $system;

> input {
display: block;
box-sizing: border-box;
background-color: transparent;
width: 100%;
height: 32px;
padding: 0;
color: $tertiary-content;
font-weight: normal;
font-size: $font-15px;
line-height: $font-24px;
}
}

#mx_SpotlightDialog_content {
margin: 16px;
height: 100%;
overflow-y: auto;

.mx_SpotlightDialog_section {
> h4 {
font-weight: $font-semi-bold;
font-size: $font-12px;
line-height: $font-15px;
color: $secondary-content;
margin-top: 0;
margin-bottom: 8px;
}

& + .mx_SpotlightDialog_section {
margin-top: 24px;
}
}

.mx_SpotlightDialog_recentlyViewed {
> div {
display: flex;
white-space: nowrap;
overflow-x: hidden;
}

.mx_AccessibleButton {
border-radius: 8px;
padding: 4px;
color: $primary-content;
font-size: $font-12px;
line-height: $font-15px;
display: inline-block;
width: 50px;
min-width: 50px;
box-sizing: border-box;
text-align: center;
overflow: hidden;
text-overflow: ellipsis;

.mx_DecoratedRoomAvatar {
margin: 0 5px 4px; // maintain centering
}

& + .mx_AccessibleButton {
margin-left: 16px;
}

&:hover, &[aria-selected=true] {
background-color: $quinary-content;
}
}
}

.mx_SpotlightDialog_results,
.mx_SpotlightDialog_recentSearches,
.mx_SpotlightDialog_otherSearches {
.mx_AccessibleButton {
padding: 6px 4px;
border-radius: 8px;
font-size: $font-15px;
line-height: $font-24px;
color: $primary-content;
position: relative;
display: flex;
align-items: center;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;

.mx_BaseAvatar {
margin-right: 8px;
display: inline-block;
height: 20px;
}

&:hover, &[aria-selected=true] {
background-color: $system;

.mx_SpotlightDialog_enterPrompt {
display: inline-block;
}
}
}
}

.mx_SpotlightDialog_otherSearches {
.mx_SpotlightDialog_startChat,
.mx_SpotlightDialog_explorePublicRooms {
padding-left: 32px;
position: relative;

&::before {
background-color: $secondary-content;
content: "";
mask-repeat: no-repeat;
mask-position: center;
mask-size: contain;
width: 20px;
height: 20px;
position: absolute;
left: 4px;
top: 50%;
transform: translateY(-50%);
}
}

.mx_SpotlightDialog_startChat::before {
mask-image: url('$(res)/img/element-icons/room/members.svg');
}

.mx_SpotlightDialog_explorePublicRooms::before {
mask-image: url('$(res)/img/element-icons/roomlist/explore.svg');
}

.mx_SpotlightDialog_otherSearches_messageSearchText {
font-size: $font-15px;
line-height: $font-24px;
}

.mx_SpotlightDialog_otherSearches_messageSearchIcon {
display: inline-block;
margin-left: 8px;
width: 20px;
height: 20px;
background-color: $secondary-content;
vertical-align: text-bottom;
mask-repeat: no-repeat;
mask-position: center;
mask-size: contain;
mask-image: url('$(res)/img/element-icons/room/search-inset.svg');
}
}

.mx_SpotlightDialog_result_details {
margin-left: 8px;
margin-right: 8px;
color: $tertiary-content;
font-size: $font-12px;
line-height: $font-15px;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
}

.mx_SpotlightDialog_recentSearches {
overflow-y: hidden;
height: calc(100% - 100px);

> h4 > .mx_AccessibleButton_kind_link {
padding: 0;
float: right;
font-weight: normal;
font-size: $font-12px;
line-height: $font-15px;
color: $secondary-content;
}
}

.mx_SpotlightDialog_enterPrompt {
padding: 2px 4px;
font-size: $font-12px;
line-height: $font-15px;
color: $tertiary-content;
border-radius: 6px;
background-color: $quinary-content;
margin: 0 4px 0 auto;
display: none;
}
}

.mx_SpotlightDialog_footer {
font-size: $font-12px;
line-height: $font-15px;
color: $secondary-content;
padding: 16px 16px 20px;
display: flex;
border-top: 1px solid $quinary-content;

> span {
position: relative;
padding-left: 20px;
align-self: center;

&::before {
background-color: $secondary-content;
content: "";
mask-repeat: no-repeat;
mask-position: center;
mask-size: contain;
mask-image: url('$(res)/img/element-icons/room/room-summary.svg');
width: 16px;
height: 16px;
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
}
}

.mx_AccessibleButton_kind_primary_outline {
padding: 4px 8px;
border-color: $secondary-content;
color: $secondary-content;
margin-left: auto;
}
}
}
2 changes: 1 addition & 1 deletion src/Rooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export function roomContextDetailsText(room: Room): string {

const dmPartner = DMRoomMap.shared().getUserIdForRoomId(room.roomId);
if (dmPartner) {
return room.getMember(dmPartner)?.rawDisplayName;
return dmPartner;
}

const [parent, ...otherParents] = SpaceStore.instance.getKnownParents(room.roomId);
Expand Down
2 changes: 1 addition & 1 deletion src/accessibility/RovingTabIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ interface IContext {
dispatch: Dispatch<IAction>;
}

const RovingTabIndexContext = createContext<IContext>({
export const RovingTabIndexContext = createContext<IContext>({
state: {
activeRef: null,
refs: [], // list of refs in DOM order
Expand Down
24 changes: 22 additions & 2 deletions src/components/structures/RoomSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ import { replaceableComponent } from "../../utils/replaceableComponent";
import SpaceStore from "../../stores/spaces/SpaceStore";
import { UPDATE_SELECTED_SPACE } from "../../stores/spaces";
import { isMac } from "../../Keyboard";
import SettingsStore from "../../settings/SettingsStore";
import Modal from "../../Modal";
import SpotlightDialog from "../views/dialogs/SpotlightDialog";

interface IProps {
isMinimized: boolean;
Expand Down Expand Up @@ -83,11 +86,19 @@ export default class RoomSearch extends React.PureComponent<IProps, IState> {
SpaceStore.instance.off(UPDATE_SELECTED_SPACE, this.clearInput);
}

private openSpotlight() {
Modal.createTrackedDialog("Spotlight", "", SpotlightDialog, {}, "mx_SpotlightDialog_wrapper", false, true);
}

private onAction = (payload: ActionPayload) => {
if (payload.action === Action.ViewRoom && payload.clear_search) {
this.clearInput();
} else if (payload.action === 'focus_room_filter' && this.inputRef.current) {
this.inputRef.current.focus();
if (SettingsStore.getValue("feature_spotlight")) {
this.openSpotlight();
} else {
this.inputRef.current.focus();
}
}
};

Expand All @@ -107,6 +118,14 @@ export default class RoomSearch extends React.PureComponent<IProps, IState> {
this.setState({ query: this.inputRef.current.value });
};

private onMouseDown = (ev: React.MouseEvent<HTMLInputElement>) => {
if (SettingsStore.getValue("feature_spotlight")) {
ev.preventDefault();
ev.stopPropagation();
this.openSpotlight();
}
};

private onFocus = (ev: React.FocusEvent<HTMLInputElement>) => {
this.setState({ focused: true });
ev.target.select();
Expand Down Expand Up @@ -162,11 +181,12 @@ export default class RoomSearch extends React.PureComponent<IProps, IState> {
ref={this.inputRef}
className={inputClasses}
value={this.state.query}
onMouseDown={this.onMouseDown}
onFocus={this.onFocus}
onBlur={this.onBlur}
onChange={this.onChange}
onKeyDown={this.onKeyDown}
placeholder={_t("Filter")}
placeholder={SettingsStore.getValue("feature_spotlight") ? _t("Search") : _t("Filter")}
autoComplete="off"
/>
);
Expand Down
Loading