Add tooltips
This commit is contained in:
parent
b1e0b35758
commit
aab372c648
6 changed files with 37 additions and 20 deletions
|
@ -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;
|
||||||
|
|
|
@ -389,3 +389,7 @@ limitations under the License.
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mx_RoomSublist2_addRoomTooltip {
|
||||||
|
margin-top: -3px;
|
||||||
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -218,7 +219,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")}
|
||||||
|
@ -228,7 +229,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">
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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 (
|
|
@ -33,6 +33,8 @@ import StyledRadioButton from "../elements/StyledRadioButton";
|
||||||
import RoomListStore from "../../../stores/room-list/RoomListStore2";
|
import RoomListStore from "../../../stores/room-list/RoomListStore2";
|
||||||
import { ListAlgorithm, SortAlgorithm } from "../../../stores/room-list/algorithms/models";
|
import { ListAlgorithm, SortAlgorithm } from "../../../stores/room-list/algorithms/models";
|
||||||
import { TagID } from "../../../stores/room-list/models";
|
import { TagID } from "../../../stores/room-list/models";
|
||||||
|
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
|
||||||
|
@ -277,11 +279,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"}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue