mirror of
https://github.com/element-hq/element-web
synced 2024-11-24 02:05:45 +03:00
Merge pull request #4987 from matrix-org/t3chguy/room-list/room-tile-icon-tooltip
Add tooltip to Room Tile Icon
This commit is contained in:
commit
b160fe886f
2 changed files with 22 additions and 1 deletions
|
@ -22,6 +22,8 @@ import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||||
import DMRoomMap from "../../../utils/DMRoomMap";
|
import DMRoomMap from "../../../utils/DMRoomMap";
|
||||||
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
||||||
import { isPresenceEnabled } from "../../../utils/presence";
|
import { isPresenceEnabled } from "../../../utils/presence";
|
||||||
|
import { _t } from "../../../languageHandler";
|
||||||
|
import TextWithTooltip from "../elements/TextWithTooltip";
|
||||||
|
|
||||||
enum Icon {
|
enum Icon {
|
||||||
// Note: the names here are used in CSS class names
|
// Note: the names here are used in CSS class names
|
||||||
|
@ -32,6 +34,19 @@ enum Icon {
|
||||||
PresenceOffline = "OFFLINE",
|
PresenceOffline = "OFFLINE",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function tooltipText(variant: Icon) {
|
||||||
|
switch (variant) {
|
||||||
|
case Icon.Globe:
|
||||||
|
return _t("This room is public");
|
||||||
|
case Icon.PresenceOnline:
|
||||||
|
return _t("Online");
|
||||||
|
case Icon.PresenceAway:
|
||||||
|
return _t("Away");
|
||||||
|
case Icon.PresenceOffline:
|
||||||
|
return _t("Offline");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
room: Room;
|
room: Room;
|
||||||
tag: TagID;
|
tag: TagID;
|
||||||
|
@ -145,6 +160,10 @@ export default class RoomTileIcon extends React.Component<IProps, IState> {
|
||||||
public render(): React.ReactElement {
|
public render(): React.ReactElement {
|
||||||
if (this.state.icon === Icon.None) return null;
|
if (this.state.icon === Icon.None) return null;
|
||||||
|
|
||||||
return <span className={`mx_RoomTileIcon mx_RoomTileIcon_${this.state.icon.toLowerCase()}`} />;
|
return <TextWithTooltip
|
||||||
|
tooltip={tooltipText(this.state.icon)}
|
||||||
|
tooltipClass="mx_Tooltip_timeline"
|
||||||
|
class={`mx_RoomTileIcon mx_RoomTileIcon_${this.state.icon.toLowerCase()}`}
|
||||||
|
/>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1239,6 +1239,8 @@
|
||||||
"Leave Room": "Leave Room",
|
"Leave Room": "Leave Room",
|
||||||
"Forget Room": "Forget Room",
|
"Forget Room": "Forget Room",
|
||||||
"Room options": "Room options",
|
"Room options": "Room options",
|
||||||
|
"This room is public": "This room is public",
|
||||||
|
"Away": "Away",
|
||||||
"Add a topic": "Add a topic",
|
"Add a topic": "Add a topic",
|
||||||
"Upgrading this room will shut down the current instance of the room and create an upgraded room with the same name.": "Upgrading this room will shut down the current instance of the room and create an upgraded room with the same name.",
|
"Upgrading this room will shut down the current instance of the room and create an upgraded room with the same name.": "Upgrading this room will shut down the current instance of the room and create an upgraded room with the same name.",
|
||||||
"This room has already been upgraded.": "This room has already been upgraded.",
|
"This room has already been upgraded.": "This room has already been upgraded.",
|
||||||
|
|
Loading…
Reference in a new issue