Support InfoTooltip kinds
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>pull/21833/head
parent
3a0b6eb466
commit
2a22f03a6a
|
@ -30,5 +30,12 @@ limitations under the License.
|
||||||
mask-position: center;
|
mask-position: center;
|
||||||
content: '';
|
content: '';
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_InfoTooltip_icon_info::before {
|
||||||
mask-image: url('$(res)/img/element-icons/info.svg');
|
mask-image: url('$(res)/img/element-icons/info.svg');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mx_InfoTooltip_icon_warning::before {
|
||||||
|
mask-image: url('$(res)/img/element-icons/warning.svg');
|
||||||
|
}
|
||||||
|
|
|
@ -22,10 +22,16 @@ import Tooltip, {Alignment} from './Tooltip';
|
||||||
import {_t} from "../../../languageHandler";
|
import {_t} from "../../../languageHandler";
|
||||||
import {replaceableComponent} from "../../../utils/replaceableComponent";
|
import {replaceableComponent} from "../../../utils/replaceableComponent";
|
||||||
|
|
||||||
|
export enum InfoTooltipKind {
|
||||||
|
Info = "info",
|
||||||
|
Warning = "warning",
|
||||||
|
}
|
||||||
|
|
||||||
interface ITooltipProps {
|
interface ITooltipProps {
|
||||||
tooltip?: React.ReactNode;
|
tooltip?: React.ReactNode;
|
||||||
className?: string,
|
className?: string,
|
||||||
tooltipClassName?: string;
|
tooltipClassName?: string;
|
||||||
|
kind?: InfoTooltipKind;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IState {
|
interface IState {
|
||||||
|
@ -54,8 +60,12 @@ export default class InfoTooltip extends React.PureComponent<ITooltipProps, ISta
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {tooltip, children, tooltipClassName, className} = this.props;
|
const {tooltip, children, tooltipClassName, className, kind} = this.props;
|
||||||
const title = _t("Information");
|
const title = _t("Information");
|
||||||
|
const iconClassName = (
|
||||||
|
(kind !== InfoTooltipKind.Warning) ?
|
||||||
|
"mx_InfoTooltip_icon_info" : "mx_InfoTooltip_icon_warning"
|
||||||
|
);
|
||||||
|
|
||||||
// Tooltip are forced on the right for a more natural feel to them on info icons
|
// Tooltip are forced on the right for a more natural feel to them on info icons
|
||||||
const tip = this.state.hover ? <Tooltip
|
const tip = this.state.hover ? <Tooltip
|
||||||
|
@ -70,7 +80,7 @@ export default class InfoTooltip extends React.PureComponent<ITooltipProps, ISta
|
||||||
onMouseLeave={this.onMouseLeave}
|
onMouseLeave={this.onMouseLeave}
|
||||||
className={classNames("mx_InfoTooltip", className)}
|
className={classNames("mx_InfoTooltip", className)}
|
||||||
>
|
>
|
||||||
<span className="mx_InfoTooltip_icon" aria-label={title} />
|
<span className={classNames("mx_InfoTooltip_icon", iconClassName)} aria-label={title} />
|
||||||
{children}
|
{children}
|
||||||
{tip}
|
{tip}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue