mirror of
https://github.com/vector-im/element-call.git
synced 2026-02-11 04:27:03 +00:00
```
move () {
FROM=$1 TO=$2 find public/locales -type f -exec sh -c 'jq ".$TO = .\"$FROM\" | del(.\"$FROM\") | del(..|nulls) | select(length > 0)" {} | sponge {}' \;
}
move "Avatar" "common.avatar"
move "Camera" "common.camera"
move "Close" "action.close"
move "Copied!" "common.copied"
move "Copy" "action.copy"
move "Copy link" "action.copy_link"
move "Encrypted" "common.encrypted"
move "Go" "action.go"
move "Home" "common.home"
move "Invite" "action.invite"
move "Loading…" "common.loading"
move "Microphone" "common.microphone"
move "No" "action.no"
move "Not encrypted" "common.unencrypted"
move "Password" "common.password"
move "Profile" "common.profile"
move "Username" "common.username"
move "Video" "common.video"
move "Register" "action.register"
move "Remove" "action.remove"
move "Settings" "common.settings"
move "Sign in" "action.sign_in"
move "Sign out" "action.sign_out"
move "Submit" "action.submit"
move "User menu" "a11y.user_menu"
move "Audio" "common.audio"
move "Display name" "common.display_name"
```
70 lines
1.8 KiB
TypeScript
70 lines
1.8 KiB
TypeScript
/*
|
|
Copyright 2022 New Vector Ltd
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
import { useTranslation } from "react-i18next";
|
|
import useClipboard from "react-use-clipboard";
|
|
import { FC } from "react";
|
|
|
|
import CheckIcon from "../icons/Check.svg?react";
|
|
import CopyIcon from "../icons/Copy.svg?react";
|
|
import { Button, ButtonVariant } from "./Button";
|
|
|
|
interface Props {
|
|
value: string;
|
|
children?: JSX.Element | string;
|
|
className?: string;
|
|
variant?: ButtonVariant;
|
|
copiedMessage?: string;
|
|
}
|
|
|
|
export const CopyButton: FC<Props> = ({
|
|
value,
|
|
children,
|
|
className,
|
|
variant,
|
|
copiedMessage,
|
|
...rest
|
|
}) => {
|
|
const { t } = useTranslation();
|
|
const [isCopied, setCopied] = useClipboard(value, { successDuration: 3000 });
|
|
|
|
return (
|
|
<Button
|
|
{...rest}
|
|
variant={variant === "icon" ? "iconCopy" : variant || "copy"}
|
|
on={isCopied}
|
|
className={className}
|
|
onPress={setCopied}
|
|
iconStyle={isCopied ? "stroke" : "fill"}
|
|
aria-label={t("action.copy")}
|
|
>
|
|
{isCopied ? (
|
|
<>
|
|
{variant !== "icon" && (
|
|
<span>{copiedMessage || t("common.copied")}</span>
|
|
)}
|
|
<CheckIcon />
|
|
</>
|
|
) : (
|
|
<>
|
|
{variant !== "icon" && <span>{children || value}</span>}
|
|
<CopyIcon />
|
|
</>
|
|
)}
|
|
</Button>
|
|
);
|
|
};
|