Merge remote-tracking branch 'origin/joriks/room-list-tooltips' into develop

This commit is contained in:
Travis Ralston 2020-07-02 15:20:27 -06:00
commit df05273225
8 changed files with 57 additions and 22 deletions

View file

@ -55,7 +55,7 @@ limitations under the License.
border-radius: 4px; border-radius: 4px;
box-shadow: 4px 4px 12px 0 $menu-box-shadow-color; box-shadow: 4px 4px 12px 0 $menu-box-shadow-color;
background-color: $menu-bg-color; background-color: $menu-bg-color;
z-index: 4000; // Higher than dialogs so tooltips can be used in dialogs z-index: 6000; // Higher than context menu so tooltips can be used everywhere
padding: 10px; padding: 10px;
pointer-events: none; pointer-events: none;
line-height: $font-14px; line-height: $font-14px;

View file

@ -51,3 +51,18 @@ limitations under the License.
height: 32px; height: 32px;
} }
} }
.mx_RoomBreadcrumbs2_Tooltip {
margin-left: -42px;
margin-top: -42px;
&.mx_Tooltip {
background-color: $tagpanel-bg-color;
color: $accent-fg-color;
border: 0;
.mx_Tooltip_chevron {
display: none;
}
}
}

View file

@ -389,3 +389,7 @@ limitations under the License.
margin-top: 8px; margin-top: 8px;
} }
} }
.mx_RoomSublist2_addRoomTooltip {
margin-top: -3px;
}

View file

