Add copy buttons for event & room ID (#8302)
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
parent
511965b840
commit
2b91ed1084
3 changed files with 26 additions and 9 deletions
|
@ -16,6 +16,7 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import React, { useState } from "react";
|
||||
import classNames from "classnames";
|
||||
|
||||
import { _t } from "../../../languageHandler";
|
||||
import { copyPlaintext } from "../../../utils/strings";
|
||||
|
@ -25,9 +26,10 @@ import AccessibleTooltipButton from "./AccessibleTooltipButton";
|
|||
interface IProps {
|
||||
children: React.ReactNode;
|
||||
getTextToCopy: () => string;
|
||||
border?: boolean;
|
||||
}
|
||||
|
||||
const CopyableText: React.FC<IProps> = ({ children, getTextToCopy }) => {
|
||||
const CopyableText: React.FC<IProps> = ({ children, getTextToCopy, border=true }) => {
|
||||
const [tooltip, setTooltip] = useState<string | undefined>(undefined);
|
||||
|
||||
const onCopyClickInternal = async (e: ButtonEvent) => {
|
||||
|
@ -42,7 +44,11 @@ const CopyableText: React.FC<IProps> = ({ children, getTextToCopy }) => {
|
|||
}
|
||||
};
|
||||
|
||||
return <div className="mx_CopyableText">
|
||||
const className = classNames("mx_CopyableText", {
|
||||
mx_CopyableText_border: border,
|
||||
});
|
||||
|
||||
return <div className={className}>
|
||||
{ children }
|
||||
<AccessibleTooltipButton
|
||||
title={tooltip ?? _t("Copy")}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue