2019-05-13 17:16:40 -06:00
|
|
|
/*
|
2024-09-09 14:57:16 +01:00
|
|
|
Copyright 2019-2024 New Vector Ltd.
|
2019-05-13 17:16:40 -06:00
|
|
|
|
2024-09-09 14:57:16 +01:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|
|
|
|
Please see LICENSE files in the repository root for full details.
|
2019-05-13 17:16:40 -06:00
|
|
|
*/
|
|
|
|
|
|
2022-07-06 11:43:30 +02:00
|
|
|
import React, { HTMLAttributes } from "react";
|
2023-12-19 17:19:54 +00:00
|
|
|
import { Tooltip } from "@vector-im/compound-web";
|
2021-09-15 21:06:06 +02:00
|
|
|
|
2022-07-06 11:43:30 +02:00
|
|
|
interface IProps extends HTMLAttributes<HTMLSpanElement> {
|
2023-12-19 17:19:54 +00:00
|
|
|
tooltip: string;
|
|
|
|
|
tooltipProps?: {
|
|
|
|
|
tabIndex?: number;
|
|
|
|
|
};
|
2021-09-15 21:06:06 +02:00
|
|
|
}
|
|
|
|
|
|
2021-12-09 11:47:50 +01:00
|
|
|
export default class TextWithTooltip extends React.Component<IProps> {
|
2023-02-13 17:01:43 +00:00
|
|
|
public render(): React.ReactNode {
|
2023-12-19 17:19:54 +00:00
|
|
|
const { className, children, tooltip, tooltipProps } = this.props;
|
2021-03-19 11:36:36 +00:00
|
|
|
|
2019-05-13 17:16:40 -06:00
|
|
|
return (
|
2024-04-12 14:56:23 +02:00
|
|
|
<Tooltip label={tooltip} placement="right">
|
2023-12-19 17:19:54 +00:00
|
|
|
<span className={className} tabIndex={tooltipProps?.tabIndex ?? 0}>
|
|
|
|
|
{children}
|
|
|
|
|
</span>
|
|
|
|
|
</Tooltip>
|
2019-05-13 17:16:40 -06:00
|
|
|
);
|
|
|
|
|
}
|
2019-05-13 18:31:43 -06:00
|
|
|
}
|