@ -37,6 +37,7 @@ import { OwnProfileStore } from "../../stores/OwnProfileStore";
import { UPDATE_EVENT } from "../../stores/AsyncStore"; import { UPDATE_EVENT } from "../../stores/AsyncStore";
import BaseAvatar from '../views/avatars/BaseAvatar'; import BaseAvatar from '../views/avatars/BaseAvatar';
import classNames from "classnames"; import classNames from "classnames";
import AccessibleTooltipButton from "../views/elements/AccessibleTooltipButton";
interface IProps { interface IProps {
isMinimized: boolean; isMinimized: boolean;
@ -230,7 +231,7 @@ export default class UserMenu extends React.Component<IProps, IState> {
{MatrixClientPeg.get().getUserId()} {MatrixClientPeg.get().getUserId()}
</span> </span>
</div> </div>
<div <AccessibleTooltipButton
className="mx_UserMenu_contextMenu_themeButton" className="mx_UserMenu_contextMenu_themeButton"
onClick={this.onSwitchThemeClick} onClick={this.onSwitchThemeClick}
title={this.state.isDarkTheme ? _t("Switch to light mode") : _t("Switch to dark mode")} title={this.state.isDarkTheme ? _t("Switch to light mode") : _t("Switch to dark mode")}
@ -240,7 +241,7 @@ export default class UserMenu extends React.Component<IProps, IState> {
alt={_t("Switch theme")} alt={_t("Switch theme")}
width={16} width={16}
/> />
</div> </AccessibleTooltipButton>
</div> </div>
{hostingLink} {hostingLink}
<div className="mx_IconizedContextMenu_optionList mx_IconizedContextMenu_optionList_notFirst"> <div className="mx_IconizedContextMenu_optionList mx_IconizedContextMenu_optionList_notFirst">

View file

@ -27,7 +27,7 @@ export type ButtonEvent = React.MouseEvent<Element> | React.KeyboardEvent<Elemen
* onClick: (required) Event handler for button activation. Should be * onClick: (required) Event handler for button activation. Should be
* implemented exactly like a normal onClick handler. * implemented exactly like a normal onClick handler.
*/ */
interface IProps extends React.InputHTMLAttributes<Element> { export interface IProps extends React.InputHTMLAttributes<Element> {
inputRef?: React.Ref<Element>; inputRef?: React.Ref<Element>;
element?: string; element?: string;
// The kind of button, similar to how Bootstrap works. // The kind of button, similar to how Bootstrap works.

View file

@ -16,21 +16,28 @@ limitations under the License.
*/ */
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import classnames from 'classnames';
import AccessibleButton from "./AccessibleButton"; import AccessibleButton from "./AccessibleButton";
import * as sdk from "../../../index"; import {IProps} from "./AccessibleButton";
import Tooltip from './Tooltip';
export default class AccessibleTooltipButton extends React.PureComponent { interface ITooltipProps extends IProps {
static propTypes = { title: string;
...AccessibleButton.propTypes, tooltipClassName?: string;
// The tooltip to render on hover }
title: PropTypes.string.isRequired,
};
state = { interface IState {
hover: false, hover: boolean;
}; }
export default class AccessibleTooltipButton extends React.PureComponent<ITooltipProps, IState> {
constructor(props: ITooltipProps) {
super(props);
this.state = {
hover: false,
};
}
onMouseOver = () => { onMouseOver = () => {
this.setState({ this.setState({
@ -45,14 +52,15 @@ export default class AccessibleTooltipButton extends React.PureComponent {
}; };
render() { render() {
const Tooltip = sdk.getComponent("elements.Tooltip");
const AccessibleButton = sdk.getComponent("elements.AccessibleButton");
const {title, children, ...props} = this.props; const {title, children, ...props} = this.props;
const tooltipClassName = classnames(
"mx_AccessibleTooltipButton_tooltip",
this.props.tooltipClassName,
);
const tip = this.state.hover ? <Tooltip const tip = this.state.hover ? <Tooltip
className="mx_AccessibleTooltipButton_container" className="mx_AccessibleTooltipButton_container"
tooltipClassName="mx_AccessibleTooltipButton_tooltip" tooltipClassName={tooltipClassName}
label={title} label={title}
/> : <div />; /> : <div />;
return ( return (

View file

@ -26,6 +26,7 @@ import { UPDATE_EVENT } from "../../../stores/AsyncStore";
import { CSSTransition } from "react-transition-group"; import { CSSTransition } from "react-transition-group";
import RoomListStore from "../../../stores/room-list/RoomListStore2"; import RoomListStore from "../../../stores/room-list/RoomListStore2";
import { DefaultTagID } from "../../../stores/room-list/models"; import { DefaultTagID } from "../../../stores/room-list/models";
import AccessibleTooltipButton from "../elements/AccessibleTooltipButton";
// TODO: Remove banner on launch: https://github.com/vector-im/riot-web/issues/14231 // TODO: Remove banner on launch: https://github.com/vector-im/riot-web/issues/14231
// TODO: Rename on launch: https://github.com/vector-im/riot-web/issues/14231 // TODO: Rename on launch: https://github.com/vector-im/riot-web/issues/14231
@ -98,11 +99,13 @@ export default class RoomBreadcrumbs2 extends React.PureComponent<IProps, IState
const roomTags = RoomListStore.instance.getTagsForRoom(r); const roomTags = RoomListStore.instance.getTagsForRoom(r);
const roomTag = roomTags.includes(DefaultTagID.DM) ? DefaultTagID.DM : roomTags[0]; const roomTag = roomTags.includes(DefaultTagID.DM) ? DefaultTagID.DM : roomTags[0];
return ( return (
<AccessibleButton <AccessibleTooltipButton
className="mx_RoomBreadcrumbs2_crumb" className="mx_RoomBreadcrumbs2_crumb"
key={r.roomId} key={r.roomId}
onClick={() => this.viewRoom(r, i)} onClick={() => this.viewRoom(r, i)}
aria-label={_t("Room %(name)s", {name: r.name})} aria-label={_t("Room %(name)s", {name: r.name})}
title={r.name}
tooltipClassName={"mx_RoomBreadcrumbs2_Tooltip"}
> >
<DecoratedRoomAvatar <DecoratedRoomAvatar
room={r} room={r}
@ -111,7 +114,7 @@ export default class RoomBreadcrumbs2 extends React.PureComponent<IProps, IState
displayBadge={true} displayBadge={true}
forceCount={true} forceCount={true}
/> />
</AccessibleButton> </AccessibleTooltipButton>
); );
}); });

View file

@ -35,6 +35,8 @@ import { DefaultTagID, TagID } from "../../../stores/room-list/models";
import dis from "../../../dispatcher/dispatcher"; import dis from "../../../dispatcher/dispatcher";
import NotificationBadge from "./NotificationBadge"; import NotificationBadge from "./NotificationBadge";
import { ListNotificationState } from "../../../stores/notifications/ListNotificationState"; import { ListNotificationState } from "../../../stores/notifications/ListNotificationState";
import Tooltip from "../elements/Tooltip";
import AccessibleTooltipButton from "../elements/AccessibleTooltipButton";
// TODO: Remove banner on launch: https://github.com/vector-im/riot-web/issues/14231 // TODO: Remove banner on launch: https://github.com/vector-im/riot-web/issues/14231
// TODO: Rename on launch: https://github.com/vector-im/riot-web/issues/14231 // TODO: Rename on launch: https://github.com/vector-im/riot-web/issues/14231
@ -350,11 +352,13 @@ export default class RoomSublist2 extends React.Component<IProps, IState> {
let addRoomButton = null; let addRoomButton = null;
if (!!this.props.onAddRoom) { if (!!this.props.onAddRoom) {
addRoomButton = ( addRoomButton = (
<AccessibleButton <AccessibleTooltipButton
tabIndex={tabIndex} tabIndex={tabIndex}
onClick={this.onAddRoom} onClick={this.onAddRoom}
className="mx_RoomSublist2_auxButton" className="mx_RoomSublist2_auxButton"
aria-label={this.props.addRoomLabel || _t("Add room")} aria-label={this.props.addRoomLabel || _t("Add room")}
title={this.props.addRoomLabel}
tooltipClassName={"mx_RoomSublist2_addRoomTooltip"}
/> />
); );
} }