2020-06-08 20:33:21 -06:00
|
|
|
/*
|
2024-09-09 14:57:16 +01:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2021-03-25 13:29:17 +00:00
|
|
|
Copyright 2020, 2021 The Matrix.org Foundation C.I.C.
|
2020-06-08 20:33:21 -06:00
|
|
|
|
2025-01-06 11:18:54 +00:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
2024-09-09 14:57:16 +01:00
|
|
|
Please see LICENSE files in the repository root for full details.
|
2020-06-08 20:33:21 -06:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import classNames from "classnames";
|
2022-06-28 12:02:08 +02:00
|
|
|
import * as React from "react";
|
2021-04-29 16:40:08 +01:00
|
|
|
|
2022-06-28 12:02:08 +02:00
|
|
|
import { ALTERNATE_KEY_NAME } from "../../accessibility/KeyboardShortcuts";
|
2020-06-08 20:33:21 -06:00
|
|
|
import defaultDispatcher from "../../dispatcher/dispatcher";
|
2022-05-03 22:04:37 +01:00
|
|
|
import { IS_MAC, Key } from "../../Keyboard";
|
2022-06-28 12:02:08 +02:00
|
|
|
import { _t } from "../../languageHandler";
|
|
|
|
|
import AccessibleButton from "../views/elements/AccessibleButton";
|
2023-08-21 10:39:20 +01:00
|
|
|
import { Action } from "../../dispatcher/actions";
|
2020-06-08 20:33:21 -06:00
|
|
|
|
|
|
|
|
interface IProps {
|
2020-06-11 14:39:28 -06:00
|
|
|
isMinimized: boolean;
|
2020-06-08 20:33:21 -06:00
|
|
|
}
|
|
|
|
|
|
2022-06-28 12:02:08 +02:00
|
|
|
export default class RoomSearch extends React.PureComponent<IProps> {
|
2023-01-12 13:25:14 +00:00
|
|
|
private openSpotlight(): void {
|
2023-08-21 10:39:20 +01:00
|
|
|
defaultDispatcher.fire(Action.OpenSpotlight);
|
2021-12-10 11:50:01 +00:00
|
|
|
}
|
|
|
|
|
|
2020-06-08 20:33:21 -06:00
|
|
|
public render(): React.ReactNode {
|
|
|
|
|
const classes = classNames(
|
|
|
|
|
{
|
|
|
|
|
mx_RoomSearch: true,
|
2020-06-11 14:39:28 -06:00
|
|
|
mx_RoomSearch_minimized: this.props.isMinimized,
|
2022-06-28 12:02:08 +02:00
|
|
|
},
|
|
|
|
|
"mx_RoomSearch_spotlightTrigger",
|
2020-06-11 14:39:28 -06:00
|
|
|
);
|
2022-02-08 14:02:36 +00:00
|
|
|
|
2022-07-08 10:50:06 +02:00
|
|
|
const icon = <div className="mx_RoomSearch_icon" />;
|
2020-06-11 14:39:28 -06:00
|
|
|
|
2022-07-08 10:50:06 +02:00
|
|
|
const shortcutPrompt = (
|
2022-02-08 14:02:36 +00:00
|
|
|
<kbd className="mx_RoomSearch_shortcutPrompt">
|
2022-05-03 22:04:37 +01:00
|
|
|
{IS_MAC ? "⌘ K" : _t(ALTERNATE_KEY_NAME[Key.CONTROL]) + " K"}
|
2022-12-12 12:24:14 +01:00
|
|
|
</kbd>
|
|
|
|
|
);
|
|
|
|
|
|
2022-06-28 12:02:08 +02:00
|
|
|
return (
|
2024-09-25 11:01:38 +01:00
|
|
|
<AccessibleButton onClick={this.openSpotlight} className={classes} aria-label={_t("action|search")}>
|
2022-06-28 12:02:08 +02:00
|
|
|
{icon}
|
2023-08-23 11:57:22 +01:00
|
|
|
{!this.props.isMinimized && (
|
|
|
|
|
<div className="mx_RoomSearch_spotlightTriggerText">{_t("action|search")}</div>
|
|
|
|
|
)}
|
2022-06-28 12:02:08 +02:00
|
|
|
{shortcutPrompt}
|
|
|
|
|
</AccessibleButton>
|
|
|
|
|
);
|
2021-11-29 17:18:35 +00:00
|
|
|
}
|
2020-06-08 20:33:21 -06:00
|
|
|
}
|